Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError: shape '[512, 512, 3]' is invalid for input of size 32768 #1

Open
yassinesefrioui opened this issue Jul 21, 2020 · 1 comment

Comments

@yassinesefrioui
Copy link

Hi !
in my file configuration (yolov4.cfg), i'm using this parameters :

width=512
height=512
channels=1

in cfg.py (YOLOv4_pytorch/tool/cfg.py), i'm using this parameters :

    prev_width = 512
    prev_height = 512
    prev_filters = 1
```

i get all time this error : 
  File "./demo.py", line 43, in <module>
    detect(cfgfile, weightfile, imgfile)
  File "./demo.py", line 28, in detect
    boxes = do_detect(m, sized, 0.5, 0.4, use_cuda)
  File "/home/yassines/Downloads/YOLOv4_Pytorch/utils/utils.py", line 357, in do_detect
    img = img.view(height, width, 3).transpose(0, 1).transpose(0, 2).contiguous()
RuntimeError: shape '[512, 512, 3]' is invalid for input of size 32768


i think, i need to change something in this code : 
```
        img = img.view(height, width, 3).transpose(0, 1).transpose(0, 2).contiguous()
        # batch:1  channel:3
        img = img.view(1, 3, height, width)
        # 除以255,归一化
```
how i can change it to take just One channel not three channel ? 

thank you 
@bobo0810
Copy link
Owner

Hi !
in my file configuration (yolov4.cfg), i'm using this parameters :

width=512
height=512
channels=1

in cfg.py (YOLOv4_pytorch/tool/cfg.py), i'm using this parameters :

    prev_width = 512
    prev_height = 512
    prev_filters = 1

i get all time this error :
File "./demo.py", line 43, in
detect(cfgfile, weightfile, imgfile)
File "./demo.py", line 28, in detect
boxes = do_detect(m, sized, 0.5, 0.4, use_cuda)
File "/home/yassines/Downloads/YOLOv4_Pytorch/utils/utils.py", line 357, in do_detect
img = img.view(height, width, 3).transpose(0, 1).transpose(0, 2).contiguous()
RuntimeError: shape '[512, 512, 3]' is invalid for input of size 32768

i think, i need to change something in this code :

        img = img.view(height, width, 3).transpose(0, 1).transpose(0, 2).contiguous()
        # batch:1  channel:3
        img = img.view(1, 3, height, width)
        # 除以255,归一化

how i can change it to take just One channel not three channel ?

thank you

Hello i am sorry just noticed...
Do you mean you want to use a grayscale image with channel 1 for testing? Since the code is not written by myself, and the pre-training model is based on color images, I guess the effect of testing grayscale images is not good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants