1inkusFace commited on
Commit
8e44b23
·
verified ·
1 Parent(s): dfeabbd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -8
app.py CHANGED
@@ -286,7 +286,7 @@ def generate_images_30(prompt, neg_prompt_1, neg_prompt_2, neg_prompt_3, width,
286
  # 4. Create 16-bit PIL Image from the same tensor (for Upscaler)
287
  # Pillow 10+ can create an 'RGB' mode image from a uint16 array
288
  srgb_numpy_16bit = (srgb_tensor_0_1.cpu().permute(0, 2, 3, 1).float().numpy()[0] * 65535.0).round().astype("uint16")
289
- sd_image_pil_16bit = Image.fromarray(srgb_numpy_16bit, mode='RGB')
290
  print('-- got 16-bit PIL image for upscaling --')
291
 
292
  # 5. Run the 16-bit upscaling (4x)
@@ -295,8 +295,6 @@ def generate_images_30(prompt, neg_prompt_1, neg_prompt_2, neg_prompt_3, width,
295
  upscale_1 = upscaler_2(sd_image_pil_16bit, tiling=True, tile_width=256, tile_height=256)
296
  upscale_2 = upscaler_2(upscale_1, tiling=True, tile_width=256, tile_height=256)
297
  print('-- got 4K 16-bit upscaled PIL image --')
298
-
299
- #downscaled_upscale = upscale_2.resize((upscale_2.width // 8, upscale_2.height // 8), Image.LANCZOS)
300
 
301
  torch.cuda.empty_cache()
302
 
@@ -357,8 +355,6 @@ def generate_images_60(prompt, neg_prompt_1, neg_prompt_2, neg_prompt_3, width,
357
  upscale_1 = upscaler_2(sd_image_pil_16bit, tiling=True, tile_width=256, tile_height=256)
358
  upscale_2 = upscaler_2(upscale_1, tiling=True, tile_width=256, tile_height=256)
359
  print('-- got 4K 16-bit upscaled PIL image --')
360
-
361
- #downscaled_upscale = upscale_2.resize((upscale_2.width // 8, upscale_2.height // 8), Image.LANCZOS)
362
 
363
  torch.cuda.empty_cache()
364
 
@@ -413,14 +409,12 @@ def generate_images_110(prompt, neg_prompt_1, neg_prompt_2, neg_prompt_3, width,
413
  sd_image_pil_16bit = Image.fromarray(srgb_numpy_16bit, mode='RGB')
414
  print('-- got 16-bit PIL image for upscaling --')
415
 
416
- # 5. Run the 16-bit upscaling (4x)
417
  # We feed the high-precision 16-bit PIL image to the upscaler
418
  with torch.no_grad():
419
  upscale_1 = upscaler_2(sd_image_pil_16bit, tiling=True, tile_width=256, tile_height=256)
420
  upscale_2 = upscaler_2(upscale_1, tiling=True, tile_width=256, tile_height=256)
421
  print('-- got 4K 16-bit upscaled PIL image --')
422
-
423
- #downscaled_upscale = upscale_2.resize((upscale_2.width // 8, upscale_2.height // 8), Image.LANCZOS)
424
 
425
  torch.cuda.empty_cache()
426
 
 
286
  # 4. Create 16-bit PIL Image from the same tensor (for Upscaler)
287
  # Pillow 10+ can create an 'RGB' mode image from a uint16 array
288
  srgb_numpy_16bit = (srgb_tensor_0_1.cpu().permute(0, 2, 3, 1).float().numpy()[0] * 65535.0).round().astype("uint16")
289
+ sd_image_pil_16bit = Image.fromarray(srgb_numpy_16bit)
290
  print('-- got 16-bit PIL image for upscaling --')
291
 
292
  # 5. Run the 16-bit upscaling (4x)
 
295
  upscale_1 = upscaler_2(sd_image_pil_16bit, tiling=True, tile_width=256, tile_height=256)
296
  upscale_2 = upscaler_2(upscale_1, tiling=True, tile_width=256, tile_height=256)
297
  print('-- got 4K 16-bit upscaled PIL image --')
 
 
298
 
299
  torch.cuda.empty_cache()
300
 
 
355
  upscale_1 = upscaler_2(sd_image_pil_16bit, tiling=True, tile_width=256, tile_height=256)
356
  upscale_2 = upscaler_2(upscale_1, tiling=True, tile_width=256, tile_height=256)
357
  print('-- got 4K 16-bit upscaled PIL image --')
 
 
358
 
359
  torch.cuda.empty_cache()
360
 
 
409
  sd_image_pil_16bit = Image.fromarray(srgb_numpy_16bit, mode='RGB')
410
  print('-- got 16-bit PIL image for upscaling --')
411
 
412
+ # 5. Run the 16-bit upscaling (4x)
413
  # We feed the high-precision 16-bit PIL image to the upscaler
414
  with torch.no_grad():
415
  upscale_1 = upscaler_2(sd_image_pil_16bit, tiling=True, tile_width=256, tile_height=256)
416
  upscale_2 = upscaler_2(upscale_1, tiling=True, tile_width=256, tile_height=256)
417
  print('-- got 4K 16-bit upscaled PIL image --')
 
 
418
 
419
  torch.cuda.empty_cache()
420