Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -547,30 +547,29 @@ def worker(input_image, prompt, n_prompt, seed, total_second_length, latent_wind
|
|
547 |
return
|
548 |
|
549 |
# 入力画像の処理
|
550 |
-
last_update_time = time.time()
|
551 |
-
stream.output_queue.push(('progress', (None, '', make_progress_bar_html(0, '画像処理中 ...'))))
|
552 |
-
|
553 |
try:
|
554 |
H, W, C = input_image.shape
|
555 |
|
556 |
# 事前定義された解像度から最も近いアスペクト比を見つける
|
557 |
target_width, target_height = find_closest_aspect_ratio(W, H, PREDEFINED_RESOLUTIONS)
|
558 |
|
559 |
-
#
|
560 |
-
|
561 |
-
|
562 |
|
563 |
# CPUモードの場合、処理サイズを小さくする
|
564 |
if cpu_fallback_mode:
|
565 |
scale_factor = min(320 / target_height, 320 / target_width)
|
566 |
target_height = int(target_height * scale_factor)
|
567 |
target_width = int(target_width * scale_factor)
|
|
|
|
|
|
|
568 |
|
569 |
print(f'元の画像サイズ: {W}x{H}, リサイズ先: {target_width}x{target_height}')
|
570 |
|
571 |
# 選択された解像度にリサイズ
|
572 |
input_image_np = resize_and_center_crop(input_image, target_width=target_width, target_height=target_height)
|
573 |
-
|
574 |
Image.fromarray(input_image_np).save(os.path.join(outputs_folder, f'{job_id}.png'))
|
575 |
|
576 |
input_image_pt = torch.from_numpy(input_image_np).float() / 127.5 - 1
|
|
|
547 |
return
|
548 |
|
549 |
# 入力画像の処理
|
|
|
|
|
|
|
550 |
try:
|
551 |
H, W, C = input_image.shape
|
552 |
|
553 |
# 事前定義された解像度から最も近いアスペクト比を見つける
|
554 |
target_width, target_height = find_closest_aspect_ratio(W, H, PREDEFINED_RESOLUTIONS)
|
555 |
|
556 |
+
# height, width変数も保持する(元のコードとの互換性のため)
|
557 |
+
width = target_width
|
558 |
+
height = target_height
|
559 |
|
560 |
# CPUモードの場合、処理サイズを小さくする
|
561 |
if cpu_fallback_mode:
|
562 |
scale_factor = min(320 / target_height, 320 / target_width)
|
563 |
target_height = int(target_height * scale_factor)
|
564 |
target_width = int(target_width * scale_factor)
|
565 |
+
# 縮小後の値も更新
|
566 |
+
height = target_height
|
567 |
+
width = target_width
|
568 |
|
569 |
print(f'元の画像サイズ: {W}x{H}, リサイズ先: {target_width}x{target_height}')
|
570 |
|
571 |
# 選択された解像度にリサイズ
|
572 |
input_image_np = resize_and_center_crop(input_image, target_width=target_width, target_height=target_height)
|
|
|
573 |
Image.fromarray(input_image_np).save(os.path.join(outputs_folder, f'{job_id}.png'))
|
574 |
|
575 |
input_image_pt = torch.from_numpy(input_image_np).float() / 127.5 - 1
|