Spaces:
Sleeping
Sleeping
apply omar's suggestions.
Browse files
app.py
CHANGED
@@ -21,18 +21,17 @@ One of the applications of this Space could be to evaluate different schedulers
|
|
21 |
|
22 |
Here's how it works:
|
23 |
|
24 |
-
* The users provides:
|
25 |
-
* An input prompt.
|
26 |
-
* Number of images to generate with the prompt.
|
27 |
-
* A checkpoint path compatible with `StableDiffusionPipeline`. You can either select one from the drop-down list or provide a valid path ("valhalla/sd-pokemon-model" for example).
|
28 |
-
* Names of the schedulers to evaluate.
|
29 |
* The evaluator first sets a seed and then generates the initial noise which is passed as the initial latent to start the image generation process. It is done to ensure fair comparison.
|
30 |
* This initial latent is used every time the pipeline is run (with different schedulers).
|
31 |
* To quantify the quality of the generated images we use:
|
32 |
* [Inception Score](https://en.wikipedia.org/wiki/Inception_score)
|
33 |
* [Clip Score](https://arxiv.org/abs/2104.08718)
|
34 |
|
35 |
-
**
|
|
|
|
|
|
|
|
|
36 |
"""
|
37 |
|
38 |
|
@@ -100,7 +99,7 @@ def initialize_pipeline(checkpoint: str):
|
|
100 |
return sd_pipe, original_scheduler_config
|
101 |
|
102 |
|
103 |
-
def get_scheduler(scheduler_name):
|
104 |
schedulers_lib = importlib.import_module("diffusers", package="schedulers")
|
105 |
scheduler_abs = getattr(schedulers_lib, scheduler_name)
|
106 |
|
@@ -162,7 +161,7 @@ def run(
|
|
162 |
}
|
163 |
}
|
164 |
)
|
165 |
-
print("First scheduler complete.")
|
166 |
|
167 |
for scheduler_name in schedulers_to_test:
|
168 |
if scheduler_name == original_scheduler_name:
|
@@ -184,13 +183,13 @@ def run(
|
|
184 |
}
|
185 |
}
|
186 |
)
|
187 |
-
print(f"{scheduler_name} complete.")
|
188 |
|
189 |
output_str = ""
|
190 |
for scheduler_name in all_images:
|
191 |
-
print(f"scheduler_name: {scheduler_name}")
|
192 |
output_str += prepare_report(scheduler_name, all_images[scheduler_name])
|
193 |
-
print(output_str)
|
194 |
return output_str
|
195 |
|
196 |
|
@@ -198,8 +197,8 @@ demo = gr.Interface(
|
|
198 |
run,
|
199 |
inputs=[
|
200 |
gr.Text(max_lines=1, placeholder="a painting of a dog"),
|
201 |
-
gr.Slider(3, 10, value=3),
|
202 |
-
gr.Slider(10, 100, value=50),
|
203 |
gr.Dropdown(
|
204 |
[
|
205 |
"CompVis/stable-diffusion-v1-4",
|
@@ -222,7 +221,7 @@ demo = gr.Interface(
|
|
222 |
multiselect=True,
|
223 |
),
|
224 |
],
|
225 |
-
outputs=[gr.Markdown().style()],
|
226 |
title=TITLE,
|
227 |
description=DESCRIPTION,
|
228 |
allow_flagging=False,
|
|
|
21 |
|
22 |
Here's how it works:
|
23 |
|
|
|
|
|
|
|
|
|
|
|
24 |
* The evaluator first sets a seed and then generates the initial noise which is passed as the initial latent to start the image generation process. It is done to ensure fair comparison.
|
25 |
* This initial latent is used every time the pipeline is run (with different schedulers).
|
26 |
* To quantify the quality of the generated images we use:
|
27 |
* [Inception Score](https://en.wikipedia.org/wiki/Inception_score)
|
28 |
* [Clip Score](https://arxiv.org/abs/2104.08718)
|
29 |
|
30 |
+
**Notes**:
|
31 |
+
|
32 |
+
* The default scheduler associated with the provided checkpoint is always used for reporting the scores.
|
33 |
+
* Increasing both the number of images per prompt and number of inference steps could quickly build up the inference queue and thus
|
34 |
+
resulting in slowdowns.
|
35 |
"""
|
36 |
|
37 |
|
|
|
99 |
return sd_pipe, original_scheduler_config
|
100 |
|
101 |
|
102 |
+
def get_scheduler(scheduler_name: str):
|
103 |
schedulers_lib = importlib.import_module("diffusers", package="schedulers")
|
104 |
scheduler_abs = getattr(schedulers_lib, scheduler_name)
|
105 |
|
|
|
161 |
}
|
162 |
}
|
163 |
)
|
164 |
+
# print("First scheduler complete.")
|
165 |
|
166 |
for scheduler_name in schedulers_to_test:
|
167 |
if scheduler_name == original_scheduler_name:
|
|
|
183 |
}
|
184 |
}
|
185 |
)
|
186 |
+
# print(f"{scheduler_name} complete.")
|
187 |
|
188 |
output_str = ""
|
189 |
for scheduler_name in all_images:
|
190 |
+
# print(f"scheduler_name: {scheduler_name}")
|
191 |
output_str += prepare_report(scheduler_name, all_images[scheduler_name])
|
192 |
+
# print(output_str)
|
193 |
return output_str
|
194 |
|
195 |
|
|
|
197 |
run,
|
198 |
inputs=[
|
199 |
gr.Text(max_lines=1, placeholder="a painting of a dog"),
|
200 |
+
gr.Slider(3, 10, value=3, step=1),
|
201 |
+
gr.Slider(10, 100, value=50, step=1),
|
202 |
gr.Dropdown(
|
203 |
[
|
204 |
"CompVis/stable-diffusion-v1-4",
|
|
|
221 |
multiselect=True,
|
222 |
),
|
223 |
],
|
224 |
+
outputs=[gr.Markdown().style(height="auto")],
|
225 |
title=TITLE,
|
226 |
description=DESCRIPTION,
|
227 |
allow_flagging=False,
|