Update app.py
Browse files
app.py
CHANGED
@@ -69,9 +69,9 @@ def on_change_event(app_state):
|
|
69 |
step = app_state['step']
|
70 |
label = f'Reconstructed image from the latent state at step {step}. It will get better :)'
|
71 |
print(f'Updating the image:! {app_state}')
|
72 |
-
return gr.update(value=
|
73 |
else:
|
74 |
-
return gr.update(label='
|
75 |
|
76 |
with gr.Blocks() as demo:
|
77 |
|
@@ -91,7 +91,7 @@ with gr.Blocks() as demo:
|
|
91 |
print (f'In Callback on {app_state} Done!')
|
92 |
|
93 |
prompt = prompt + ' masterpiece charcoal pencil art lord of the rings illustration'
|
94 |
-
img = pipe(prompt, height=512, width=512, num_inference_steps=inference_steps, callback=callback, callback_steps=
|
95 |
app_state['running'] = False
|
96 |
app_state['img'] = None
|
97 |
return gr.update(value=img.images[0], label='Generated image')
|
@@ -113,10 +113,11 @@ with gr.Blocks() as demo:
|
|
113 |
bt_make_image = gr.Button(f"Generate an image (takes about 10-15 minutes on CPU).", visible=False)
|
114 |
|
115 |
img_description = gr.Markdown('Image generation takes some time'
|
116 |
-
' but here you can see
|
117 |
-
' Usually there is a significant improvement around step 12 that yields much better
|
118 |
-
image = gr.Image(label='Illustration for your story', show_label=True)
|
119 |
gallery = gr.Gallery()
|
|
|
|
|
120 |
gallery.style(grid=[4])
|
121 |
|
122 |
inference_steps = gr.Slider(5, 30,
|
@@ -130,12 +131,11 @@ with gr.Blocks() as demo:
|
|
130 |
bt_make_image.click(fn=generate_image, inputs=[summary, inference_steps, app_state], outputs=image)
|
131 |
|
132 |
eventslider = gr.Slider(visible=False)
|
133 |
-
dep = demo.load(on_change_event, app_state, [
|
134 |
-
eventslider.change(fn=on_change_event, inputs=[app_state], outputs=[
|
135 |
|
136 |
|
137 |
if READ_TOKEN:
|
138 |
demo.queue().launch()
|
139 |
else:
|
140 |
demo.queue().launch(share=True, debug=True)
|
141 |
-
|
|
|
69 |
step = app_state['step']
|
70 |
label = f'Reconstructed image from the latent state at step {step}. It will get better :)'
|
71 |
print(f'Updating the image:! {app_state}')
|
72 |
+
return gr.update(value=app_state['img_list'], label='intermediate steps')
|
73 |
else:
|
74 |
+
return gr.update(label='images list')
|
75 |
|
76 |
with gr.Blocks() as demo:
|
77 |
|
|
|
91 |
print (f'In Callback on {app_state} Done!')
|
92 |
|
93 |
prompt = prompt + ' masterpiece charcoal pencil art lord of the rings illustration'
|
94 |
+
img = pipe(prompt, height=512, width=512, num_inference_steps=inference_steps, callback=callback, callback_steps=2)
|
95 |
app_state['running'] = False
|
96 |
app_state['img'] = None
|
97 |
return gr.update(value=img.images[0], label='Generated image')
|
|
|
113 |
bt_make_image = gr.Button(f"Generate an image (takes about 10-15 minutes on CPU).", visible=False)
|
114 |
|
115 |
img_description = gr.Markdown('Image generation takes some time'
|
116 |
+
' but here you can see what is generated from the latent state of the diffuser every few steps.'
|
117 |
+
' Usually there is a significant improvement around step 12 that yields a much better image')
|
|
|
118 |
gallery = gr.Gallery()
|
119 |
+
image = gr.Image(label='Illustration for your story', show_label=True)
|
120 |
+
|
121 |
gallery.style(grid=[4])
|
122 |
|
123 |
inference_steps = gr.Slider(5, 30,
|
|
|
131 |
bt_make_image.click(fn=generate_image, inputs=[summary, inference_steps, app_state], outputs=image)
|
132 |
|
133 |
eventslider = gr.Slider(visible=False)
|
134 |
+
dep = demo.load(on_change_event, app_state, [gallery], every=10)
|
135 |
+
eventslider.change(fn=on_change_event, inputs=[app_state], outputs=[gallery], every=10, cancels=[dep])
|
136 |
|
137 |
|
138 |
if READ_TOKEN:
|
139 |
demo.queue().launch()
|
140 |
else:
|
141 |
demo.queue().launch(share=True, debug=True)
|
|