Using Webkitdirectory to import multiple directories and maintain directory hierarchy
With VIA 2.0.9, I was building my training set by (1) collating my images into subdirectories, (2) renaming them so that I knew which subset the image belonged to, and then (3) assigning the appropriate region attribute in batches. However, I was compromising my file structure and it made it difficult for me to add more images to my existing training set.
So I implemented the use of Webkitdirectory to allow me to: (1) specify the root folder as the default search folder in the Settings page, (2) select Project/Add directory, (3) pick a subfolder to the root folder, (4) filter image by specifying file or directory identifier in "regular expressions". I have confirmed that it works with Firefox and Chrome. I don't believe all browsers support the Webkitdirectory attribute. If new images are added to your dataset, "adding" the folder again will add the new files without disturbing the old files. This builds on earlier revisions I made to export improved COCO annotation JSONs.
My particular use-case involves exporting a COCO Annotation JSON (in Windows) and then using it with Detectron2. In the last argument of register_coco_instances, if you specify the root directory in which all the image subdirectories are located, it should work. I do not know how other use-cases can benefit from this feature. I also don't know how Linux systems will handle the file:/// prefix I added to help load images.
I also dealt with the pesky trailing slash, allowed files with the same name but in different directories (as long as they have different file sizes), fixed the search path deletion problem, and added the ability to merge multiple project files (to help distribute the work). This should also be compatible with earlier project files.