Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -118,29 +118,6 @@ pipe.transformer.set_attn_processor(QwenDoubleStreamAttnProcessorFA3())
|
|
| 118 |
|
| 119 |
MAX_SEED = np.iinfo(np.int32).max
|
| 120 |
|
| 121 |
-
# --- Helper Functions ---
|
| 122 |
-
def update_dimensions_on_upload(image):
|
| 123 |
-
if image is None:
|
| 124 |
-
return 1024, 1024
|
| 125 |
-
|
| 126 |
-
original_width, original_height = image.size
|
| 127 |
-
|
| 128 |
-
# Cap max dimension to 1024 while preserving aspect ratio
|
| 129 |
-
if original_width > original_height:
|
| 130 |
-
new_width = 1024
|
| 131 |
-
aspect_ratio = original_height / original_width
|
| 132 |
-
new_height = int(new_width * aspect_ratio)
|
| 133 |
-
else:
|
| 134 |
-
new_height = 1024
|
| 135 |
-
aspect_ratio = original_width / original_height
|
| 136 |
-
new_width = int(new_height * aspect_ratio)
|
| 137 |
-
|
| 138 |
-
# Ensure dimensions are multiples of 8 for model compatibility
|
| 139 |
-
new_width = (new_width // 8) * 8
|
| 140 |
-
new_height = (new_height // 8) * 8
|
| 141 |
-
|
| 142 |
-
return new_width, new_height
|
| 143 |
-
|
| 144 |
# --- Main Inference Function ---
|
| 145 |
@spaces.GPU
|
| 146 |
def infer(
|
|
@@ -190,6 +167,29 @@ def infer(
|
|
| 190 |
|
| 191 |
return result, seed, gr.Button(visible=True)
|
| 192 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
# Wrapper for examples to handle file paths
|
| 194 |
@spaces.GPU
|
| 195 |
def infer_example(input_image_path, prompt, lora_adapter):
|
|
@@ -277,4 +277,4 @@ with gr.Blocks(css=css, theme=steel_blue_theme) as demo:
|
|
| 277 |
outputs=[width, height]
|
| 278 |
)
|
| 279 |
|
| 280 |
-
demo.launch(
|
|
|
|
| 118 |
|
| 119 |
MAX_SEED = np.iinfo(np.int32).max
|
| 120 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
# --- Main Inference Function ---
|
| 122 |
@spaces.GPU
|
| 123 |
def infer(
|
|
|
|
| 167 |
|
| 168 |
return result, seed, gr.Button(visible=True)
|
| 169 |
|
| 170 |
+
# --- Helper Functions ---
|
| 171 |
+
def update_dimensions_on_upload(image):
|
| 172 |
+
if image is None:
|
| 173 |
+
return 1024, 1024
|
| 174 |
+
|
| 175 |
+
original_width, original_height = image.size
|
| 176 |
+
|
| 177 |
+
# Cap max dimension to 1024 while preserving aspect ratio
|
| 178 |
+
if original_width > original_height:
|
| 179 |
+
new_width = 1024
|
| 180 |
+
aspect_ratio = original_height / original_width
|
| 181 |
+
new_height = int(new_width * aspect_ratio)
|
| 182 |
+
else:
|
| 183 |
+
new_height = 1024
|
| 184 |
+
aspect_ratio = original_width / original_height
|
| 185 |
+
new_width = int(new_height * aspect_ratio)
|
| 186 |
+
|
| 187 |
+
# Ensure dimensions are multiples of 8 for model compatibility
|
| 188 |
+
new_width = (new_width // 8) * 8
|
| 189 |
+
new_height = (new_height // 8) * 8
|
| 190 |
+
|
| 191 |
+
return new_width, new_height
|
| 192 |
+
|
| 193 |
# Wrapper for examples to handle file paths
|
| 194 |
@spaces.GPU
|
| 195 |
def infer_example(input_image_path, prompt, lora_adapter):
|
|
|
|
| 277 |
outputs=[width, height]
|
| 278 |
)
|
| 279 |
|
| 280 |
+
demo.launch(ssr_mode=False)
|