Spaces:
Runtime error
Runtime error
Commit
·
e3b915c
1
Parent(s):
404e08e
Update app.py
Browse files
app.py
CHANGED
@@ -23,7 +23,7 @@ def diffusion_schedule(diffusion_times, min_signal_rate, max_signal_rate):
|
|
23 |
|
24 |
def generate_images(diffusion_steps, stochasticity, min_signal_rate, max_signal_rate):
|
25 |
step_size = 1.0 / diffusion_steps
|
26 |
-
initial_noise = tf.random.normal(shape=(num_images, image_size, image_size, 3))
|
27 |
|
28 |
# reverse diffusion
|
29 |
noisy_images = initial_noise
|
@@ -57,13 +57,21 @@ def generate_images(diffusion_steps, stochasticity, min_signal_rate, max_signal_
|
|
57 |
generated_images = tf.reshape(generated_images, (num_rows * plot_image_size, num_cols * plot_image_size, 3))
|
58 |
return generated_images.numpy()
|
59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
gr.Interface(
|
61 |
generate_images,
|
62 |
-
inputs=
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
],
|
68 |
-
outputs="image",
|
69 |
).launch()
|
|
|
23 |
|
24 |
def generate_images(diffusion_steps, stochasticity, min_signal_rate, max_signal_rate):
|
25 |
step_size = 1.0 / diffusion_steps
|
26 |
+
initial_noise = tf.random.normal(shape=(num_images, image_size, image_size, 3), seed=42)
|
27 |
|
28 |
# reverse diffusion
|
29 |
noisy_images = initial_noise
|
|
|
57 |
generated_images = tf.reshape(generated_images, (num_rows * plot_image_size, num_cols * plot_image_size, 3))
|
58 |
return generated_images.numpy()
|
59 |
|
60 |
+
inputs = [
|
61 |
+
gr.inputs.Slider(1, 20, step=1, default=10, label="Diffusion steps"),
|
62 |
+
gr.inputs.Slider(0.0, 1.0, step=0.05, default=0.0, label="Stochasticity (η in the paper)"),
|
63 |
+
gr.inputs.Slider(0.02, 0.10, step=0.01, default=0.02, label="Minimal signal rate"),
|
64 |
+
gr.inputs.Slider(0.80, 0.95, step=0.01, default=0.95, label="Maximal signal rate"),
|
65 |
+
]
|
66 |
+
output = gr.outputs.Image(label="Generated images")
|
67 |
+
examples = [[2, 0.0, 0.02, 0.95], [10, 0.0, 0.02, 0.95], [20, 1.0, 0.02, 0.95]]
|
68 |
+
title = "Denoising Diffusion Implicit Models"
|
69 |
+
article = "<div style='text-align: center;'>Keras code example and demo by <a href='https://www.linkedin.com/in/andras-beres-789190210' target='_blank'>András Béres</a></div>"
|
70 |
gr.Interface(
|
71 |
generate_images,
|
72 |
+
inputs=inputs,
|
73 |
+
outputs=output,
|
74 |
+
examples=examples,
|
75 |
+
title=title,
|
76 |
+
article=article,
|
|
|
|
|
77 |
).launch()
|