Spaces:
Runtime error
Runtime error
Commit
·
2e506d2
1
Parent(s):
e5e751e
Update app.py
Browse files
app.py
CHANGED
@@ -9,10 +9,7 @@ num_images = num_rows * num_cols
|
|
9 |
image_size = 64
|
10 |
plot_image_size = 64
|
11 |
|
12 |
-
|
13 |
-
def load_model():
|
14 |
-
model = hf_hub.from_pretrained_keras("beresandras/denoising-diffusion-model")
|
15 |
-
return model
|
16 |
|
17 |
def diffusion_schedule(diffusion_times, min_signal_rate, max_signal_rate):
|
18 |
start_angle = tf.acos(max_signal_rate)
|
@@ -25,7 +22,7 @@ def diffusion_schedule(diffusion_times, min_signal_rate, max_signal_rate):
|
|
25 |
|
26 |
return noise_rates, signal_rates
|
27 |
|
28 |
-
def generate_images(
|
29 |
step_size = 1.0 / diffusion_steps
|
30 |
initial_noise = tf.random.normal(shape=(num_images, image_size, image_size, 3))
|
31 |
|
@@ -49,18 +46,12 @@ def generate_images(model, num_images, diffusion_steps, stochasticity, min_signa
|
|
49 |
)
|
50 |
|
51 |
generated_images = tf.clip_by_value(0.5 + 0.3 * pred_images, 0.0, 1.0)
|
52 |
-
generated_images = tf.image.resize(
|
53 |
-
generated_images, (plot_image_size, plot_image_size), method="nearest"
|
54 |
-
)
|
55 |
return generated_images.numpy()
|
56 |
|
57 |
-
|
58 |
-
model = load_model()
|
59 |
gr.Interface(
|
60 |
generate_images,
|
61 |
inputs=[
|
62 |
-
model,
|
63 |
-
num_images,
|
64 |
gr.inputs.Slider(1, 20, default=10, label="Diffusion steps"),
|
65 |
gr.inputs.Slider(0.0, 1.0, step=0.05, default=0.0, label="Stochasticity"),
|
66 |
gr.inputs.Slider(0.02, 0.10, step=0.01, default=0.02, label="Minimal signal rate"),
|
|
|
9 |
image_size = 64
|
10 |
plot_image_size = 64
|
11 |
|
12 |
+
model = hf_hub.from_pretrained_keras("beresandras/denoising-diffusion-model")
|
|
|
|
|
|
|
13 |
|
14 |
def diffusion_schedule(diffusion_times, min_signal_rate, max_signal_rate):
|
15 |
start_angle = tf.acos(max_signal_rate)
|
|
|
22 |
|
23 |
return noise_rates, signal_rates
|
24 |
|
25 |
+
def generate_images(diffusion_steps, stochasticity, min_signal_rate, max_signal_rate):
|
26 |
step_size = 1.0 / diffusion_steps
|
27 |
initial_noise = tf.random.normal(shape=(num_images, image_size, image_size, 3))
|
28 |
|
|
|
46 |
)
|
47 |
|
48 |
generated_images = tf.clip_by_value(0.5 + 0.3 * pred_images, 0.0, 1.0)
|
49 |
+
generated_images = tf.image.resize(generated_images, (plot_image_size, plot_image_size), method="nearest")
|
|
|
|
|
50 |
return generated_images.numpy()
|
51 |
|
|
|
|
|
52 |
gr.Interface(
|
53 |
generate_images,
|
54 |
inputs=[
|
|
|
|
|
55 |
gr.inputs.Slider(1, 20, default=10, label="Diffusion steps"),
|
56 |
gr.inputs.Slider(0.0, 1.0, step=0.05, default=0.0, label="Stochasticity"),
|
57 |
gr.inputs.Slider(0.02, 0.10, step=0.01, default=0.02, label="Minimal signal rate"),
|