jsbroks / coco-annotator

:pencil2: Web-based image segmentation tool for object detection, localization, and keypoints
MIT License
2.11k stars 461 forks source link

coco imports and paths #486

Open uwer opened 3 years ago

uwer commented 3 years ago

After failing dismally for some time i started to look at the code, I see that the ImageModel uses only the basename of a path as the entry to the 'file_name' part. In the search for an import it searches for all occurrences of that filename. That indicates that the file_name should be unique with the dataset and that sub path are ignored in that context see (workers/tasks/data.py:211 images.filter(file_name__exact=image_filename).all() ). It also means that import behaviour is undefined within a dataset with existing images and annotations. This should be an easy fix to correct the search behaviour to reflect the subpath within the dataset. And understanding this now, i was able to finish the import process to find that my annotations were applied to all sorts of targets except the image related to the annotation.

uwer commented 3 years ago

Furthermore, the import relies on valid segmentation or keypoints, albeit ignores BBOX altogether if segmentation is not available. I would have thought that bbox is independent of segmentation masks? I consider this a bug (or formatting mishap ) backend/workers/tasks/data.py:277 Finally, the search for existing annotations for the current image based on valid segmentation and keypoints then has to fail for multiple objects identified by the same category in the image. There are some easy fixes possible (including the bbox in the search criteria after addressing above ), but also might be worthwhile to re-think that approach (retaining the original annotation_id at least temporarily or others). I can implement these if you are interested in pulling them.