Zhu-FaceOnLive commited on
Commit
a294f5a
β€’
1 Parent(s): e24b42a

Update app.py

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