Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -96,8 +96,8 @@ def generate_caption(image):
|
|
96 |
task_prompt = "<MORE_DETAILED_CAPTION>"
|
97 |
prompt = task_prompt
|
98 |
|
99 |
-
inputs = florence_processor(text=prompt, images=image, return_tensors="pt").to(device)
|
100 |
-
|
101 |
generated_ids = florence_model.generate(
|
102 |
input_ids=inputs["input_ids"],
|
103 |
pixel_values=inputs["pixel_values"],
|
@@ -133,8 +133,8 @@ def process_input(input_image, upscale_factor):
|
|
133 |
)
|
134 |
target_input_pixels = MAX_PIXEL_BUDGET / (upscale_factor ** 2)
|
135 |
scale = (target_input_pixels / (w * h)) ** 0.5
|
136 |
-
new_w = int(w * scale) - int(w * scale) % 8
|
137 |
-
new_h = int(h * scale) - int(h * scale) % 8
|
138 |
input_image = input_image.resize((new_w, new_h), resample=Image.LANCZOS)
|
139 |
was_resized = True
|
140 |
|
@@ -184,6 +184,9 @@ def tiled_flux_img2img(pipe, prompt, image, strength, steps, guidance, generator
|
|
184 |
generator=generator,
|
185 |
).images[0]
|
186 |
|
|
|
|
|
|
|
187 |
# Paste with blending if overlap
|
188 |
if overlap > 0:
|
189 |
paste_box = (x, y, x + tile_w, y + tile_h)
|
|
|
96 |
task_prompt = "<MORE_DETAILED_CAPTION>"
|
97 |
prompt = task_prompt
|
98 |
|
99 |
+
inputs = florence_processor(text=prompt, images=image, return_tensors="pt").to(florence_model.device) # Fixed: Use model's current device instead of static 'device'
|
100 |
+
|
101 |
generated_ids = florence_model.generate(
|
102 |
input_ids=inputs["input_ids"],
|
103 |
pixel_values=inputs["pixel_values"],
|
|
|
133 |
)
|
134 |
target_input_pixels = MAX_PIXEL_BUDGET / (upscale_factor ** 2)
|
135 |
scale = (target_input_pixels / (w * h)) ** 0.5
|
136 |
+
new_w = int(w * scale) - int(w * scale) % 16 # Fixed: Use % 16 for FLUX alignment (was % 8)
|
137 |
+
new_h = int(h * scale) - int(h * scale) % 16 # Fixed: Use % 16 for FLUX alignment (was % 8)
|
138 |
input_image = input_image.resize((new_w, new_h), resample=Image.LANCZOS)
|
139 |
was_resized = True
|
140 |
|
|
|
184 |
generator=generator,
|
185 |
).images[0]
|
186 |
|
187 |
+
# Fixed: Resize generated tile back to exact tile dimensions if pipeline auto-resized for multiple-of-16 requirement
|
188 |
+
gen_tile = gen_tile.resize((tile_w, tile_h), resample=Image.LANCZOS)
|
189 |
+
|
190 |
# Paste with blending if overlap
|
191 |
if overlap > 0:
|
192 |
paste_box = (x, y, x + tile_w, y + tile_h)
|