freddyaboulton HF Staff commited on
Commit
a1b49d8
·
verified ·
1 Parent(s): ec58c27

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -3
app.py CHANGED
@@ -6,16 +6,15 @@ def set_client_for_session(request: gr.Request):
6
  x_zero_gpu_id = request.headers["x-zerogpu-uuid"]
7
  return Client("hysts/SDXL", headers={"x-zerogpu-token": x_gpu_token, "x-zero-gpu-uuid": x_zero_gpu_id})
8
 
9
- def text_to_image(prompt, client):
 
10
  img = client.predict(prompt, "", "", "", api_name="/run")
11
  return img
12
 
13
  with gr.Blocks() as demo:
14
- client = gr.State()
15
  image = gr.Image()
16
  prompt = gr.Textbox(max_lines=1)
17
  prompt.submit(text_to_image, [prompt, client], [image])
18
- demo.load(set_client_for_session, inputs=None, outputs=client)
19
 
20
  demo.launch()
21
 
 
6
  x_zero_gpu_id = request.headers["x-zerogpu-uuid"]
7
  return Client("hysts/SDXL", headers={"x-zerogpu-token": x_gpu_token, "x-zero-gpu-uuid": x_zero_gpu_id})
8
 
9
+ def text_to_image(prompt, request: gr.Request):
10
+ client = set_client_for_session(request)
11
  img = client.predict(prompt, "", "", "", api_name="/run")
12
  return img
13
 
14
  with gr.Blocks() as demo:
 
15
  image = gr.Image()
16
  prompt = gr.Textbox(max_lines=1)
17
  prompt.submit(text_to_image, [prompt, client], [image])
 
18
 
19
  demo.launch()
20