Spaces:
Running
on
Zero
Running
on
Zero
WeichenFan
commited on
Commit
·
babee83
1
Parent(s):
13a0076
Add application file
Browse files
app.py
CHANGED
@@ -148,28 +148,39 @@ def generate_content(prompt, model_name, guidance_scale=7.5, num_inference_steps
|
|
148 |
return None, image, None, None, seed
|
149 |
|
150 |
# Gradio UI
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
|
174 |
demo.launch(ssr_mode=False)
|
175 |
|
|
|
148 |
return None, image, None, None, seed
|
149 |
|
150 |
# Gradio UI
|
151 |
+
with gr.Blocks() as demo:
|
152 |
+
gr.HTML("""
|
153 |
+
<div style="text-align: center; font-size: 32px; font-weight: bold; margin-bottom: 20px;">
|
154 |
+
CFG-Zero*: Improved Classifier-Free Guidance for Flow Matching Models
|
155 |
+
</div>
|
156 |
+
<div style="text-align: center;">
|
157 |
+
<a href="https://github.com/WeichenFan/CFG-Zero-star">Code</a> |
|
158 |
+
<a href="https://huggingface.co/spaces/weepiess2383/CFG-Zero-Star">Huggingface</a> |
|
159 |
+
<a href="https://arxiv.org/abs/2503.18886">Paper</a>
|
160 |
+
</div>
|
161 |
+
""")
|
162 |
+
|
163 |
+
gr.Interface(
|
164 |
+
fn=generate_content,
|
165 |
+
inputs=[
|
166 |
+
gr.Textbox(value="A spooky haunted mansion on a hill silhouetted by a full moon.", label="Enter your prompt"),
|
167 |
+
gr.Dropdown(choices=list(model_paths.keys()), label="Choose Model"),
|
168 |
+
gr.Slider(1, 20, value=4.0, step=0.5, label="Guidance Scale"),
|
169 |
+
gr.Slider(10, 100, value=28, step=5, label="Inference Steps"),
|
170 |
+
gr.Checkbox(value=True, label="Use CFG Zero Star"),
|
171 |
+
gr.Checkbox(value=True, label="Use Zero Init"),
|
172 |
+
gr.Slider(0, 20, value=0, step=1, label="Zero out steps"),
|
173 |
+
gr.Number(value=42, label="Seed (Leave blank for random)"),
|
174 |
+
gr.Checkbox(value=True, label="Compare Mode")
|
175 |
+
],
|
176 |
+
outputs=[
|
177 |
+
gr.Image(type="pil", label="CFG-Zero* Image"),
|
178 |
+
gr.Image(type="pil", label="CFG Image"),
|
179 |
+
gr.Textbox(label="Used Seed")
|
180 |
+
],
|
181 |
+
title="CFG-Zero*: Improved Classifier-Free Guidance for Flow Matching Models",
|
182 |
+
live=False # optional
|
183 |
+
).render()
|
184 |
|
185 |
demo.launch(ssr_mode=False)
|
186 |
|