lelafav502 commited on
Commit
8f41352
1 Parent(s): e73e1f9

Upload main (2).py

Browse files
Files changed (1) hide show
  1. main (2).py +34 -0
main (2).py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, request, jsonify
2
+ from gradio_client import Client
3
+
4
+ app = Flask(__name__)
5
+
6
+ @app.route('/', methods=['GET'])
7
+ def get_prediction():
8
+
9
+ # Extract data for prediction
10
+ prompt = request.args.get("prompt")
11
+ negative_prompt = request.args.get("negative_prompt")
12
+ width = int(request.args.get("width"))
13
+ height = int(request.args.get("height"))
14
+
15
+ # Make prediction using Gradio Client
16
+ client = Client("https://ddosxd-realvisxl.hf.space/--replicas/flm7z/")
17
+ result = client.predict(
18
+ prompt,
19
+ negative_prompt,
20
+ True,
21
+ 0,
22
+ width,
23
+ height,
24
+ 7,
25
+ True,
26
+ api_name="/run"
27
+ )
28
+
29
+ # Return the result as JSON response
30
+ return jsonify(result)
31
+
32
+ if __name__ == '__main__':
33
+ app.run(debug=True, port=8080)
34
+