I am new to deeplearning.
I am trying to use the deepface library in my local machine. I used pip install deepface
to install the library, tried on python 3.7.13, 3.8.13 and 3.9.13 which were all created using conda virtual environment.
However when running the code snippet below, I am getting the same error when running on my local machine. Do I need a GPU to run the library? If yes, how do I set it up? Because from the online guides/ articles, none of them mentioned the need of installing / setup a GPU.
I have a GeForce MX450 on my local pc.
code
import cv2
from deepface import DeepFace
import numpy as np
def analyse_face():
imagepath = "happy_face_woman.png"
image = cv2.imread(imagepath)
face_analysis = DeepFace.analyze(image)
print(face_analysis)
print(analyse_face())
Error:
ResourceExhaustedError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_14196\3829791526.py in <module>
12 print(face_analysis)
13
---> 14 analyse_face()
~\AppData\Local\Temp\ipykernel_14196\3829791526.py in analyse_face()
9 imagepath = "happy_face_woman.png"
10 image = cv2.imread(imagepath)
---> 11 face_analysis = DeepFace.analyze(image)
12 print(face_analysis)
13
c:\Users\user_name\anaconda3\envs\deepFacepy37\lib\site-packages\deepface\DeepFace.py in analyze(img_path, actions, models, enforce_detection, detector_backend, prog_bar)
352
353 if 'age' in actions and 'age' not in built_models:
--> 354 models['age'] = build_model('Age')
355
356 if 'gender' in actions and 'gender' not in built_models:
c:\Users\user_name\anaconda3\envs\deepFacepy37\lib\site-packages\deepface\DeepFace.py in build_model(model_name)
61 model = models.get(model_name)
62 if model:
---> 63 model = model()
...
-> 1922 seed=self.make_legacy_seed())
1923
1924 def truncated_normal(self, shape, mean=0., stddev=1., dtype=None):
ResourceExhaustedError: failed to allocate memory [Op:AddV2]
Different Error output
ResourceExhaustedError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_14196\3829791526.py in <module>
12 print(face_analysis)
13
---> 14 analyse_face()
~\AppData\Local\Temp\ipykernel_14196\3829791526.py in analyse_face()
9 imagepath = "happy_face_woman.png"
10 image = cv2.imread(imagepath)
---> 11 face_analysis = DeepFace.analyze(image)
12 print(face_analysis)
13
c:\Users\user_name\anaconda3\envs\deepFacepy37\lib\site-packages\deepface\DeepFace.py in analyze(img_path, actions, models, enforce_detection, detector_backend, prog_bar)
352
353 if 'age' in actions and 'age' not in built_models:
--> 354 models['age'] = build_model('Age')
355
356 if 'gender' in actions and 'gender' not in built_models:
c:\Users\user_name\anaconda3\envs\deepFacepy37\lib\site-packages\deepface\DeepFace.py in build_model(model_name)
61 model = models.get(model_name)
62 if model:
---> 63 model = model()
...
-> 1922 seed=self.make_legacy_seed())
1923
1924 def truncated_normal(self, shape, mean=0., stddev=1., dtype=None):
ResourceExhaustedError: OOM when allocating tensor with shape[7,7,512,4096] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc [Op:RandomUniform]
Additional Info I've ran the command to check my GPU usage and the details is as follows:
!nvidia-smi
Why do not you disable GPU?