Zhu-FaceOnLive commited on
Commit
e0da6da
Β·
verified Β·
1 Parent(s): ac5b5dc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -22
app.py CHANGED
@@ -26,28 +26,29 @@ def search_face(file):
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 = []
 
26
  raise gr.Error("Please select image file!")
27
 
28
  try:
29
+ if r.text.startswith('AC='):
30
+ status_code = int(text[3:6])
31
+ if status_code == 301:
32
+ gr.Info("Too many faces in the photo.")
33
+ elif status_code == 302:
34
+ gr.Info("Face is not clear enough.")
35
+ elif status_code == 303:
36
+ gr.Info("No matches found.")
37
+ elif status_code == 304:
38
+ gr.Info("No face in the photo.")
39
+ elif status_code == 305:
40
+ gr.Info("Search blocked for privacy issue.")
41
+ elif status_code == 401:
42
+ gr.Info("Invalid image format.")
43
+ elif status_code == 402:
44
+ gr.Info("Wrong request.")
45
+ elif status_code == 403:
46
+ gr.Info("Requests all used in your token.")
47
+ elif status_code == 404:
48
+ gr.Info("Timeout, try again.")
49
+
50
+ if status_code > 300:
51
+ return [], count
52
 
53
  res = r.json().get('img_array')
54
  out_array = []