erwold commited on
Commit
d800f84
Β·
1 Parent(s): 4236cfe

Initial Commit

Browse files
Files changed (1) hide show
  1. app.py +82 -50
app.py CHANGED
@@ -163,92 +163,122 @@ class FluxInterface:
163
  interface = FluxInterface()
164
 
165
  # Create Gradio interface
166
- with gr.Blocks(css="""
167
- .container { max-width: 1200px; margin: auto; padding: 20px; }
168
- .header { text-align: center; margin-bottom: 40px; }
169
- .input-panel { border: 1px solid #e0e0e0; padding: 20px; border-radius: 8px; background: white; }
170
- .control-panel { padding: 10px; margin: 10px 0; }
171
- .output-panel { border: 1px solid #e0e0e0; padding: 20px; border-radius: 8px; }
172
- .submit-btn { height: 40px; margin: 10px 0; }
173
- """) as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
  with gr.Column(elem_classes="container"):
175
- gr.Markdown("""
176
- <div class="header">
177
- # 🎨 Qwen2vl-Flux Image Variation Demo
178
- Upload an image and get AI-generated variations. You can optionally add a text prompt to guide the generation.
179
- </div>
180
- """)
 
 
181
 
182
- with gr.Row():
183
- # Input Column
184
- with gr.Column(scale=1, min_width=400, elem_classes="input-panel"):
185
  input_image = gr.Image(
186
- label="Upload Image",
187
  type="pil",
188
- height=400
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.Column(elem_classes="control-panel"):
197
- with gr.Row():
198
- with gr.Column(scale=1):
 
 
 
 
 
 
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="Number of Steps"
 
213
  )
214
- with gr.Row():
215
- with gr.Column(scale=1):
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 (optional)",
226
- precision=0
 
 
227
  )
228
 
229
  submit_btn = gr.Button(
230
- "Generate Variations",
231
  variant="primary",
232
- elem_classes="submit-btn"
233
  )
234
 
235
- # Output Column
236
- with gr.Column(scale=1, min_width=400, elem_classes="output-panel"):
237
  output_gallery = gr.Gallery(
238
  label="Generated Variations",
239
  columns=2,
240
  rows=2,
241
- height=600,
 
 
 
 
242
  )
243
 
244
- gr.Markdown("""
245
- ### Tips:
246
- - Higher guidance scale values (1-10) result in outputs that more closely follow the prompt
247
- - More steps generally produce better quality but take longer
248
- - You can generate up to 4 variations at once
249
- - Set a seed for reproducible results
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()