wenjiao commited on
Commit
3a285d8
1 Parent(s): eedcf9f
Files changed (1) hide show
  1. app.py +14 -11
app.py CHANGED
@@ -89,21 +89,22 @@ def txt2img_generate(prompt, steps=25, seed=42, guidance_scale=7.5):
89
  print("Compute node: ", json.loads(resp.text)["ip"])
90
  except:
91
  print('No inference result. Please check server connection')
92
- return [None, gr.update(visible=True), gr.update(visible=False)]
 
93
 
94
  img_byte = base64.b64decode(img_str)
95
  img_io = BytesIO(img_byte) # convert image to file-like object
96
  img = Image.open(img_io) # img is now PIL Image object
97
  print("elapsed time: ", time.time() - start_time)
98
 
99
- if queue_size.isdigit():
100
- if int(queue_size) > 4:
101
- return [img, gr.update(visible=False), gr.update(visible=True)]
102
- elif int(queue_size) <= 4:
103
- return [img, gr.update(visible=True), gr.update(visible=False)]
104
- else:
105
- return [img, gr.update(visible=True), gr.update(visible=False)]
106
-
107
 
108
  md = """
109
  This demo shows the accelerated inference performance of a Stable Diffusion model on **Intel Xeon Gold 64xx (4th Gen Intel Xeon Scalable Processors codenamed Sapphire Rapids)**. Try it and generate photorealistic images from text! Please note that the demo is in **preview** under limited HW resources. We are committed to continue improving the demo and happy to hear your feedbacks. Thanks for your trying!
@@ -167,9 +168,11 @@ with gr.Blocks(css=css) as demo:
167
  with gr.Column():
168
  result_image_2 = gr.Image()
169
 
170
- txt2img_button.click(fn=txt2img_generate, inputs=[prompt, inference_steps, seed, guidance_scale], outputs=[result_image, textBoxGreen, textBoxOrange])
 
171
 
172
- img2img_button.click(fn=img2img_generate, inputs=[source_img, prompt_2, inference_steps_2, strength, seed_2, guidance_scale_2], outputs=[result_image_2, textBoxGreen, textBoxOrange])
 
173
 
174
  gr.Markdown("**Additional Test Configuration Details:**", elem_id='mdStyle')
175
  gr.Markdown(details, elem_id='mdStyle')
 
89
  print("Compute node: ", json.loads(resp.text)["ip"])
90
  except:
91
  print('No inference result. Please check server connection')
92
+ return None
93
+ # return [None, gr.update(visible=True), gr.update(visible=False)]
94
 
95
  img_byte = base64.b64decode(img_str)
96
  img_io = BytesIO(img_byte) # convert image to file-like object
97
  img = Image.open(img_io) # img is now PIL Image object
98
  print("elapsed time: ", time.time() - start_time)
99
 
100
+ # if queue_size.isdigit():
101
+ # if int(queue_size) > 4:
102
+ # return [img, gr.update(visible=False), gr.update(visible=True)]
103
+ # elif int(queue_size) <= 4:
104
+ # return [img, gr.update(visible=True), gr.update(visible=False)]
105
+ # else:
106
+ # return [img, gr.update(visible=True), gr.update(visible=False)]
107
+ return img
108
 
109
  md = """
110
  This demo shows the accelerated inference performance of a Stable Diffusion model on **Intel Xeon Gold 64xx (4th Gen Intel Xeon Scalable Processors codenamed Sapphire Rapids)**. Try it and generate photorealistic images from text! Please note that the demo is in **preview** under limited HW resources. We are committed to continue improving the demo and happy to hear your feedbacks. Thanks for your trying!
 
168
  with gr.Column():
169
  result_image_2 = gr.Image()
170
 
171
+ txt2img_button.click(fn=txt2img_generate, inputs=[prompt, inference_steps, seed, guidance_scale], outputs=[result_image])
172
+ # txt2img_button.click(fn=txt2img_generate, inputs=[prompt, inference_steps, seed, guidance_scale], outputs=[result_image, textBoxGreen, textBoxOrange])
173
 
174
+ img2img_button.click(fn=img2img_generate, inputs=[source_img, prompt_2, inference_steps_2, strength, seed_2, guidance_scale_2], outputs=[result_image_2])
175
+ # img2img_button.click(fn=img2img_generate, inputs=[source_img, prompt_2, inference_steps_2, strength, seed_2, guidance_scale_2], outputs=[result_image_2, textBoxGreen, textBoxOrange])
176
 
177
  gr.Markdown("**Additional Test Configuration Details:**", elem_id='mdStyle')
178
  gr.Markdown(details, elem_id='mdStyle')