-
Notifications
You must be signed in to change notification settings - Fork 0
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
RetinaNet script: Validation data set error #14
Comments
This stackoverflow thread might provide some insight. Could you tell me what is the value of the following attributes: Ref: https://detectron2.readthedocs.io/en/latest/_modules/detectron2/evaluation/coco_evaluation.html def _eval_predictions(self, predictions, img_ids=None):
"""
Evaluate predictions. Fill self._results with the metrics of the tasks.
"""
self._logger.info("Preparing results for COCO format ...")
coco_results = list(itertools.chain(*[x["instances"] for x in predictions]))
tasks = self._tasks or self._tasks_from_predictions(coco_results)
# unmap the category ids for COCO
if hasattr(self._metadata, "thing_dataset_id_to_contiguous_id"):
dataset_id_to_contiguous_id = self._metadata.thing_dataset_id_to_contiguous_id
all_contiguous_ids = list(dataset_id_to_contiguous_id.values())
num_classes = len(all_contiguous_ids)
assert min(all_contiguous_ids) == 0 and max(all_contiguous_ids) == num_classes - 1
reverse_id_mapping = {v: k for k, v in dataset_id_to_contiguous_id.items()}
for result in coco_results:
category_id = result["category_id"]
assert category_id < num_classes, (
f"A prediction has class={category_id}, "
f"but the dataset only has {num_classes} classes and "
f"predicted class id should be in [0, {num_classes - 1}]."
) |
If the MetadataCatalog.get("COCO_VAL_ANNOTATION").set(thing_classes=["axon"]) |
It looks like thing_classes already has According to this num_classes should have a value of 2, but it doesn't |
unfortunately the only other mention of this issue was here facebookresearch/detectron2#5103 |
Just updating this here to document it, this week I debugged this problem and found that
I've been looking into solving this this week in order to properly use the COCOEvaluator class for the validation and test set. |
@MurielleMardenli200 if I understand correctly in your dict Why does the model predict these classes? |
Also note that |
Btw which preprocessing script are you using? Is it this one? https://github.com/axondeepseg/axon-detection/blob/main/src/preprocessing.py because the code for COCO still considers both axon and myelin. If you fixed this on your side, could you make a PR to update the preprocessing script? |
|
@MurielleMardenli200 in the meantime maybe you can "manually" set all classes to 1 and try COCOEvaluator with this? |
Currently, you assign all classes to a single class with |
@hermancollin I tried changing the But I am still getting the same giberrish in the output predictions & the same error thrown when 2 classes are registered: |
In the RetinaNet script (see current PR), an error is thrown in the evaluate method used on the validation set. It uses the data set of
json_annotation_val.json
generated bypreprocess_data_coco
inpreprocessing.py
.This is the error gotten when running the train script
Validation run stopped due to: A prediction has class=53, but the dataset only has 2 classes and predicted class id should be in [0, 1]
The text was updated successfully, but these errors were encountered: