File size: 807 Bytes
8f41352
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
28
29
30
31
32
33
34
35
from flask import Flask, request, jsonify
from gradio_client import Client

app = Flask(__name__)

@app.route('/', methods=['GET'])
def get_prediction():

    # Extract data for prediction
    prompt = request.args.get("prompt")
    negative_prompt = request.args.get("negative_prompt")
    width = int(request.args.get("width"))
    height = int(request.args.get("height"))

    # Make prediction using Gradio Client
    client = Client("https://ddosxd-realvisxl.hf.space/--replicas/flm7z/")
    result = client.predict(
        prompt,
        negative_prompt,
        True,
        0,
        width,
        height,
        7,
        True,
        api_name="/run"
    )

    # Return the result as JSON response
    return jsonify(result)

if __name__ == '__main__':
    app.run(debug=True, port=8080)