Update app.py
Browse files
app.py
CHANGED
@@ -24,30 +24,31 @@ def search_face(file):
|
|
24 |
r = requests.post(url=url, headers={"X-RapidAPI-Key": os.environ.get("API_KEY")}, json={"image": image_base64})
|
25 |
except:
|
26 |
raise gr.Error("Please select image file!")
|
27 |
-
|
28 |
-
if r.status_code == 301:
|
29 |
-
gr.Info("Too many faces in the photo.")
|
30 |
-
elif r.status_code == 302:
|
31 |
-
gr.Info("Face is not clear enough.")
|
32 |
-
elif r.status_code == 303:
|
33 |
-
gr.Info("No matches found.")
|
34 |
-
elif r.status_code == 304:
|
35 |
-
gr.Info("No face in the photo.")
|
36 |
-
elif r.status_code == 305:
|
37 |
-
gr.Info("Search blocked for privacy issue.")
|
38 |
-
elif r.status_code == 401:
|
39 |
-
gr.Info("Invalid image format.")
|
40 |
-
elif r.status_code == 402:
|
41 |
-
gr.Info("Wrong request.")
|
42 |
-
elif r.status_code == 403:
|
43 |
-
gr.Info("Requests all used in your token.")
|
44 |
-
elif r.status_code == 404:
|
45 |
-
gr.Info("Timeout, try again.")
|
46 |
|
47 |
-
if r.status_code > 300:
|
48 |
-
return [], count
|
49 |
-
|
50 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
res = r.json().get('img_array')
|
52 |
out_array = []
|
53 |
for item in res:
|
|
|
24 |
r = requests.post(url=url, headers={"X-RapidAPI-Key": os.environ.get("API_KEY")}, json={"image": image_base64})
|
25 |
except:
|
26 |
raise gr.Error("Please select image file!")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
|
|
|
|
|
|
28 |
try:
|
29 |
+
status_code = r.json().get('AC')
|
30 |
+
if status_code == 301:
|
31 |
+
gr.Info("Too many faces in the photo.")
|
32 |
+
elif status_code == 302:
|
33 |
+
gr.Info("Face is not clear enough.")
|
34 |
+
elif status_code == 303:
|
35 |
+
gr.Info("No matches found.")
|
36 |
+
elif status_code == 304:
|
37 |
+
gr.Info("No face in the photo.")
|
38 |
+
elif status_code == 305:
|
39 |
+
gr.Info("Search blocked for privacy issue.")
|
40 |
+
elif status_code == 401:
|
41 |
+
gr.Info("Invalid image format.")
|
42 |
+
elif status_code == 402:
|
43 |
+
gr.Info("Wrong request.")
|
44 |
+
elif status_code == 403:
|
45 |
+
gr.Info("Requests all used in your token.")
|
46 |
+
elif status_code == 404:
|
47 |
+
gr.Info("Timeout, try again.")
|
48 |
+
|
49 |
+
if status_code > 300:
|
50 |
+
return [], count
|
51 |
+
|
52 |
res = r.json().get('img_array')
|
53 |
out_array = []
|
54 |
for item in res:
|