gliese581gg / YOLO_tensorflow

tensorflow implementation of 'YOLO : Real-Time Object Detection'
Other
1.72k stars 655 forks source link

AttributeError: 'NoneType' object has no attribute 'shape' #9

Open jiankang1991 opened 8 years ago

jiankang1991 commented 8 years ago

Hi, I come across an error when I run the demo. Here is what I type: python YOLO_tiny_tf.py -fromfile /home/kang/Documents/work_code_PC1/online_code/YOLO_tensorflow/test/person.jpg And It shows:

Detect from /home/kang/Documents/work_code_PC1/online_code/YOLO_tensorflow/test/person.jpg
Traceback (most recent call last):
  File "YOLO_tiny_tf.py", line 237, in <module>
    main(sys.argv)
  File "YOLO_tiny_tf.py", line 232, in main
    yolo = YOLO_TF(argvs)
  File "YOLO_tiny_tf.py", line 30, in __init__
    if self.fromfile is not None: self.detect_from_file(self.fromfile)
  File "YOLO_tiny_tf.py", line 124, in detect_from_file
    self.detect_from_cvmat(img)
  File "YOLO_tiny_tf.py", line 107, in detect_from_cvmat
    self.h_img,self.w_img,_ = img.shape
AttributeError: 'NoneType' object has no attribute 'shape'

I do not know where the error comes out. Because I have already input the image with -fromfile /home/kang/Documents/work_code_PC1/online_code/YOLO_tensorflow/test/person.jpg

Can anyone help? Thank you.

natanielruiz commented 8 years ago

I have the same issue. Anyone can help ?

natanielruiz commented 8 years ago

Okay so first I made sure the file I wanted to open existed and everything was okay but it still didn't work. What I ended up doing out of desperation is switching the import statements, ie. putting import cv2 at the beginning of the file and that is what worked. Don't know if it helps you.

Cheers

lielizabeth commented 7 years ago

@natanielruiz Thank you very much, it helps me. But still wondering why it helps

xiaobaiyang-programer commented 7 years ago

Check out if the value "img" is empty, I once passed a wrong image path, so I also met the error you proposed!

natanielruiz commented 7 years ago

@lielizabeth Yes I have no idea why it works, if anyone figures it out please post here. It's puzzling.

HarunaHaju commented 6 years ago

Check out if the image path legal, for example, I put my image xxx.jpg on the same folder of YOLO_xxx_tf.py. Then use python YOLO_xxx_tf.py -fromfile xxx.jpg It worked

Update: If you want to use the person.jpg in "test" folder, use -fromfile test//person.jpg ↑windows platform

YunYang1994 commented 5 years ago

hope this helps you ! https://github.com/YunYang1994/tensorflow-yolov3

palanips commented 5 years ago

sudo modprobe bcm2835-v4l2

use this code inside opencv environment, it may be useful

dungbc commented 5 years ago

I think you should put your floder path to your PC path....

May it be useful~

luyile commented 5 years ago

@natanielruiz which file are you talking about that should be kept after import cv2

luyile commented 5 years ago

hey guys well am working with LSB-stegnography, i am hiding a text inside an image so this is what i typed:

python LSBSteg.py encode -i /root/deskt op/splashz.bmp -o scrt.bmp -f /root/desktop/secretive.txt.gpg && ls

and this is what it responded to me:

Traceback (most recent call last): File "LSBSteg.py", line 189, in main() File "LSBSteg.py", line 175, in main steg = LSBSteg(in_img) File "LSBSteg.py", line 29, in init self.height, self.width, self.nbchannels = im.shape AttributeError: 'NoneType' object has no attribute 'shape'

is there anything i need to change in the LSBSteg.py ??? currently i am new to python programming please i need help

thenithinthomas commented 4 years ago

Reasons for error maybe :

  1. Image path not correct.
  2. Recheck on image extension.
  3. CV package error
Mahati04 commented 4 years ago

It may mean that the image youre trying to load is currently being used.

zied99 commented 3 years ago

make the full path of the image, it works for me