facebookresearch / detr

End-to-End Object Detection with Transformers
Apache License 2.0
13.08k stars 2.37k forks source link

I know the problem is caused by COCO label.json file, but have no clue how to solve it #577

Open frabob2017 opened 1 year ago

frabob2017 commented 1 year ago

❓ How to do something using DETR

Hello, I want to run DETR on my customer datasets. when I use my COCO label instances_train2017.json, it shows the error.

Not using distributed mode git: sha: 3af9fa878e73b6894ce3596450a8d9b89d918ca9, status: has uncommited changes, branch: main

Namespace(lr=0.0001, lr_backbone=1e-05, batch_size=2, weight_decay=0.0001, epochs=1, lr_drop=200, clip_max_norm=0.1, frozen_weights=None, backbone='resnet50', dilation=False, position_embedding='sine', enc_layers=6, dec_layers=6, dim_feedforward=2048, hidden_dim=256, dropout=0.1, nheads=8, num_queries=100, pre_norm=False, masks=False, aux_loss=True, set_cost_class=1, set_cost_bbox=5, set_cost_giou=2, mask_loss_coef=1, dice_loss_coef=1, bbox_loss_coef=5, giou_loss_coef=2, eos_coef=0.1, dataset_file='coco', coco_path='/content/drive/MyDrive/DETR_Cervical_Bone_Fracture', coco_panoptic_path=None, remove_difficult=False, output_dir='', device='cuda', seed=42, resume='', start_epoch=0, eval=False, num_workers=2, world_size=1, dist_url='env://', distributed=False) /usr/local/lib/python3.9/dist-packages/torchvision/models/_utils.py:208: UserWarning: The parameter 'pretrained' is deprecated since 0.13 and may be removed in the future, please use 'weights' instead. warnings.warn( /usr/local/lib/python3.9/dist-packages/torchvision/models/_utils.py:223: UserWarning: Arguments other than a weight enum or None for 'weights' are deprecated since 0.13 and may be removed in the future. The current behavior is equivalent to passing weights=ResNet50_Weights.IMAGENET1K_V1. You can also use weights=ResNet50_Weights.DEFAULT to get the most up-to-date weights. warnings.warn(msg) number of params: 41302368 loading annotations into memory... Done (t=0.00s) creating index... index created! loading annotations into memory... Done (t=0.00s) creating index... index created! Start training Traceback (most recent call last): File "/content/detr/main.py", line 248, in main(args) File "/content/detr/main.py", line 196, in main train_stats = train_one_epoch( File "/content/detr/engine.py", line 28, in train_one_epoch for samples, targets in metric_logger.log_every(data_loader, printfreq, header): File "/content/detr/util/misc.py", line 246, in log_every header, total_time_str, total_time / len(iterable))) _ZeroDivisionError: float division by zero__ CPU times: user 26.7 ms, sys: 8.18 ms, total: 34.9 ms Wall time: 3.32 s

my instances_train2017.json is:

{"info": {}, "licenses": [{"id": 1, "url": "https://creativecommons.org/licenses/by/4.0/", "name": "CC BY 4.0"}], "categories": [{"supercategory": "none", "id": 0, "name": "no lesion"}, {"supercategory": "none", "id": 1, "name": "lesion"}], "images": [{"id": "53_102", "file_name": "53_102.jpg", "width": 512, "height": 512, "license": 1}], "annotations": [{"id": 1, "image_id": "53_102", "category_id": 1, "bbox": [155, 174, 70, 59], "area": 4130, "segmentation": [], "iscrowd": 0}]}

bjzhb666 commented 8 months ago

How do you solve the problem? I am facing the same problem. It is a bug in the code?