DonDominic / MP2Net

The official code of our TGRS'24 paper MP2Net: Mask Propagation and Motion Prediction Network for Multi-Object Tracking in Satellite Videos
MIT License
10 stars 0 forks source link

how to prepare "instances_val_caronly.json", especially "obj_id"? #4

Open Baicheng42 opened 1 month ago

Baicheng42 commented 1 month ago

Hello, Thank you for your great work! I followed "1generate_json.py" from https://satvideodt.github.io/ and https://github.com/zf020114/SatVedioDTkit to prepare "instances_val_caronly.json" and I used my json to train the model. But I got an error:

Original Traceback (most recent call last):
File "/root/miniconda3/envs/c3/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 287, in _worker_loop data = fetcher.fetch(index)
File "/root/miniconda3/envs/c3/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch data = [self.dataset[idx] for idx in possibly_batched_index]
File "/root/miniconda3/envs/c3/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 49, in data = [self.dataset[idx] for idx in possibly_batched_index] File "/workspace/MP2Net-main/lib/dataset/coco_icpr.py", line 223, in getitem ids_tol.append(int(ann['obj_id']))
KeyError: 'obj_id'

I compared the difference between your json and my json, and found that there are not obj_id in my json.

Therefore, could you kindly teach me how to prepare the obj_id in instances_val_caronly.json? Thanks again!!!

Best wishes!

DonDominic commented 1 month ago

The 'obj_id' represents the annotation ID corresponding to the target in the frame. You can refer to the annotation information to add the corresponding key and value.

Jianfantasy commented 1 week ago

It seems that the "obj_id" is the "id" of of "object" in XML. But i find another when there is no target in a frame, the JOSN file generated by "1generate_json.py" will not have any target information, result in the problem of augmentation. File "/home/kiki/A/hxc/track/MP2Net/lib/dataset/coco_icpr.py", line 240, in __getitem__ img, _, bbox_tol, cls_id_tol, ids_tol, pre_bboxes, pre_ids = self.aug(img, img, bbox_tol, cls_id_tol, ids_tol, pre_bboxes, pre_ids) File "/home/kiki/A/hxc/track/MP2Net/lib/utils/augmentations.py", line 605, in __call__ img, img_fg, boxes, labels, ids, pre_boxes, pre_ids = self.augment(img, img_fg, boxes, labels, ids, pre_boxes, pre_ids) File "/home/kiki/A/hxc/track/MP2Net/lib/utils/augmentations.py", line 79, in __call__ img, img_fg, boxes, labels, ids, pre_boxes, pre_ids = t(img, img_fg, boxes, labels, ids, pre_boxes, pre_ids) ValueError: not enough values to unpack (expected 7, got 5) In this case, should I remove the images that do not contain the target in the training set or add some information when generating the josn file?

Could I ask how did you solve do it?

DonDominic commented 1 week ago

@Jianfantasy, in my case, I have not encountered this error. I think there are two ways to address it:

Option 1: Remove the images without a target. Option 2: Modify the code related to Line 239 by adding a check. If there are not enough values, you can simply assign the value using np.empty().

Hope this finds you well.

It seems that the "obj_id" is the "id" of of "object" in XML. But i find another when there is no target in a frame, the JOSN file generated by "1generate_json.py" will not have any target information, result in the problem of augmentation. File "/home/kiki/A/hxc/track/MP2Net/lib/dataset/coco_icpr.py", line 240, in __getitem__ img, _, bbox_tol, cls_id_tol, ids_tol, pre_bboxes, pre_ids = self.aug(img, img, bbox_tol, cls_id_tol, ids_tol, pre_bboxes, pre_ids) File "/home/kiki/A/hxc/track/MP2Net/lib/utils/augmentations.py", line 605, in __call__ img, img_fg, boxes, labels, ids, pre_boxes, pre_ids = self.augment(img, img_fg, boxes, labels, ids, pre_boxes, pre_ids) File "/home/kiki/A/hxc/track/MP2Net/lib/utils/augmentations.py", line 79, in __call__ img, img_fg, boxes, labels, ids, pre_boxes, pre_ids = t(img, img_fg, boxes, labels, ids, pre_boxes, pre_ids) ValueError: not enough values to unpack (expected 7, got 5) In this case, should I remove the images that do not contain the target in the training set or add some information when generating the josn file?

Could I ask how did you solve do it?