Update app.py
Browse files
app.py
CHANGED
|
@@ -78,6 +78,7 @@ def base64_to_image(base64_str):
|
|
| 78 |
return buffer.read()
|
| 79 |
|
| 80 |
def search_image(base64_image, token_txt, request: gr.Request):
|
|
|
|
| 81 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as temp_file:
|
| 82 |
try:
|
| 83 |
temp_file.write(base64_to_image(base64_image))
|
|
@@ -92,14 +93,19 @@ def search_image(base64_image, token_txt, request: gr.Request):
|
|
| 92 |
gr.Info("β³ Wait for your next free search, or π Go Premium Search at https://faceseek.online!", duration=10)
|
| 93 |
return []
|
| 94 |
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
file=file1,
|
| 100 |
token=token_txt,
|
| 101 |
api_name="/search_face"
|
| 102 |
-
|
| 103 |
|
| 104 |
result = json.loads(result_text)
|
| 105 |
outarray = []
|
|
|
|
| 78 |
return buffer.read()
|
| 79 |
|
| 80 |
def search_image(base64_image, token_txt, request: gr.Request):
|
| 81 |
+
global backend
|
| 82 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as temp_file:
|
| 83 |
try:
|
| 84 |
temp_file.write(base64_to_image(base64_image))
|
|
|
|
| 93 |
gr.Info("β³ Wait for your next free search, or π Go Premium Search at https://faceseek.online!", duration=10)
|
| 94 |
return []
|
| 95 |
|
| 96 |
+
try:
|
| 97 |
+
result_text = backend.predict(
|
| 98 |
+
file=file1,
|
| 99 |
+
token=token_txt,
|
| 100 |
+
api_name="/search_face"
|
| 101 |
+
)
|
| 102 |
+
except:
|
| 103 |
+
backend = Client(BACKEND, auth=[USER, PASS])
|
| 104 |
+
result_text = backend.predict(
|
| 105 |
file=file1,
|
| 106 |
token=token_txt,
|
| 107 |
api_name="/search_face"
|
| 108 |
+
)
|
| 109 |
|
| 110 |
result = json.loads(result_text)
|
| 111 |
outarray = []
|