Tianxiaomo / pytorch-YOLOv4

PyTorch ,ONNX and TensorRT implementation of YOLOv4
Apache License 2.0
4.46k stars 1.49k forks source link

您好,您有跑过昨天提交的计算map的代码吗?我刚跑了一下,好多bug啊,都集中在dataset.py中 #142

Open shenghsiaowong opened 4 years ago

shenghsiaowong commented 4 years ago

File "E:\code\pytorch-YOLOv4-master1\dataset.py", line 390, in _get_val_item img_path = self.imgs[index] AttributeError: 'Yolo_dataset' object has no attribute 'imgs'

File "E:\code\pytorch-YOLOv4-master1\dataset.py", line 414, in get_image_id raise NotImplementedError("Create your own 'get_image_id' function") NotImplementedError: Create your own 'get_image_id' function

shenghsiaowong commented 4 years ago

@wenh06 ,您好,我跑这个计算map好多bug 啊

wenh06 commented 4 years ago

File "E:\code\pytorch-YOLOv4-master1\dataset.py", line 390, in _get_val_item img_path = self.imgs[index] AttributeError: 'Yolo_dataset' object has no attribute 'imgs'

File "E:\code\pytorch-YOLOv4-master1\dataset.py", line 414, in get_image_id raise NotImplementedError("Create your own 'get_image_id' function") NotImplementedError: Create your own 'get_image_id' function

第一个问题,我在我的项目里init函数最后面加了个 self.imgs = list(self.truth.keys()) 这里忘了改了,我改一下

第二个问题,这个错是我主动raise的,报错信息就是Create your own 'get_image_id' function. raise error下面就是我在我项目里创建image_id的方式,或者你参考这个试一下。

下面就是我前几天用我的项目训练的log的某一段

Epoch 130/450: 74%|▋| 592/797 [02:36<01:00, 3.36img/s, loss (batch)=24, loss_cls=0, loss_l2=4.6, l Epoch 130/450: 75%|▋| 594/797 [02:37<00:52, 3.86img/s, loss (batch)=24, loss_cls=0, loss_l2=4.6, l Epoch 130/450: 75%|▋| 594/797 [02:37<00:52, 3.86img/s, loss (batch)=25.9, loss_cls=7.03e-6, loss_l Epoch 130/450: 75%|▋| 596/797 [02:37<00:46, 4.29img/s, loss (batch)=25.9, loss_cls=7.03e-6, loss_l Epoch 130/450: 75%|▊| 598/797 [02:37<00:42, 4.70img/s, loss (batch)=25.9, loss_cls=7.03e-6, loss_l Epoch 130/450: 75%|▊| 600/797 [02:38<00:39, 5.00img/s, loss (batch)=25.9, loss_cls=7.03e-6, loss_l Epoch 130/450: 76%|▊| 602/797 [02:38<00:37, 5.26img/s, loss (batch)=25.9, loss_cls=7.03e-6, loss_l Epoch 130/450: 76%|▊| 604/797 [02:39<00:36, 5.34img/s, loss (batch)=25.9, loss_cls=7.03e-6, loss_l Epoch 130/450: 76%|▊| 606/797 [02:41<01:35, 1.99img/s, loss (batc2020-06-28T21:24:34.048689516Z in function convert_to_coco_api... 2020-06-28T21:24:53.925002258Z creating index... 2020-06-28T21:24:53.92585524Z index created! 2020-06-28T21:25:56.219875996Z Accumulating evaluation results... 2020-06-28T21:25:56.3882316Z DONE (t=0.17s). 2020-06-28T21:25:56.388286166Z IoU metric: bbox 2020-06-28T21:25:56.388499586Z Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.187 2020-06-28T21:25:56.388517616Z Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.479 2020-06-28T21:25:56.388670965Z Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.098 2020-06-28T21:25:56.388683718Z Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.014 2020-06-28T21:25:56.388821873Z Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.196 2020-06-28T21:25:56.388833686Z Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.174 2020-06-28T21:25:56.388958108Z Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.057 2020-06-28T21:25:56.388969406Z Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.253 2020-06-28T21:25:56.389080461Z Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.380 2020-06-28T21:25:56.389093123Z Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.250 2020-06-28T21:25:56.389205637Z Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.373 2020-06-28T21:25:56.389219648Z Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.436 2020-06-28T21:25:56.753941934Z h)=25.9, loss_cls=7.03e-6, loss_l Epoch 130/450: 76%|▊| 608/797 [02:41<01:15, 2.49img/s, loss (batch)=25.9, loss_cls=7.03e-6, loss_l Epoch 130/450: 77%|▊| 610/797 [02:42<01:02, 3.02img/s, loss (batch)=25.9, loss_cls=7.03e-6, loss_l Epoch 130/450: 77%|▊| 612/797 [02:42<00:52, 3.52img/s, loss (batch)=25.9, loss_cls=7.03e-6, loss_l Epoch 130/450: 77%|▊| 614/797 [02:42<00:45, 4.02img/s, loss (batch)=25.9, loss_cls=7.03e-6, loss_l Epoch 130/450: 77%|▊| 616/797 [02:43<00:40, 4.42img/s, loss (batch)=25.9, loss_cls=7.03e-6, loss_l Epoch 130/450: 78%|▊| 618/797 [02:43<00:37, 4.77img/s, loss (batch)=25.9, loss_cls=7.03e-6, loss_l

wenh06 commented 4 years ago

File "E:\code\pytorch-YOLOv4-master1\dataset.py", line 390, in _get_val_item img_path = self.imgs[index] AttributeError: 'Yolo_dataset' object has no attribute 'imgs'

File "E:\code\pytorch-YOLOv4-master1\dataset.py", line 414, in get_image_id raise NotImplementedError("Create your own 'get_image_id' function") NotImplementedError: Create your own 'get_image_id' function

对了,如果是COCO数据集的话,annotation 里面自带 image_id,我的数据集没有自带image_id,所以要搞个这个函数。这个image_id保证跟图片一一对应就可以 image

wenh06 commented 4 years ago

File "E:\code\pytorch-YOLOv4-master1\dataset.py", line 390, in _get_val_item img_path = self.imgs[index] AttributeError: 'Yolo_dataset' object has no attribute 'imgs'

File "E:\code\pytorch-YOLOv4-master1\dataset.py", line 414, in get_image_id raise NotImplementedError("Create your own 'get_image_id' function") NotImplementedError: Create your own 'get_image_id' function

如果再有问题的话,欢迎反馈,我再比较一下这两个仓库相应代码有啥不同,谢谢 image 我是把这里头的复制回去,难免有遗漏~

lzw0515 commented 3 years ago

NotImplementedError: Create your own 'get_image_id' function 请问这个自定义get_image_id时干嘛用的,时让我的id等于我的图片名字吗?还是标签?

lzw0515 commented 3 years ago

File "E:\code\pytorch-YOLOv4-master1\dataset.py", line 390, in _get_val_item img_path = self.imgs[index] AttributeError: 'Yolo_dataset' object has no attribute 'imgs' File "E:\code\pytorch-YOLOv4-master1\dataset.py", line 414, in get_image_id raise NotImplementedError("Create your own 'get_image_id' function") NotImplementedError: Create your own 'get_image_id' function

对了,如果是COCO数据集的话,annotation 里面自带 image_id,我的数据集没有自带image_id,所以要搞个这个函数。这个image_id保证跟图片一一对应就可以 image

请问如果我的图片文件名时字母数字不规律组合的,我需要把xml和image重命名吗?改成纯数字?

wenh06 commented 3 years ago

File "E:\code\pytorch-YOLOv4-master1\dataset.py", line 390, in _get_val_item img_path = self.imgs[index] AttributeError: 'Yolo_dataset' object has no attribute 'imgs' File "E:\code\pytorch-YOLOv4-master1\dataset.py", line 414, in get_image_id raise NotImplementedError("Create your own 'get_image_id' function") NotImplementedError: Create your own 'get_image_id' function

对了,如果是COCO数据集的话,annotation 里面自带 image_id,我的数据集没有自带image_id,所以要搞个这个函数。这个image_id保证跟图片一一对应就可以 image

请问如果我的图片文件名时字母数字不规律组合的,我需要把xml和image重命名吗?改成纯数字?

也可以像automl那样采取自增的方式吧,不用把原数据重命名.

Rachel1111 commented 3 years ago

您好,我把'get_image_id'函数改了后,运行又出现了object of type <class 'numpy.float64'> cannot be safely interpreted as an integer.我搜索解决办法是把numpy降级成1.17.0,降级后又出现'list' object has no attribute 'cpu',代码是train.py第490行 outputs = outputs.cpu().detach.numpy()出错

Linranran commented 3 years ago

@Rachel1111 我和你遇见了相同的问题。我检查了下 evaluation时model的输出,很奇怪,分别是[3,22743, 1, 4]和[3,22743, 1]

wenh06 commented 3 years ago

@Rachel1111 我和你遇见了相同的问题。我检查了下 evaluation时model的输出,很奇怪,分别是[3,22743, 1, 4]和[3,22743, 1]

image

最近有人改了模型做inference的输出, 把之前接在一起的boxes和confidences分开了. 也可以看这里, train.py相应的地方还没改.

Rachel1111 commented 3 years ago

@Rachel1111 我和你遇见了相同的问题。我检查了下 evaluation时model的输出,很奇怪,分别是[3,22743, 1, 4]和[3,22743, 1]

image

最近有人改了模型做inference的输出, 把之前接在一起的boxes和confidences分开了. 也可以看这里, train.py相应的地方还没改.

您好,我cfg.use_darknet_cfg=False,model没有用darknet,创建的是Yolo4,里面没有用到get_region_boxes(out_boxes)这个函数,应该和它无关吧

Rachel1111 commented 3 years ago

@Rachel1111 我和你遇见了相同的问题。我检查了下 evaluation时model的输出,很奇怪,分别是[3,22743, 1, 4]和[3,22743, 1]

image 最近有人改了模型做inference的输出, 把之前接在一起的boxes和confidences分开了. 也可以看这里, train.py相应的地方还没改.

您好,我cfg.use_darknet_cfg=False,model没有用darknet,创建的是Yolo4,里面没有用到get_region_boxes(out_boxes)这个函数,应该和它无关吧

您好,谢谢你,我发现这个问题了。

wojiaohumaocheng commented 3 years ago

您好,我把'get_image_id'函数改了后,运行又出现了object of type <class 'numpy.float64'> cannot be safely interpreted as an integer.我搜索解决办法是把numpy降级成1.17.0,降级后又出现'list' object has no attribute 'cpu',代码是train.py第490行 outputs = outputs.cpu().detach.numpy()出错

用这个方法 https://blog.csdn.net/flyfish1986/article/details/104513632/

Rachel1111 commented 3 years ago

您好,我把'get_image_id'函数改了后,运行又出现了object of type <class 'numpy.float64'> cannot be safely interpreted as an integer.我搜索解决办法是把numpy降级成1.17.0,降级后又出现'list' object has no attribute 'cpu',代码是train.py第490行 outputs = outputs.cpu().detach.numpy()出错

用这个方法 https://blog.csdn.net/flyfish1986/article/details/104513632/

嗯谢谢,我就是改了那句代码的。

qybing commented 3 years ago

File "E:\code\pytorch-YOLOv4-master1\dataset.py", line 390, in _get_val_item img_path = self.imgs[index] AttributeError: 'Yolo_dataset' object has no attribute 'imgs' File "E:\code\pytorch-YOLOv4-master1\dataset.py", line 414, in get_image_id raise NotImplementedError("Create your own 'get_image_id' function") NotImplementedError: Create your own 'get_image_id' function

对了,如果是COCO数据集的话,annotation 里面自带 image_id,我的数据集没有自带image_id,所以要搞个这个函数。这个image_id保证跟图片一一对应就可以 image

请问如果我的图片文件名时字母数字不规律组合的,我需要把xml和image重命名吗?改成纯数字?

也可以像automl那样采取自增的方式吧,不用把原数据重命名.

你新更新的代码,我运行出现一下问题: File "train.py", line 495, in evaluate for img, target, (boxes, confs) in zip(images, targets, outputs): ValueError: not enough values to unpack (expected 2, got 1)

wenh06 commented 3 years ago

3天前inference模式下的输出变了,你看一下我提到的那两个issue

Le jeu. 23 juil. 2020 à 13:51, qybing notifications@github.com a écrit :

File "E:\code\pytorch-YOLOv4-master1\dataset.py", line 390, in _get_val_item img_path = self.imgs[index] AttributeError: 'Yolo_dataset' object has no attribute 'imgs' File "E:\code\pytorch-YOLOv4-master1\dataset.py", line 414, in get_image_id raise NotImplementedError("Create your own 'get_image_id' function") NotImplementedError: Create your own 'get_image_id' function

对了,如果是COCO数据集的话,annotation 里面自带 image_id,我的数据集没有自带image_id,所以要搞个这个函数。这个image_id保证跟图片一一对应就可以 [image: image] https://user-images.githubusercontent.com/8778305/86488542-ea7b1b00-bd93-11ea-9bd6-7a8595405e28.png

请问如果我的图片文件名时字母数字不规律组合的,我需要把xml和image重命名吗?改成纯数字?

也可以像automl https://github.com/google/automl/blob/master/efficientdet/dataset/create_pascal_tfrecord.py#L86 那样采取自增的方式吧,不用把原数据重命名.

你新更新的代码,我运行出现一下问题: File "train.py", line 495, in evaluate for img, target, (boxes, confs) in zip(images, targets, outputs): ValueError: not enough values to unpack (expected 2, got 1)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Tianxiaomo/pytorch-YOLOv4/issues/142#issuecomment-662830460, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACC7EQN57IWAXRG4N4KFERDR47FURANCNFSM4OP2FNIQ .

-- WEN Hao Department of Mathematical Sciences Tsinghua University

Rachel1111 commented 3 years ago

额为什么我运行新更新的代码出现的是too many values to unpack (expected 2) for img, target, (boxes, confs) in zip(images, targets, outputs):也是这行代码出错 https://github.com/Tianxiaomo/pytorch-YOLOv4/issues/142#issuecomment-662838036

qybing commented 3 years ago

@wenh06 这两个已经安按照你的方式改了,运行你刚更新的代码 出现的错误是: File "train.py", line 495, in evaluate for img, target, (boxes, confs) in zip(images, targets, outputs): ValueError: not enough values to unpack (expected 2, got 1) 这里outputs 有问题

ersheng-ai commented 3 years ago

Pull the latest code. Corresponding training code was updated by https://github.com/Tianxiaomo/pytorch-YOLOv4/pull/183

ersheng-ai commented 3 years ago

Modifications of https://github.com/Tianxiaomo/pytorch-YOLOv4/pull/183 is unfinished. Current output bounding box format is [x1, y1, x2, y2], not [x_center, y_center, W, H].

In train.py, line 497 was changed from

boxes[...,:2] = boxes[...,:2] - boxes[...,2:]/2  # to coco format

to

boxes[...,2:] = boxes[...,2:] - boxes[...,:2] # Transform [x1, y1, x2, y2] to [x1, y1, w, h]
qybing commented 3 years ago

Modifications of #183 is unfinished. Current output bounding box format is [x1, y1, x2, y2], not [x_center, y_center, W, H].

In train.py, line 497 was changed from

boxes[...,:2] = boxes[...,:2] - boxes[...,2:]/2  # to coco format

to

boxes[...,2:] = boxes[...,2:] - boxes[...,:2] # Transform [x1, y1, x2, y2] to [x1, y1, w, h]

File "train.py", line 493, in evaluate for img, target, (boxes, confs) in zip(images, targets, outputs): ValueError: not enough values to unpack (expected 2, got 1)

icennaise commented 3 years ago

Traceback (most recent call last): File "train.py", line 627, in device=device, ) File "train.py", line 425, in train evaluator = evaluate(eval_model, val_loader, config, device) File "d:\Anaconda\lib\site-packages\torch\autograd\grad_mode.py", line 49, in decorate_no_grad return func(*args, **kwargs) File "train.py", line 493, in evaluate for img, target, (boxes, confs) in zip(images, targets, outputs): ValueError: not enough values to unpack (expected 2, got 1)

修改raise error后出现错误

OYLH commented 3 years ago

Traceback (most recent call last): File "train.py", line 627, in device=device, ) File "train.py", line 425, in train evaluator = evaluate(eval_model, val_loader, config, device) File "d:\Anaconda\lib\site-packages\torch\autograd\grad_mode.py", line 49, in decorate_no_grad return func(*args, **kwargs) File "train.py", line 493, in evaluate for img, target, (boxes, confs) in zip(images, targets, outputs): ValueError: not enough values to unpack (expected 2, got 1)

修改raise error后出现错误

请问你们解决了吗?我也遇到了这样的问题

holdonyb commented 3 years ago

File "E:\code\pytorch-YOLOv4-master1\dataset.py", line 390, in _get_val_item img_path = self.imgs[index] AttributeError: 'Yolo_dataset' object has no attribute 'imgs' File "E:\code\pytorch-YOLOv4-master1\dataset.py", line 414, in get_image_id raise NotImplementedError("Create your own 'get_image_id' function") NotImplementedError: Create your own 'get_image_id' function

第一个问题,我在我的项目里init函数最后面加了个 self.imgs = list(self.truth.keys()) 这里忘了改了,我改一下

第二个问题,这个错是我主动raise的,报错信息就是Create your own 'get_image_id' function. raise error下面就是我在我项目里创建image_id的方式,或者你参考这个试一下。

下面就是我前几天用我的项目训练的log的某一段

Epoch 130/450: 74%|▋| 592/797 [02:36<01:00, 3.36img/s, loss (batch)=24, loss_cls=0, loss_l2=4.6, l Epoch 130/450: 75%|▋| 594/797 [02:37<00:52, 3.86img/s, loss (batch)=24, loss_cls=0, loss_l2=4.6, l Epoch 130/450: 75%|▋| 594/797 [02:37<00:52, 3.86img/s, loss (batch)=25.9, loss_cls=7.03e-6, loss_l Epoch 130/450: 75%|▋| 596/797 [02:37<00:46, 4.29img/s, loss (batch)=25.9, loss_cls=7.03e-6, loss_l Epoch 130/450: 75%|▊| 598/797 [02:37<00:42, 4.70img/s, loss (batch)=25.9, loss_cls=7.03e-6, loss_l Epoch 130/450: 75%|▊| 600/797 [02:38<00:39, 5.00img/s, loss (batch)=25.9, loss_cls=7.03e-6, loss_l Epoch 130/450: 76%|▊| 602/797 [02:38<00:37, 5.26img/s, loss (batch)=25.9, loss_cls=7.03e-6, loss_l Epoch 130/450: 76%|▊| 604/797 [02:39<00:36, 5.34img/s, loss (batch)=25.9, loss_cls=7.03e-6, loss_l Epoch 130/450: 76%|▊| 606/797 [02:41<01:35, 1.99img/s, loss (batc2020-06-28T21:24:34.048689516Z in function convert_to_coco_api... 2020-06-28T21:24:53.925002258Z creating index... 2020-06-28T21:24:53.92585524Z index created! 2020-06-28T21:25:56.219875996Z Accumulating evaluation results... 2020-06-28T21:25:56.3882316Z DONE (t=0.17s). 2020-06-28T21:25:56.388286166Z IoU metric: bbox 2020-06-28T21:25:56.388499586Z Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.187 2020-06-28T21:25:56.388517616Z Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.479 2020-06-28T21:25:56.388670965Z Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.098 2020-06-28T21:25:56.388683718Z Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.014 2020-06-28T21:25:56.388821873Z Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.196 2020-06-28T21:25:56.388833686Z Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.174 2020-06-28T21:25:56.388958108Z Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.057 2020-06-28T21:25:56.388969406Z Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.253 2020-06-28T21:25:56.389080461Z Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.380 2020-06-28T21:25:56.389093123Z Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.250 2020-06-28T21:25:56.389205637Z Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.373 2020-06-28T21:25:56.389219648Z Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.436 2020-06-28T21:25:56.753941934Z h)=25.9, loss_cls=7.03e-6, loss_l Epoch 130/450: 76%|▊| 608/797 [02:41<01:15, 2.49img/s, loss (batch)=25.9, loss_cls=7.03e-6, loss_l Epoch 130/450: 77%|▊| 610/797 [02:42<01:02, 3.02img/s, loss (batch)=25.9, loss_cls=7.03e-6, loss_l Epoch 130/450: 77%|▊| 612/797 [02:42<00:52, 3.52img/s, loss (batch)=25.9, loss_cls=7.03e-6, loss_l Epoch 130/450: 77%|▊| 614/797 [02:42<00:45, 4.02img/s, loss (batch)=25.9, loss_cls=7.03e-6, loss_l Epoch 130/450: 77%|▊| 616/797 [02:43<00:40, 4.42img/s, loss (batch)=25.9, loss_cls=7.03e-6, loss_l Epoch 130/450: 78%|▊| 618/797 [02:43<00:37, 4.77img/s, loss (batch)=25.9, loss_cls=7.03e-6, loss_l

Is this a "must" function to implement? Then maybe it should be noted somewhere in the readme. Or at least it can be ignored. Also, according to the document, the annotations file should be transformed to yolo format. Where does it keeps the image id in the transformed label file?

zrqi commented 3 years ago

Traceback (most recent call last): File "train.py", line 627, in device=device, ) File "train.py", line 425, in train evaluator = evaluate(eval_model, val_loader, config, device) File "d:\Anaconda\lib\site-packages\torch\autograd\grad_mode.py", line 49, in decorate_no_grad return func(*args, **kwargs) File "train.py", line 493, in evaluate for img, target, (boxes, confs) in zip(images, targets, outputs): ValueError: not enough values to unpack (expected 2, got 1) 修改raise error后出现错误

请问你们解决了吗?我也遇到了这样的问题 我也出现了这个问题,请问你现在有解决的方法了吗?

haoyangcai0711 commented 3 years ago

Traceback (most recent call last): File "train.py", line 627, in device=device, ) File "train.py", line 425, in train evaluator = evaluate(eval_model, val_loader, config, device) File "d:\Anaconda\lib\site-packages\torch\autograd\grad_mode.py", line 49, in decorate_no_grad return func(*args, **kwargs) File "train.py", line 493, in evaluate for img, target, (boxes, confs) in zip(images, targets, outputs): ValueError: not enough values to unpack (expected 2, got 1) 修改raise error后出现错误

请问你们解决了吗?我也遇到了这样的问题 我也出现了这个问题,请问你现在有解决的方法了吗?

估计是某个人把outputs换成了(boxes, confs)但是没有更新zip函数里面的第三个参数。。然而我也不知道该怎么改

haoyangcai0711 commented 3 years ago

微信图片_20200817162949 我按照torch_utils.py里get_region_boxes函数的输出格式调整了那个for循环的参数,然而出现了list index out of range... 如下图 index_out

后来又尝试了另一种方法,把get_region_boxes改回老版本的样子,即 “return [boxes, confs]” 改成两行:"output = torch.cat((boxes, confs), dim=2)"和"return output"。但这样子会报tensor的维度不一致,无法拼接。

jayagami commented 3 years ago

A workaround may solve this problem


def get_image_id(filename:str) -> int:
    """
    Convert a string to a integer.
    Make sure that the images and the `image_id`s are in one-one correspondence.
    There are already `image_id`s in annotations of the COCO dataset,
    in which case this function is unnecessary.
    For creating one's own `get_image_id` function, one can refer to
    https://github.com/google/automl/blob/master/efficientdet/dataset/create_pascal_tfrecord.py#L86
    or refer to the following code (where the filenames are like 'level1_123.jpg')
    >>> lv, no = os.path.splitext(os.path.basename(filename))[0].split("_")
    >>> lv = lv.replace("level", "")
    >>> no = f"{int(no):04d}"
    >>> return int(lv+no)
    """
    # alternative solution

    from hashlib import md5
    return int(md5(filename).hexdigest, 16)

replace code in the flowing position, commit original code.

https://github.com/Tianxiaomo/pytorch-YOLOv4/blob/4ccef0ec8fe984e059378813e33b3740929e0c19/dataset.py#L412-L430

not tested, I used another method.