Skip to content

UI Improvement for DragDiffusion: Correct Display for Non-Square Images #80

@Rubenacp

Description

@Rubenacp

Hi everyone,
If you've tried using DragDiffusion with a rectangular (non-square) image, you've probably noticed that the image gets cropped in the "Draw Mask" panel. This makes it difficult to draw an accurate mask.
Here's a simple fix for that.
The Problem:
The UI forces all images into a square container (480x480px), which crops any image that doesn't match this aspect ratio.
The Cause:
In the drag_ui.py file, the Gradio gr.Image components have a hardcoded height and width (height=LENGTH, width=LENGTH).
The Solution (100% Safe):
The fix is to simply remove these fixed-size parameters, allowing the UI to automatically adapt to the shape of your uploaded image.
This is a visual-only change. It does not affect the backend processing, LoRA training, or the final result in any way. The program always uses the full, original image behind the scenes.
How to Apply the Fix:
Open the drag_ui.py file.
Find the lines where the gr.Image components are defined (e.g., canvas, input_image, output_image).
Remove the height=LENGTH and width=LENGTH parameters from these definitions.
Example - Before:

canvas = gr.Image(type="numpy", tool="sketch", label="Draw Mask", show_label=True, height=LENGTH, width=LENGTH) # for mask painting

Example - After:

canvas = gr.Image(type="numpy", tool="sketch", label="Draw Mask", show_label=True) # for mask painting

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions