pytorch-YOLOv4 icon indicating copy to clipboard operation
pytorch-YOLOv4 copied to clipboard

OpenCV can't augment image: 608 x 608

Open Todaymorning opened this issue 3 years ago • 18 comments

训练自己的数据集的时候出现的,我只需要识别一个类别 我的环境为: Ubuntu 16.04.12 cuda 10.0 python 3.7.9 torchversion 1.2.0

运行: python train.py -l 0.001 -g 1 -pretrained ./weight/yolov4.pth -classes 1 -dir ./VOCdevkit/VOC2007/JPEGImages/ -train_label_path ./data/train.txt

出现:

    Epochs:          300
    Batch size:      4
    Subdivisions:    1
    Learning rate:   0.001
    Training size:   464
    Validation size: 52
    Checkpoints:     True
    Device:          cuda
    Images size:     608
    Optimizer:       adam
    Dataset classes: 1
    Train label path:./data/train.txt
    Pretrained:

Epoch 1/300: 0%| | 0/464 [00:00<?, ?img/s]OpenCV can't augment image: 608 x 608 OpenCV can't augment image: 608 x 608 OpenCV can't augment image: 608 x 608 OpenCV can't augment image: 608 x 608 OpenCV can't augment image: 608 x 608

希望大佬们帮我分析分析

Todaymorning avatar May 14 '21 05:05 Todaymorning

It comes from image_data_augmentation of Dataset.py.

lixinghe1999 avatar Aug 05 '21 04:08 lixinghe1999

我在想你是不是在运行的时候ctrlc暂停了,那样的话就会触发except,然后就会print(...)

shoudlee avatar Aug 10 '21 08:08 shoudlee

请问楼主解决了吗?

curryJ avatar Nov 09 '21 12:11 curryJ

请问楼主解决了吗?

其实就是中途退出触发except,在调试的时候很常见。

lixinghe1999 avatar Nov 10 '21 02:11 lixinghe1999

请问楼主解决了吗?

其实就是中途退出触发except,在调试的时候很常见。 我一步一步调式出来 是这一行有问题 但是我不是很明白这个HSV相乘为什么有问题,楼主能帮忙看一下吗 谢谢 image

curryJ avatar Nov 12 '21 06:11 curryJ

我解决了 楼主 cv2.split()出来的hsv是tuple,不能被赋值的,转换成list就好了

curryJ avatar Nov 12 '21 06:11 curryJ

楼主解决这个问题了吗?我用代码直接跑的COCO2017数据集,报的错误一模一样,如果解决了还希望能分享一下 Epoch 1/300: 0%| | 0/4952 [00:00<?, ?img/s] OpenCV can't augment image: 608 x 608 OpenCV can't augment image: 608 x 608 OpenCV can't augment image: 608 x 608

hustCYQ avatar Dec 23 '21 14:12 hustCYQ

这里 我一步一步debug下来发现的,hsv原本返回的类型是元组,不可更改,因此被try了,把它转换为list就行了  141行

------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2021年12月23日(星期四) 晚上10:57 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [Tianxiaomo/pytorch-YOLOv4] OpenCV can't augment image: 608 x 608 (#427)

楼主解决这个问题了吗?我用代码直接跑的COCO2017数据集,报的错误一模一样,如果解决了还希望能分享一下 Epoch 1/300: 0%| | 0/4952 [00:00<?, ?img/s] OpenCV can't augment image: 608 x 608 OpenCV can't augment image: 608 x 608 OpenCV can't augment image: 608 x 608

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.Message ID: @.***>

curryJ avatar Dec 23 '21 15:12 curryJ

这里 我一步一步debug下来发现的,hsv原本返回的类型是元组,不可更改,因此被try了,把它转换为list就行了  141行 ------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2021年12月23日(星期四) 晚上10:57 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [Tianxiaomo/pytorch-YOLOv4] OpenCV can't augment image: 608 x 608 (#427) 楼主解决这个问题了吗?我用代码直接跑的COCO2017数据集,报的错误一模一样,如果解决了还希望能分享一下 Epoch 1/300: 0%| | 0/4952 [00:00<?, ?img/s] OpenCV can't augment image: 608 x 608 OpenCV can't augment image: 608 x 608 OpenCV can't augment image: 608 x 608 — Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.Message ID: @.***>

非常感谢楼主,我刚刚发现将python版本降到3.4同样解决了这个问题

hustCYQ avatar Dec 23 '21 15:12 hustCYQ

我解决了 楼主 cv2.split()出来的hsv是tuple,不能被赋值的,转换成list就好了

可以问是怎么改的? 谢谢!

chenscottus avatar Jan 01 '22 01:01 chenscottus

            hsv = cv2.split(hsv_src)
            #https://github.com/Tianxiaomo/pytorch-YOLOv4/issues/427
            #OpenCV can't augment image: 608 x 608
            hsv = list(hsv)

chenscottus avatar Jan 03 '22 23:01 chenscottus

h, s, v = cv2.split(hsv)

ingbeeedd avatar Mar 06 '22 08:03 ingbeeedd

我也遇到了一样的问题,请问要改的文件在哪,能发一下路径吗,谢谢

S-kewen avatar Apr 12 '22 08:04 S-kewen

我也遇到了一样的问题,请问要改的文件在哪,能发一下路径吗,谢谢

其实我将opencv降到3.4.7就没问题了,你也可以试试看

hustCYQ avatar Apr 12 '22 08:04 hustCYQ

好的,感谢!

S-kewen avatar Apr 14 '22 12:04 S-kewen

#https://github.com/Tianxiaomo/pytorch-YOLOv4/issues/427 #OpenCV can't augment image: 608 x 608

我降成3.4.7还是一样~~

S-kewen avatar Apr 16 '22 13:04 S-kewen

This following worked for me

Before (actual error: TypeError: 'tuple' object does not support item assignment)

hsv_src = cv2.cvtColor(sized.astype(np.float32), cv2.COLOR_RGB2HSV)  # RGB to HSV
hsv = cv2.split(hsv_src)
hsv[1] *= dsat

After making it into list

hsv_src = cv2.cvtColor(sized.astype(np.float32), cv2.COLOR_RGB2HSV)  # RGB to HSV
hsv = list(cv2.split(hsv_src))    # <---- IN THIS LINE: make it tuple to list
hsv[1] *= dsat

resolved the OpenCV can't augment image error

(Note: my opencv version 4.8.1 and numpy version 1.18.2)

uzl avatar Oct 24 '23 10:10 uzl

我解决了 楼主 cv2.split()出来的hsv是tuple,不能被赋值的,转换成list就好了

确实有用

littlelight-e avatar Dec 06 '23 09:12 littlelight-e