Closed DrPlanecraft closed 1 year ago
You just need to call DeepFace.analyze. This handles preprocessing steps such as normalization. Most probably you are missing these steps. Recommend you to use this function directly.
Thank You for the information, I will re-evaluate how I use DeepFace. At the current juncture I would only like to use a section and not the library as a whole to hopefully keep the size of my project as small as humanly possible. It has been a good learning experience looking through and seeing how everything is wrapped and presented.
on another note, I would like to ask about the two statements checking the image shape. I see 2 similar statements and a convert color statement.
for current_img, current_region, confidence in face_objs:
if current_img.shape[0] > 0 and current_img.shape[1] > 0: #here
if grayscale is True:
current_img = cv2.cvtColor(current_img, cv2.COLOR_BGR2GRAY)
# resize and padding
if current_img.shape[0] > 0 and current_img.shape[1] > 0: # Here
Is there any way that the cvtColor function will reshape the array in a way that it is of shape (0,0)?
this is mentioned in this issue: https://github.com/serengil/deepface/issues/679
it will be fixed in the next release.
Thank You for your Help in pointing out Where I have went wrong, I have now fixed the issue that is being discussed in this thread.
turns out that the nan was being caused by these 3 lines inside my code:
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
image = cv2.resize(image, (224,224))
image = np.reshape(image, (-1,224,224,3))
and the sanitization of the data
I am currently working on a school project and I have taken deepface's code and compacted the code to only the stuff I needed to predict Age, Gender and Race.
my current code is working fine for Gender and Race, but my age is either 0 or 90+ most of the time, please advise on what I am doing wrong, thank you for your time! (Source Code is pasted below for demonstration video, click here)
The code that is interfacing with my class. Above code is in a file named 'operations.py'
Any and all help will be appreciated.