-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
issue while using a custom coco annotated dataset #50
Comments
In OpenCV 'NoneType' errors are generated due to not being able to read the frames. Try changing the index of d to 1. |
thanks , however i think i know what the problem is . The coco dataset i generated is only with masks and without any bboxes, as I was creating these bboxes from the mask coordinates in the getitem method of the custom dataset I was using in torchvision segmentation example. It sounds like the register_coco_instances function does expect a "complete" coco dataset including bboxes (e.g. they are not calculated automatically from the masks). So I can close this for now |
The visualizer does not handle empty masks very well. This will be fixed soon. As for why your model predicts empty masks - you can first verify your data format is correct by visualizing them just like the colab tutorial did. If the data is correct but the training fails to produce good models, we do not help people design models/parameters for their datasets. |
Actually I gave up trying to use the register_coco_instances function and instead I created a modified version of the get_ballon_dict from the tutorial which is basically computing the bounding boxes out of the masks. I also had to define the thing_dataset_id_to_contiguous_id method to my corresponding object id Here is the new function i created in case someone would like to try. With this new function I was able to train the model and to have the predictions of the masks without any issues
|
Sounds good. The model does expect the bounding boxes to exist and by default it does not compute it from masks (because the computed one is not necessarily equal to the annotation). detectron2/detectron2/data/dataset_mapper.py Line 133 in bc4cf19
but of course, doing it in the dataset is also a good solution |
❓ Empty masks after training on a custom coco dataset
I have a custom coco annotated dataset (generated thru coco annotator tool), and I am using
the method described in the doc to register my dataset
Then I can train the model without any problem again following the documentation
The problem is occuring during inference
==> array([0], dtype=uint8)
then obviously if i try to visualize I've got an error, as opencv findContours cannot detect any bounding box as the masks are empty
v = v.draw_instance_predictions(outputs["instances"].to("cpu"))
...
/data/home/doursand/notebooks/Detectron2/detectron2/detectron2/utils/visualizer.py in mask_to_polygons(self, mask)
108 res = cv2.findContours(mask.astype("uint8"), cv2.RETR_CCOMP, cv2.CHAIN_APPROX_NONE)
109 hierarchy = res[-1]
--> 110 has_holes = (hierarchy.reshape(-1, 4)[:, 3] >= 0).sum() > 0
111 res = res[-2]
112 res = [x.flatten() for x in res]
AttributeError: 'NoneType' object has no attribute 'reshape'
...
Anybody knows what I am missing here ? thanks in advance
The text was updated successfully, but these errors were encountered: