Spaces:
Runtime error
Runtime error
Update main.py
Browse files
main.py
CHANGED
|
@@ -6,10 +6,10 @@ from huggingface_hub import create_repo, upload_file
|
|
| 6 |
|
| 7 |
app = Flask(__name__)
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
response = requests.
|
| 13 |
if response.status_code == 200:
|
| 14 |
return response.json()["response"]["result"]
|
| 15 |
else:
|
|
@@ -92,17 +92,12 @@ def faceswapper():
|
|
| 92 |
endpoint = request.args.get('endpoint', default='https://pierroromeu-faceswapper.hf.space/--replicas/u42x7/')
|
| 93 |
user_photo = request.args.get('user_photo', default='')
|
| 94 |
result_photo = request.args.get('result_photo', default='')
|
| 95 |
-
|
| 96 |
-
#
|
| 97 |
-
|
| 98 |
-
result_path = client.predict(
|
| 99 |
-
user_photo,
|
| 100 |
-
result_photo,
|
| 101 |
-
api_name="/predict"
|
| 102 |
-
)
|
| 103 |
|
| 104 |
# Hospedar a imagem e obter a URL
|
| 105 |
-
hosted_url = host_image(
|
| 106 |
|
| 107 |
if hosted_url:
|
| 108 |
return jsonify({"result_url": hosted_url})
|
|
|
|
| 6 |
|
| 7 |
app = Flask(__name__)
|
| 8 |
|
| 9 |
+
# Função para chamar a API de hospedagem de imagens
|
| 10 |
+
def host_image(image_url):
|
| 11 |
+
api_url = "https://wosocial.bubbleapps.io/version-test/api/1.1/wf/save?file=" + image_url
|
| 12 |
+
response = requests.get(api_url)
|
| 13 |
if response.status_code == 200:
|
| 14 |
return response.json()["response"]["result"]
|
| 15 |
else:
|
|
|
|
| 92 |
endpoint = request.args.get('endpoint', default='https://pierroromeu-faceswapper.hf.space/--replicas/u42x7/')
|
| 93 |
user_photo = request.args.get('user_photo', default='')
|
| 94 |
result_photo = request.args.get('result_photo', default='')
|
| 95 |
+
|
| 96 |
+
# Formar a URL completa
|
| 97 |
+
full_url = endpoint + "/file=" + result_photo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
|
| 99 |
# Hospedar a imagem e obter a URL
|
| 100 |
+
hosted_url = host_image(full_url)
|
| 101 |
|
| 102 |
if hosted_url:
|
| 103 |
return jsonify({"result_url": hosted_url})
|