AlGe commited on
Commit
8dc3fdd
·
verified ·
1 Parent(s): 6ea49db

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -12
app.py CHANGED
@@ -1,13 +1,28 @@
 
1
  from gradio_client import Client
2
  import gradio as gr
3
 
4
- # Create a client for the other space
 
5
  client = Client("radames/Enhance-This-HiDiffusion-SDXL")
6
 
7
- # Define your interface function
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
- def my_interface(input_image, prompt="This is a beautiful scenery", negative_prompt="blurry, ugly, duplicate, poorly drawn, deformed, mosaic", seed=1415926535897932, guidance_scale=8.5, scale=2, controlnet_conditioning_scale=0.5, strength=1.0, controlnet_start=0.0, controlnet_end=1.0, guassian_sigma=2.0, intensity_threshold=3):
10
- # Call the other space's predict function
11
  result = client.predict(
12
  input_image=input_image,
13
  prompt=prompt,
@@ -23,13 +38,8 @@ def my_interface(input_image, prompt="This is a beautiful scenery", negative_pro
23
  intensity_threshold=intensity_threshold,
24
  api_name="/predict"
25
  )
26
- # Return only the first image from the result
27
- return result[0][0]
28
 
29
- # Define your Gradio interface
30
- iface = gr.Interface(fn=my_interface,
31
- inputs=gr.Image(),
32
- outputs=gr.Image())
33
 
34
- # Launch your Gradio interface
35
- iface.launch()
 
1
+ from flask import Flask, request, jsonify
2
  from gradio_client import Client
3
  import gradio as gr
4
 
5
+ app = Flask(__name__)
6
+
7
  client = Client("radames/Enhance-This-HiDiffusion-SDXL")
8
 
9
+ @app.route('/predict', methods=['POST'])
10
+ def my_interface():
11
+ data = request.get_json()
12
+
13
+ input_image = data['input_image']
14
+ prompt = data.get('prompt', "This is a beautiful scenery")
15
+ negative_prompt = data.get('negative_prompt', "blurry, ugly, duplicate, poorly drawn, deformed, mosaic")
16
+ seed = data.get('seed', 1415926535897932)
17
+ guidance_scale = data.get('guidance_scale', 8.5)
18
+ scale = data.get('scale', 2)
19
+ controlnet_conditioning_scale = data.get('controlnet_conditioning_scale', 0.5)
20
+ strength = data.get('strength', 1.0)
21
+ controlnet_start = data.get('controlnet_start', 0.0)
22
+ controlnet_end = data.get('controlnet_end', 1.0)
23
+ guassian_sigma = data.get('guassian_sigma', 2.0)
24
+ intensity_threshold = data.get('intensity_threshold', 3)
25
 
 
 
26
  result = client.predict(
27
  input_image=input_image,
28
  prompt=prompt,
 
38
  intensity_threshold=intensity_threshold,
39
  api_name="/predict"
40
  )
 
 
41
 
42
+ return jsonify(result[0][0])
 
 
 
43
 
44
+ if __name__ == '__main__':
45
+ app.run(debug=True)