erwold commited on
Commit
af7a5be
·
1 Parent(s): 49d4954

Initial Commit

Browse files
Files changed (1) hide show
  1. app.py +84 -21
app.py CHANGED
@@ -197,41 +197,104 @@ class FluxInterface:
197
  interface = FluxInterface()
198
 
199
  # Create Gradio interface
200
- with gr.Blocks(title="Qwen2vl-Flux Demo") as demo:
201
  gr.Markdown("""
202
  # 🎨 Qwen2vl-Flux Image Variation Demo
203
  Upload an image and get AI-generated variations. You can optionally add a text prompt to guide the generation.
204
  """)
205
 
206
  with gr.Row():
207
- with gr.Column():
208
- input_image = gr.Image(label="Upload Image", type="pil")
209
- prompt = gr.Textbox(label="Optional Text Prompt(should be as long as possible)", placeholder="Enter text prompt here (optional)")
 
 
 
 
 
 
 
 
 
 
210
 
211
- with gr.Row():
212
- guidance = gr.Slider(minimum=1, maximum=10, value=3.5, label="Guidance Scale")
213
- steps = gr.Slider(minimum=1, maximum=50, value=28, label="Number of Steps")
214
- num_images = gr.Slider(minimum=1, maximum=4, value=2, step=1, label="Number of Images")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
 
216
- seed = gr.Number(label="Random Seed (optional)", precision=0)
217
- submit_btn = gr.Button("Generate Variations", variant="primary")
 
 
 
218
 
219
- with gr.Column():
220
- output_gallery = gr.Gallery(label="Generated Variations", columns=2, show_label=True)
 
 
 
 
 
 
 
221
 
 
 
 
 
 
 
 
 
 
222
  # Set up the generation function
223
  submit_btn.click(
224
  fn=interface.generate,
225
- inputs=[input_image, prompt, guidance, steps, num_images, seed],
226
- outputs=output_gallery,
 
 
 
 
 
 
 
227
  )
228
-
229
- gr.Markdown("""
230
- ### Notes:
231
- - Higher guidance scale values result in outputs that more closely follow the prompt
232
- - More steps generally produce better quality but take longer
233
- - Set a seed for reproducible results
234
- """)
235
 
236
  # Launch the app
237
  if __name__ == "__main__":
 
197
  interface = FluxInterface()
198
 
199
  # Create Gradio interface
200
+ with gr.Blocks(theme=gr.themes.Soft()) as demo:
201
  gr.Markdown("""
202
  # 🎨 Qwen2vl-Flux Image Variation Demo
203
  Upload an image and get AI-generated variations. You can optionally add a text prompt to guide the generation.
204
  """)
205
 
206
  with gr.Row():
207
+ with gr.Column(scale=1):
208
+ input_image = gr.Image(
209
+ label="Upload Image",
210
+ type="pil",
211
+ height=384,
212
+ width=384,
213
+ tool="select"
214
+ )
215
+ prompt = gr.Textbox(
216
+ label="Optional Text Prompt",
217
+ placeholder="Enter text prompt here (optional)",
218
+ lines=2
219
+ )
220
 
221
+ with gr.Group():
222
+ with gr.Row(equal_height=True):
223
+ with gr.Column(scale=1):
224
+ guidance = gr.Slider(
225
+ minimum=1,
226
+ maximum=10,
227
+ value=3.5,
228
+ step=0.5,
229
+ label="Guidance Scale",
230
+ info="Higher values follow prompt more closely"
231
+ )
232
+ with gr.Column(scale=1):
233
+ steps = gr.Slider(
234
+ minimum=1,
235
+ maximum=50,
236
+ value=28,
237
+ step=1,
238
+ label="Steps",
239
+ info="More steps = better quality but slower"
240
+ )
241
+
242
+ with gr.Row(equal_height=True):
243
+ with gr.Column(scale=1):
244
+ num_images = gr.Slider(
245
+ minimum=1,
246
+ maximum=4,
247
+ value=2,
248
+ step=1,
249
+ label="Number of Images",
250
+ info="Generate multiple variations"
251
+ )
252
+ with gr.Column(scale=1):
253
+ seed = gr.Number(
254
+ label="Random Seed",
255
+ value=None,
256
+ precision=0,
257
+ info="Optional, for reproducibility"
258
+ )
259
 
260
+ submit_btn = gr.Button(
261
+ "Generate Variations",
262
+ variant="primary",
263
+ scale=1
264
+ )
265
 
266
+ with gr.Column(scale=1):
267
+ output_gallery = gr.Gallery(
268
+ label="Generated Variations",
269
+ columns=2,
270
+ rows=2,
271
+ height=768,
272
+ object_fit="contain",
273
+ show_label=True
274
+ )
275
 
276
+ gr.Markdown("""
277
+ ### Tips:
278
+ - Upload any image to get started
279
+ - Add a text prompt to guide the generation in a specific direction
280
+ - Adjust guidance scale to control how closely the output follows the prompt
281
+ - Increase steps for higher quality (but slower) generation
282
+ - Use the same seed to reproduce results
283
+ """)
284
+
285
  # Set up the generation function
286
  submit_btn.click(
287
  fn=interface.generate,
288
+ inputs=[
289
+ input_image,
290
+ prompt,
291
+ guidance,
292
+ steps,
293
+ num_images,
294
+ seed
295
+ ],
296
+ outputs=output_gallery
297
  )
 
 
 
 
 
 
 
298
 
299
  # Launch the app
300
  if __name__ == "__main__":