Spaces:
Runtime error
Runtime error
erwold
commited on
Commit
Β·
d800f84
1
Parent(s):
4236cfe
Initial Commit
Browse files
app.py
CHANGED
@@ -163,92 +163,122 @@ class FluxInterface:
|
|
163 |
interface = FluxInterface()
|
164 |
|
165 |
# Create Gradio interface
|
166 |
-
with gr.Blocks(
|
167 |
-
.
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
with gr.Column(elem_classes="container"):
|
175 |
-
gr.Markdown(
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
|
|
|
|
181 |
|
182 |
-
with gr.Row():
|
183 |
-
|
184 |
-
|
185 |
input_image = gr.Image(
|
186 |
-
label="Upload Image",
|
187 |
type="pil",
|
188 |
-
height=
|
189 |
-
|
190 |
-
prompt = gr.Textbox(
|
191 |
-
label="Optional Text Prompt",
|
192 |
-
placeholder="Enter text prompt here (optional)",
|
193 |
-
lines=2
|
194 |
)
|
195 |
|
196 |
-
with gr.
|
197 |
-
with gr.
|
198 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
guidance = gr.Slider(
|
200 |
minimum=1,
|
201 |
maximum=10,
|
202 |
value=3.5,
|
203 |
step=0.5,
|
204 |
-
label="Guidance Scale"
|
|
|
205 |
)
|
206 |
-
with gr.Column(scale=1):
|
207 |
steps = gr.Slider(
|
208 |
minimum=1,
|
209 |
maximum=50,
|
210 |
value=28,
|
211 |
step=1,
|
212 |
-
label="
|
|
|
213 |
)
|
214 |
-
|
215 |
-
with gr.
|
216 |
num_images = gr.Slider(
|
217 |
minimum=1,
|
218 |
maximum=4,
|
219 |
value=2,
|
220 |
step=1,
|
221 |
-
label="Number of Images"
|
|
|
222 |
)
|
223 |
-
with gr.Column(scale=1):
|
224 |
seed = gr.Number(
|
225 |
-
label="Random Seed
|
226 |
-
|
|
|
|
|
227 |
)
|
228 |
|
229 |
submit_btn = gr.Button(
|
230 |
-
"Generate Variations",
|
231 |
variant="primary",
|
232 |
-
|
233 |
)
|
234 |
|
235 |
-
|
236 |
-
|
237 |
output_gallery = gr.Gallery(
|
238 |
label="Generated Variations",
|
239 |
columns=2,
|
240 |
rows=2,
|
241 |
-
height=
|
|
|
|
|
|
|
|
|
242 |
)
|
243 |
|
244 |
-
gr.
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
|
|
|
|
252 |
# Set up the generation function
|
253 |
submit_btn.click(
|
254 |
fn=interface.generate,
|
@@ -260,8 +290,10 @@ with gr.Blocks(css="""
|
|
260 |
num_images,
|
261 |
seed
|
262 |
],
|
263 |
-
outputs=output_gallery
|
|
|
264 |
)
|
265 |
|
|
|
266 |
if __name__ == "__main__":
|
267 |
demo.launch()
|
|
|
163 |
interface = FluxInterface()
|
164 |
|
165 |
# Create Gradio interface
|
166 |
+
with gr.Blocks(
|
167 |
+
theme=gr.themes.Soft(),
|
168 |
+
css="""
|
169 |
+
.container {
|
170 |
+
max-width: 1200px;
|
171 |
+
margin: auto;
|
172 |
+
padding: 0 20px;
|
173 |
+
}
|
174 |
+
.header {
|
175 |
+
text-align: center;
|
176 |
+
margin: 20px 0 40px 0;
|
177 |
+
padding: 20px;
|
178 |
+
background: #f7f7f7;
|
179 |
+
border-radius: 12px;
|
180 |
+
}
|
181 |
+
.param-row {
|
182 |
+
padding: 10px 0;
|
183 |
+
}
|
184 |
+
footer {
|
185 |
+
margin-top: 40px;
|
186 |
+
padding: 20px;
|
187 |
+
border-top: 1px solid #eee;
|
188 |
+
}
|
189 |
+
"""
|
190 |
+
) as demo:
|
191 |
with gr.Column(elem_classes="container"):
|
192 |
+
gr.Markdown(
|
193 |
+
"""
|
194 |
+
<div class="header">
|
195 |
+
# π¨ Qwen2vl-Flux Image Variation Demo
|
196 |
+
Generate creative variations of your images with optional text guidance
|
197 |
+
</div>
|
198 |
+
"""
|
199 |
+
)
|
200 |
|
201 |
+
with gr.Row(equal_height=True):
|
202 |
+
with gr.Column(scale=1):
|
203 |
+
# Input Section
|
204 |
input_image = gr.Image(
|
205 |
+
label="Upload Your Image",
|
206 |
type="pil",
|
207 |
+
height=384,
|
208 |
+
sources=["upload", "clipboard"]
|
|
|
|
|
|
|
|
|
209 |
)
|
210 |
|
211 |
+
with gr.Accordion("Advanced Settings", open=False):
|
212 |
+
with gr.Group():
|
213 |
+
prompt = gr.Textbox(
|
214 |
+
label="Text Prompt (Optional)",
|
215 |
+
placeholder="Describe how you want to modify the image...",
|
216 |
+
lines=3
|
217 |
+
)
|
218 |
+
|
219 |
+
with gr.Row(elem_classes="param-row"):
|
220 |
guidance = gr.Slider(
|
221 |
minimum=1,
|
222 |
maximum=10,
|
223 |
value=3.5,
|
224 |
step=0.5,
|
225 |
+
label="Guidance Scale",
|
226 |
+
info="Higher values follow prompt more closely"
|
227 |
)
|
|
|
228 |
steps = gr.Slider(
|
229 |
minimum=1,
|
230 |
maximum=50,
|
231 |
value=28,
|
232 |
step=1,
|
233 |
+
label="Sampling Steps",
|
234 |
+
info="More steps = better quality but slower"
|
235 |
)
|
236 |
+
|
237 |
+
with gr.Row(elem_classes="param-row"):
|
238 |
num_images = gr.Slider(
|
239 |
minimum=1,
|
240 |
maximum=4,
|
241 |
value=2,
|
242 |
step=1,
|
243 |
+
label="Number of Images",
|
244 |
+
info="Generate multiple variations at once"
|
245 |
)
|
|
|
246 |
seed = gr.Number(
|
247 |
+
label="Random Seed",
|
248 |
+
value=None,
|
249 |
+
precision=0,
|
250 |
+
info="Set for reproducible results"
|
251 |
)
|
252 |
|
253 |
submit_btn = gr.Button(
|
254 |
+
"π¨ Generate Variations",
|
255 |
variant="primary",
|
256 |
+
size="lg"
|
257 |
)
|
258 |
|
259 |
+
with gr.Column(scale=1):
|
260 |
+
# Output Section
|
261 |
output_gallery = gr.Gallery(
|
262 |
label="Generated Variations",
|
263 |
columns=2,
|
264 |
rows=2,
|
265 |
+
height=700,
|
266 |
+
object_fit="contain",
|
267 |
+
show_label=True,
|
268 |
+
allow_preview=True,
|
269 |
+
preview=True
|
270 |
)
|
271 |
|
272 |
+
with gr.Row(elem_classes="footer"):
|
273 |
+
gr.Markdown("""
|
274 |
+
### Tips:
|
275 |
+
- πΈ Upload any image to get started
|
276 |
+
- π‘ Add an optional text prompt to guide the generation
|
277 |
+
- π― Adjust guidance scale to control prompt influence
|
278 |
+
- βοΈ Increase steps for higher quality
|
279 |
+
- π² Use seeds for reproducible results
|
280 |
+
""")
|
281 |
+
|
282 |
# Set up the generation function
|
283 |
submit_btn.click(
|
284 |
fn=interface.generate,
|
|
|
290 |
num_images,
|
291 |
seed
|
292 |
],
|
293 |
+
outputs=output_gallery,
|
294 |
+
show_progress="minimal"
|
295 |
)
|
296 |
|
297 |
+
# Launch the app
|
298 |
if __name__ == "__main__":
|
299 |
demo.launch()
|