Spaces:
Runtime error
Runtime error
File size: 811 Bytes
209a278 e1fc40e 209a278 f5a2ba0 209a278 8147977 39ba7a3 eb62269 6a07040 39ba7a3 209a278 6a07040 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
import requests
from io import BytesIO
from flask import Flask, request, jsonify
from gradio_client import Client
from huggingface_hub import create_repo, upload_file
app = Flask(__name__)
@app.route('/faceswapper', methods=['POST'])
def faceswapper():
# Obter parâmetros da consulta da URL
endpoint = request.args.get('endpoint', default='https://pierroromeu-faceswapper.hf.space/--replicas/u42x7/')
user_photo = request.args.get('user_photo', default='')
result_photo = request.args.get('result_photo', default='')
# Chamar a API Gradio
client = Client(endpoint, upload_files=True)
result = client.predict(
user_photo,
result_photo,
api_name="/predict"
)
return jsonify(result)
if __name__ == "__main__":
app.run(host="0.0.0.0", port=7860) |