tugstugi / dl-colab-notebooks

Try out deep learning models online on Google Colab
1.72k stars 465 forks source link

YOLOv3_Pytorch notebook command to read image from folder #10

Closed nyck33 closed 5 years ago

nyck33 commented 5 years ago

In the final cell, I am trying to:

#!cd pytorch-yolo-v3 && python detect.py --weights ../yolov3.weights --images ../$image_file --det ..
!cd pytorch-yolo-v3 && python detect.py --weights ../yolov3.weights --images $image_file --det ..
plt.figure(figsize=(20, 15))
#plt.imshow(matplotlib.image.imread('det_%s' % image_file))
plt.imshow(matplotlib.image.imread(image_file))

but getting an error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-13-f0b6ab42b24b> in <module>()
      2 plt.figure(figsize=(20, 15))
      3 #plt.imshow(matplotlib.image.imread('det_%s' % image_file))
----> 4 plt.imshow(matplotlib.image.imread(image_file))

/usr/local/lib/python3.6/dist-packages/matplotlib/image.py in imread(fname, format)
   1367                 return handler(fd)
   1368     else:
-> 1369         return handler(fname)
   1370 
   1371 

TypeError: Object does not appear to be a 8-bit string path or a Python file-like object

How can I change the command to use an image uploaded to Colab, sitting in /content/image.jpg that was read in the previous cell with:

image_file =mpimg.imread('/content/frame1290.jpg')
plt.imshow(image_file)
nyck33 commented 5 years ago

Hey sorry, I just looked up the original github repo and figured it out.