Open ShulyAvraham opened 1 month ago
You've chosen to report an unexpected problem or bug. Unless you already know the root cause of it, please include details about it by filling the issue template. The following information is missing: "Instructions To Reproduce the Issue and Full Logs";
Hi,
ZeroDivisionError is raised due to the lists being empty, the print_instances_class_histogram
function expects something as follows... I don't exactly get the point that you are trying to bring up, is it that there should be a better way that this should be informed to the user?
dummy_dataset = [{
"file_name": "dummy_image.jpg",
"image_id": 0,
"height": 100,
"width": 100,
"annotations": [{"category_id": 0, "bbox": [10, 10, 20, 20], "bbox_mode": 0}]
}]
# Call the function with the dummy dataset
print_instances_class_histogram(dummy_dataset, ["class_0"])
Thank you
Thanks for your response. The problem appeared at a bigger piece of code. This is the shortest example that could reproduce the issue. Indeed, the exception is raised due to the lists being empty, however, I would expect a better report of the issue. E.g. "Empty list of classes" or "No classes were provided" (rather than ZeroDivisionError), to indicate that the exception was caused by incorrect parameters provided by the caller and not something internal in detectron2.
Some more background: our real code looks something like the following:
cfg = dt_config.get_cfg()
# many more configuration...
cfg.MODEL.RETINANET.NUM_CLASSES = len(classes) # classes is an empty list
trainer = dt_engine.DefaultTrainer(cfg)
It's clear to us that we shouldn't run the trainer without any classes, our point is that is would be nicer to get a clearer message when catching invalid input.
If by mistake we pass an empty list of classes, we get a ZeroDivisionError exception.
Expected behavior:
An exception indicating the lack of classes, or no exception at all.
Environment: