abidlabs HF Staff commited on
Commit
6275c42
·
verified ·
1 Parent(s): 558263a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -1
app.py CHANGED
@@ -1,3 +1,23 @@
1
  import gradio as gr
 
2
 
3
- gr.load("hysts/SDXL", src="spaces").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from gradio_client import Client
3
 
4
+ def text_to_image(client, prompt):
5
+ img = client.predict(prompt, "", "", "", api_name="/run")
6
+ return img
7
+
8
+
9
+ def set_client_for_session(request: gr.Request):
10
+ x_ip_token = request.headers['x-ip-token']
11
+
12
+ # The "gradio/text-to-image" space is a ZeroGPU space
13
+ return Client("hysts/SDXL", headers={"X-IP-Token": x_ip_token})
14
+
15
+ with gr.Blocks() as demo:
16
+ client = gr.State()
17
+ image = gr.Image()
18
+ prompt = gr.Textbox(max_lines=1)
19
+
20
+ prompt.submit(text_to_image, [client, prompt], [image])
21
+
22
+ demo.load(set_client_for_session, None, client)
23
+ demo.launch()