elyha7 / yoloface

Yolov5 Face Detection
GNU General Public License v3.0
130 stars 37 forks source link

Detect several images #7

Open razvan-tanase opened 2 years ago

razvan-tanase commented 2 years ago

I am trying to use your face detector script to get the bboxes on several images but it does not work how it is expected. First of all, your README describes that you can pass several images packed in a list to get multi-image predictions with the following example: bboxes,points = model.predict([image1,image2]) but does not mention if the image1 and image2 are the paths to that images or the object you get after you open them with PIL (for example: Image.open('image1'), assuming they have the same root directory). I get the following errors in this cases:

Traceback (most recent call last): File "C:\YOLOv5\yoloface\detect.py", line 65, in _main(arguments) File "C:\YOLOv5\yoloface\detect.py", line 58, in _main bboxes, points = model.predict(orgimg) File "C:\YOLOv5\yoloface\face_detector.py", line 159, in predict images = self._preprocess(images) File "C:\YOLOv5\yoloface\face_detector.py", line 73, in _preprocess h0, w0 = img.shape[:2] # orig hw ValueError: not enough values to unpack (expected 2, got 1)

from this call: orgimg = np.array([Image.open('00000002.png'), Image.open('00000001.png')]) bboxes, points = model.predict(orgimg) (when I pass the images as PIL objects)

Traceback (most recent call last): File "C:\YOLOv5\yoloface\detect.py", line 65, in _main(arguments) File "C:\YOLOv5\yoloface\detect.py", line 58, in _main bboxes, points = model.predict(orgimg) File "C:\YOLOv5\yoloface\face_detector.py", line 159, in predict images = self._preprocess(images) File "C:\YOLOv5\yoloface\face_detector.py", line 73, in _preprocess h0, w0 = img.shape[:2] # orig hw ValueError: not enough values to unpack (expected 2, got 1)

from this call: orgimg = np.array(['00000002.png', '00000001.png']) bboxes, points = model.predict(orgimg) (where I pass the images as paths to them)

Traceback (most recent call last): File "C:\YOLOv5\yoloface\detect.py", line 65, in _main(arguments) File "C:\YOLOv5\yoloface\detect.py", line 58, in _main bboxes, points = model.predict(['00000002.png', '00000001.png']) File "C:\YOLOv5\yoloface\face_detector.py", line 159, in predict images = self._preprocess(images) File "C:\YOLOv5\yoloface\face_detector.py", line 73, in _preprocess h0, w0 = img.shape[:2] # orig hw AttributeError: 'str' object has no attribute 'shape'

from this call: bboxes, points = model.predict(['00000002.png', '00000001.png']) (where I pass the images as paths to them)

and

Traceback (most recent call last): File "C:\YOLOv5\yoloface\detect.py", line 65, in _main(arguments) File "C:\YOLOv5\yoloface\detect.py", line 58, in _main bboxes, points = model.predict([Image.open('00000002.png'), Image.open('00000001.png')]) File "C:\YOLOv5\yoloface\face_detector.py", line 159, in predict images = self._preprocess(images) File "C:\YOLOv5\yoloface\face_detector.py", line 73, in _preprocess h0, w0 = img.shape[:2] # orig hw File "C:\Users\rtanase\Anaconda3\envs\detect\lib\site-packages\PIL\Image.py", line 519, in getattr raise AttributeError(name) AttributeError: shape

from this call: bboxes, points = model.predict([Image.open('00000002.png'), Image.open('00000001.png')]) (when I pass the images as PIL objects)

razvan-tanase commented 2 years ago

For anyone that has these problems: You must call the predict method with a list of np,arrays (which does not make sense to me but that's fine). For example: bboxes, points = model.predict([np.array(Image.open('00000001.png')), np.array(Image.open('00000002.png'))])

elyha7 commented 2 years ago

For anyone that has this problems: You must call the predict method with a list of np,arrays (which does not make sense to me but that's fine). For example: bboxes, points = model.predict([np.array(Image.open('00000001.png')), np.array(Image.open('00000002.png'))])

Hey! I considered this class to be a part of image processing pipeline, for example for facial recognition, so numpy arrays are default input type, cause face detection may be intermediate step of the pipeline. But i'll consider adding filename input support.