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 several images #7

Open
razvan-tanase opened this issue Aug 11, 2022 · 2 comments
Open

Detect several images #7

razvan-tanase opened this issue Aug 11, 2022 · 2 comments

Comments

@razvan-tanase
Copy link

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
Copy link
Author

razvan-tanase commented Aug 11, 2022

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
Copy link
Owner

elyha7 commented Aug 11, 2022

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.

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