flask2 / main.py
craftgamesnetwork's picture
Update main.py
a0005e6 verified
raw
history blame
811 Bytes
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)