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

Detect source as .txt error #1877

Closed
pngmafia opened this issue Jan 8, 2021 · 6 comments
Closed

Detect source as .txt error #1877

pngmafia opened this issue Jan 8, 2021 · 6 comments
Labels

Comments

@pngmafia
Copy link

pngmafia commented Jan 8, 2021

When running detect.py with source as a txt it is loading the images but getting this error:
Traceback (most recent call last): File "detect.py", line 181, in <module> detect() File "detect.py", line 49, in detect dataset = LoadStreams(source, img_size=imgsz) File "/mnt1/yolo3/utils/datasets.py", line 286, in __init__ s = np.stack([letterbox(x, new_shape=self.img_size)[0].shape for x in self.imgs], 0) # inference shapes File "/mnt1/yolo3/utils/datasets.py", line 286, in <listcomp> s = np.stack([letterbox(x, new_shape=self.img_size)[0].shape for x in self.imgs], 0) # inference shapes File "/mnt1/yolo3/utils/datasets.py", line 696, in letterbox shape = img.shape[:2] # current shape [height, width] AttributeError: 'NoneType' object has no attribute 'shape'

please help!!

@pngmafia pngmafia added the bug Something isn't working label Jan 8, 2021
@pngmafia
Copy link
Author

pngmafia commented Jan 8, 2021

command used
nohup python -u detect.py --weights ./runs/train/exp72/weights/best.pt --source ./../run.txt --conf-thres 0.4 --iou-thres 0.45 --save-txt --save-conf --device 0,1,2,3 > ll.txt

run.txt has paths to the images, just like we use in training

@glenn-jocher
Copy link
Member

@pngmafia at the moment a text file passed to detect.py may only contain RTSP/HTTP/RTMP streaming addresses, not local media.

@glenn-jocher glenn-jocher removed the bug Something isn't working label Jan 8, 2021
@sbmalik
Copy link

sbmalik commented Jan 17, 2021

@glenn-jocher are you guys working on providing support for .txt file, which contains path of images.

@glenn-jocher
Copy link
Member

glenn-jocher commented Jan 17, 2021

@m3sibti there's no current plans for this. Could you use the glob command instead?

python detect.py --source path/*.jpg

Also note that YOLOv5 autoshape models from PyTorch Hub have the capability for inputting lists of local or internet image paths. See https://github.com/ultralytics/yolov5#pytorch-hub

@glenn-jocher
Copy link
Member

For YOLOv5 authoshape model inference from image paths or URIs:

    def forward(self, imgs, size=640, augment=False, profile=False):
        # Inference from various sources. For height=720, width=1280, RGB images example inputs are:
        #   filename:   imgs = 'data/samples/zidane.jpg'
        #   URI:             = 'https://github.com/ultralytics/yolov5/releases/download/v1.0/zidane.jpg'
        #   OpenCV:          = cv2.imread('image.jpg')[:,:,::-1]  # HWC BGR to RGB x(720,1280,3)
        #   PIL:             = Image.open('image.jpg')  # HWC x(720,1280,3)
        #   numpy:           = np.zeros((720,1280,3))  # HWC
        #   torch:           = torch.zeros(16,3,720,1280)  # BCHW
        #   multiple:        = [Image.open('image1.jpg'), Image.open('image2.jpg'), ...]  # list of images

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

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

No branches or pull requests

3 participants