Spaces:
Runtime error
Runtime error
update app
Browse files
app.py
CHANGED
|
@@ -125,6 +125,27 @@ pipe.load_lora_weights("dx8152/Qwen-Image-Edit-2509-Relight",
|
|
| 125 |
pipe.transformer.set_attn_processor(QwenDoubleStreamAttnProcessorFA3())
|
| 126 |
MAX_SEED = np.iinfo(np.int32).max
|
| 127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
@spaces.GPU
|
| 129 |
def infer(
|
| 130 |
input_image,
|
|
@@ -155,7 +176,9 @@ def infer(
|
|
| 155 |
negative_prompt = "worst quality, low quality, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, jpeg artifacts, signature, watermark, username, blurry"
|
| 156 |
|
| 157 |
original_image = input_image.convert("RGB")
|
| 158 |
-
|
|
|
|
|
|
|
| 159 |
|
| 160 |
result = pipe(
|
| 161 |
image=original_image,
|
|
|
|
| 125 |
pipe.transformer.set_attn_processor(QwenDoubleStreamAttnProcessorFA3())
|
| 126 |
MAX_SEED = np.iinfo(np.int32).max
|
| 127 |
|
| 128 |
+
def update_dimensions_on_upload(image):
|
| 129 |
+
if image is None:
|
| 130 |
+
return 1024, 1024
|
| 131 |
+
|
| 132 |
+
original_width, original_height = image.size
|
| 133 |
+
|
| 134 |
+
if original_width > original_height:
|
| 135 |
+
new_width = 1024
|
| 136 |
+
aspect_ratio = original_height / original_width
|
| 137 |
+
new_height = int(new_width * aspect_ratio)
|
| 138 |
+
else:
|
| 139 |
+
new_height = 1024
|
| 140 |
+
aspect_ratio = original_width / original_height
|
| 141 |
+
new_width = int(new_height * aspect_ratio)
|
| 142 |
+
|
| 143 |
+
# Ensure dimensions are multiples of 8
|
| 144 |
+
new_width = (new_width // 8) * 8
|
| 145 |
+
new_height = (new_height // 8) * 8
|
| 146 |
+
|
| 147 |
+
return new_width, new_height
|
| 148 |
+
|
| 149 |
@spaces.GPU
|
| 150 |
def infer(
|
| 151 |
input_image,
|
|
|
|
| 176 |
negative_prompt = "worst quality, low quality, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, jpeg artifacts, signature, watermark, username, blurry"
|
| 177 |
|
| 178 |
original_image = input_image.convert("RGB")
|
| 179 |
+
|
| 180 |
+
# Use the new function to update dimensions
|
| 181 |
+
width, height = update_dimensions_on_upload(original_image)
|
| 182 |
|
| 183 |
result = pipe(
|
| 184 |
image=original_image,
|