got an error with custom dataset float division by zero
------------------------------------------Start training-------------------------------------------
Traceback (most recent call last):
File "C:\Users\emm\PycharmProjects\DFINE3119\train.py", line 113, in
Process finished with exit code 1
i cheked my .json, images path, structure looks like no problem, tried change images to smaller size, but still got this error. Tried original coco dataset and its work, change to my and it doesnt work. Dont know how to fix
Do your categories start with index 0?
If not, you should shfit them to start with zero.
import json
def shift_category_ids(coco_file_path, output_file_path):
try:
# Load the COCO JSON file
with open(coco_file_path, 'r') as file:
coco_data = json.load(file)
# Update category IDs in the categories section
for category in coco_data.get("categories", []):
category["id"] -= 1
# Update category IDs in the annotations section
for annotation in coco_data.get("annotations", []):
annotation["category_id"] -= 1
# Save the modified COCO JSON file
with open(output_file_path, 'w') as file:
json.dump(coco_data, file, indent=4)
print(f"Modified COCO file saved to: {output_file_path}")
except Exception as e:
print(f"An error occurred: {e}")
# Example usage
input_coco_file = "/data/datasets/objects-v1/annotations/instances_train.json"
output_coco_file = "/data/datasets/objects-v1/annotations/instances_train.json"
shift_category_ids(input_coco_file, output_coco_file)
Try to decrease the batch sizes in yaml. It can be caused by too many empty objects in a batch if your dataset is much smaller than default.