EdBanshee commited on
Commit
434113d
Β·
1 Parent(s): bf1cd9b

Better crop info

Browse files
Files changed (2) hide show
  1. app.py +23 -3
  2. optimization.py +1 -0
app.py CHANGED
@@ -420,6 +420,7 @@ with gr.Blocks() as demo:
420
  input_image_component = gr.Image(type="pil", label="Input Image (auto-resized to target H/W)")
421
  resize_mode = gr.Radio(choices=["CROP SOURCE", "RESIZE SOURCE"], value="CROP SOURCE", label="Image Preparation Mode")
422
  cropping_preview_component = gr.Image(type="pil", label="Processing Preview", interactive=False)
 
423
  prompt_input = gr.Textbox(label="Prompt", value=default_prompt_i2v)
424
  duration_seconds_input = gr.Slider(minimum=MIN_DURATION, maximum=MAX_DURATION, step=0.1, value=3.5, label="Duration (seconds)", info="Clamped to model's {}-{} frames at {}fps.".format(MIN_FRAMES_MODEL, MAX_FRAMES_MODEL, FIXED_FPS))
425
 
@@ -445,20 +446,39 @@ with gr.Blocks() as demo:
445
  # Preview update function
446
  def update_preview(image, mode):
447
  use_crop = mode == "CROP SOURCE"
448
- return make_cropping_preview(image, use_crop)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
449
 
450
  # Preview updates when input image or resize mode changes
451
  input_image_component.change(
452
  fn=update_preview,
453
  inputs=[input_image_component, resize_mode],
454
- outputs=[cropping_preview_component],
455
  show_progress=False,
456
  )
457
 
458
  resize_mode.change(
459
  fn=update_preview,
460
  inputs=[input_image_component, resize_mode],
461
- outputs=[cropping_preview_component],
462
  show_progress=False,
463
  )
464
 
 
420
  input_image_component = gr.Image(type="pil", label="Input Image (auto-resized to target H/W)")
421
  resize_mode = gr.Radio(choices=["CROP SOURCE", "RESIZE SOURCE"], value="CROP SOURCE", label="Image Preparation Mode")
422
  cropping_preview_component = gr.Image(type="pil", label="Processing Preview", interactive=False)
423
+ dimension_info_component = gr.Textbox(label="Image Dimensions", value="No image loaded", interactive=False, max_lines=2)
424
  prompt_input = gr.Textbox(label="Prompt", value=default_prompt_i2v)
425
  duration_seconds_input = gr.Slider(minimum=MIN_DURATION, maximum=MAX_DURATION, step=0.1, value=3.5, label="Duration (seconds)", info="Clamped to model's {}-{} frames at {}fps.".format(MIN_FRAMES_MODEL, MAX_FRAMES_MODEL, FIXED_FPS))
426
 
 
446
  # Preview update function
447
  def update_preview(image, mode):
448
  use_crop = mode == "CROP SOURCE"
449
+ preview = make_cropping_preview(image, use_crop)
450
+ dimension_info = get_dimension_info(image, mode)
451
+ return preview, dimension_info
452
+
453
+ def get_dimension_info(image, mode):
454
+ if image is None:
455
+ return "No image loaded"
456
+
457
+ width, height = image.size
458
+ target_w, target_h = calculate_optimal_dimensions(width, height)
459
+ pixel_count_original = width * height
460
+ pixel_count_final = target_w * target_h
461
+
462
+ mode_text = "CROP" if mode == "CROP SOURCE" else "RESIZE+PAD"
463
+
464
+ info = "Original: {}Γ—{} ({:,} pixels)\nFinal ({}): {}Γ—{} ({:,} pixels)".format(
465
+ width, height, pixel_count_original,
466
+ mode_text, target_w, target_h, pixel_count_final
467
+ )
468
+ return info
469
 
470
  # Preview updates when input image or resize mode changes
471
  input_image_component.change(
472
  fn=update_preview,
473
  inputs=[input_image_component, resize_mode],
474
+ outputs=[cropping_preview_component, dimension_info_component],
475
  show_progress=False,
476
  )
477
 
478
  resize_mode.change(
479
  fn=update_preview,
480
  inputs=[input_image_component, resize_mode],
481
+ outputs=[cropping_preview_component, dimension_info_component],
482
  show_progress=False,
483
  )
484
 
optimization.py CHANGED
@@ -47,6 +47,7 @@ import torch._inductor.config as inductor_config
47
  # Temporarily reduce optimization aggressiveness for startup
48
  original_max_autotune = inductor_config.max_autotune
49
  inductor_config.max_autotune = False
 
50
 
51
  def optimize_pipeline_(pipeline: Callable[P, Any], *args: P.args, **kwargs: P.kwargs):
52
 
 
47
  # Temporarily reduce optimization aggressiveness for startup
48
  original_max_autotune = inductor_config.max_autotune
49
  inductor_config.max_autotune = False
50
+ inductor_config.max_autotune_gemm = False
51
 
52
  def optimize_pipeline_(pipeline: Callable[P, Any], *args: P.args, **kwargs: P.kwargs):
53