patrickvonplaten commited on
Commit
2720c36
1 Parent(s): 3ee4870

clamp generated images

Browse files
Files changed (2) hide show
  1. generated_image_3.png +0 -0
  2. run.py +2 -2
generated_image_3.png CHANGED
run.py CHANGED
@@ -49,7 +49,7 @@ with torch.no_grad():
49
  # process image
50
  image_processed = image.cpu().permute(0, 2, 3, 1)
51
  image_processed = (image_processed + 1.0) * 127.5
52
- image_processed = image_processed.numpy().astype(np.uint8)
53
  image_pil = PIL.Image.fromarray(image_processed[0])
54
 
55
 
@@ -70,7 +70,7 @@ image = pipeline(generator=generator, num_inference_steps=200)["sample"]
70
  # process image
71
  image_processed = image.cpu().permute(0, 2, 3, 1)
72
  image_processed = (image_processed + 1.0) * 127.5
73
- image_processed = image_processed.numpy().astype(np.uint8)
74
  image_pil = PIL.Image.fromarray(image_processed[0])
75
 
76
  image_pil.save(f"generated_image_{seed}.png")
 
49
  # process image
50
  image_processed = image.cpu().permute(0, 2, 3, 1)
51
  image_processed = (image_processed + 1.0) * 127.5
52
+ image_processed = image_processed.clamp(0, 255).numpy().astype(np.uint8)
53
  image_pil = PIL.Image.fromarray(image_processed[0])
54
 
55
 
 
70
  # process image
71
  image_processed = image.cpu().permute(0, 2, 3, 1)
72
  image_processed = (image_processed + 1.0) * 127.5
73
+ image_processed = image_processed.clamp(0, 255).numpy().astype(np.uint8)
74
  image_pil = PIL.Image.fromarray(image_processed[0])
75
 
76
  image_pil.save(f"generated_image_{seed}.png")