multimodalart HF Staff commited on
Commit
a1491f0
·
verified ·
1 Parent(s): cdac3fd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -19
app.py CHANGED
@@ -313,29 +313,18 @@ def unified_image_generator(prompt: str, images: Optional[List[str]], previous_v
313
  # Select model based on radio selection
314
  model_name = GEMINI_PRO_MODEL_NAME if use_pro_model else GEMINI_MODEL_NAME
315
 
316
- # Create config with aspect ratio (omit image_config if Auto is selected)
317
- # Note: PRO model uses image_size instead of aspect_ratio
318
- if use_pro_model:
319
- # Gemini 3 Pro uses image_size parameter
 
 
320
  generate_content_config = types.GenerateContentConfig(
321
  response_modalities=["IMAGE", "TEXT"],
322
  image_config=types.ImageConfig(
323
- image_size="1K", # Options: "1K", "2K", "4K"
324
  ),
325
  )
326
- else:
327
- # Gemini 2.5 Flash uses aspect_ratio parameter
328
- if aspect_ratio == "Auto":
329
- generate_content_config = types.GenerateContentConfig(
330
- response_modalities=["IMAGE", "TEXT"],
331
- )
332
- else:
333
- generate_content_config = types.GenerateContentConfig(
334
- response_modalities=["IMAGE", "TEXT"],
335
- image_config=types.ImageConfig(
336
- aspect_ratio=aspect_ratio,
337
- ),
338
- )
339
 
340
  response = client.models.generate_content(
341
  model=model_name,
@@ -416,9 +405,12 @@ with gr.Blocks(theme=gr.themes.Citrus(), css=css) as demo:
416
  image_input_gallery = gr.Gallery(label="Upload one or more images here. Leave empty for text-to-image", file_types=["image"], height="auto")
417
  prompt_input = gr.Textbox(label="Prompt", placeholder="Turns this photo into a masterpiece")
418
 
 
419
  model_radio = gr.Radio(
420
  choices=["Nano Banana", "Nano Banana PRO"],
421
- value="Nano Banana PRO",
 
 
422
  )
423
 
424
  aspect_ratio_dropdown = gr.Dropdown(
 
313
  # Select model based on radio selection
314
  model_name = GEMINI_PRO_MODEL_NAME if use_pro_model else GEMINI_MODEL_NAME
315
 
316
+ # Create config with aspect ratio
317
+ if aspect_ratio == "Auto":
318
+ generate_content_config = types.GenerateContentConfig(
319
+ response_modalities=["IMAGE", "TEXT"],
320
+ )
321
+ else:
322
  generate_content_config = types.GenerateContentConfig(
323
  response_modalities=["IMAGE", "TEXT"],
324
  image_config=types.ImageConfig(
325
+ aspect_ratio=aspect_ratio,
326
  ),
327
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
328
 
329
  response = client.models.generate_content(
330
  model=model_name,
 
405
  image_input_gallery = gr.Gallery(label="Upload one or more images here. Leave empty for text-to-image", file_types=["image"], height="auto")
406
  prompt_input = gr.Textbox(label="Prompt", placeholder="Turns this photo into a masterpiece")
407
 
408
+ # Model selection radio
409
  model_radio = gr.Radio(
410
  choices=["Nano Banana", "Nano Banana PRO"],
411
+ value="Nano Banana",
412
+ label="Model Selection",
413
+ info="PRO: Higher quality, slower generation (50/day) | Standard: Faster generation (75/day)"
414
  )
415
 
416
  aspect_ratio_dropdown = gr.Dropdown(