Aastha Jha
Aastha Jha

Reputation: 303

DeepFace library -Access denied with the following error

I am trying to use DeepFace for facial recognition. I have installed the library:

pip install deepface

from deepface import DeepFace
happy_face = cv2.imread('happy.jpg')
predictions=DeepFace.analyze(happy_face, actions = ['age', 'gender', 'race', 'emotion'])

But I am getting the following error:

facial_expression_model_weights.h5 will be downloaded...
Access denied with the following error:

    Too many users have viewed or downloaded this file recently. Please
    try accessing the file again later. If the file you are trying to
    access is particularly large or is shared with many people, it may
    take up to 24 hours to be able to view or download the file. If you
    still can't access a file after 24 hours, contact your domain
    administrator. 

You may still be able to access the file from the browser:

     https://drive.google.com/uc?id=13iUHHP3SlNg53qSuQZDdHDSDNdBP9nwy 

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-41-ecaf75345ffc> in <module>
----> 1 predictions=DeepFace.analyze(happy_face, actions = ['age', 'gender', 'race', 'emotion'])

C:\ProgramData\Anaconda3\lib\site-packages\deepface\DeepFace.py in analyze(img_path, actions, models, enforce_detection, detector_backend)
    323                         emotion_model = models['emotion']
    324                 else:
--> 325                         emotion_model = build_model('Emotion')
    326 
    327         if 'age' in actions:

C:\ProgramData\Anaconda3\lib\site-packages\deepface\DeepFace.py in build_model(model_name)
     43 
     44         if model:
---> 45                 model = model()
     46                 #print('Using {} model backend'.format(model_name))
     47                 return model

C:\ProgramData\Anaconda3\lib\site-packages\deepface\extendedmodels\Emotion.py in loadModel()
     51 
     52                 #unzip facial_expression_model_weights.zip
---> 53                 with zipfile.ZipFile(output, 'r') as zip_ref:
     54                         zip_ref.extractall(home+'/.deepface/weights/')
     55 

C:\ProgramData\Anaconda3\lib\zipfile.py in __init__(self, file, mode, compression, allowZip64, compresslevel)
   1202             while True:
   1203                 try:
-> 1204                     self.fp = io.open(file, filemode)
   1205                 except OSError:
   1206                     if filemode in modeDict:

FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\aasth/.deepface/weights/facial_expression_model_weights.zip'

I tried searching for this error but I couldn't find any relevant post. I also tried running the same code in google colab and I received the same error. Is this some issue with the library or am I missing something here?

Upvotes: 2

Views: 2925

Answers (1)

sefiks
sefiks

Reputation: 1650

Pre-trained weights are in Google Drive and it seems limit is exceeded. However, you can still download the pre-trained weight file manually from the link specified in the console log.

URL: https://drive.google.com/uc?id=13iUHHP3SlNg53qSuQZDdHDSDNdBP9nwy

Then, you should copy the pre-trained weight to HOME_FOLDER/.deepface/weights folder whereas your HOME_FOLDER can be found as shown below. Then, deepface will not download the pre-trained weight anymore. BTW, if the drive url downloads a zip, then you should unzip it here.

from pathlib import Path
home = str(Path.home())
print("HOME_FOLDER is ",home)

Upvotes: 1

Related Questions