NameError: name 'face_api_url' is not defined

Asked 2 years ago, Updated 2 years ago, 99 views

"NameError: name 'face_api_url' is not defined" issue appeared
If you erase the face_api_url itself, the next one is NameError: name 'binary_img' is not defined.
I'm trying this and that, but I'm running out of solutions, so please explain it in an easy-to-understand way.
By the way, I am an amateur in programming.

headers={'Content-Type':'application/octet-stream', 'Ocp-Apim-Subscription-Key':subscription_key}
param={'returnFaceId': 'true', 'returnFaceAttributes': 'age,gender,headPose,smile,facialHair,glaces,emotion,hair,makeup,occurrence,accessories,blur,exposure,noise',}
res=requests.post(face_api_url, params=params, heads=headers, data=binary_img)

python jupyter-lab

2022-09-30 12:10

1 Answers

"NameError: name 'face_api_url' is not defined"

Error when the variable is not defined
You must declare face_api_url before you know what python means by face_api_url and display the 'variable name' is not defined error.

#Diverting code from the following site https://qiita.com/ryo19841204/items/74d663b08e56345e3b60
endpoint='https://20YYMMDDxxxx.cognitiveservices.azure.com/' #Azure API Endpoint
face_api_url = endpoint + 'face/v1.0/detect'

How to get the endpoint is explained by Youtube commentary video up to 32 minutes.

binary_img has similar errors.
The binary_img variable must contain image data retrieved from the Internet or stored on your computer.

There are many ways to store it, so I will not deal with it in my answer.
If you encounter another problem, we recommend that you create short reproducible sample code and ask new questions.


2022-09-30 12:10

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.