patrickvonplaten
commited on
Commit
•
3ee4870
1
Parent(s):
a7acc83
new images
Browse files- generated_image.png +0 -0
- generated_image_pipeline.png → generated_image_0.png +0 -0
- generated_image_1.png +0 -0
- generated_image_2.png +0 -0
- generated_image_3.png +0 -0
- generated_image_unrolled.png +0 -0
- run.py +5 -5
generated_image.png
DELETED
Binary file (177 kB)
|
|
generated_image_pipeline.png → generated_image_0.png
RENAMED
File without changes
|
generated_image_1.png
ADDED
generated_image_2.png
ADDED
generated_image_3.png
ADDED
generated_image_unrolled.png
DELETED
Binary file (119 kB)
|
|
run.py
CHANGED
@@ -5,6 +5,8 @@ import PIL.Image
|
|
5 |
import numpy as np
|
6 |
import tqdm
|
7 |
|
|
|
|
|
8 |
# 1. Unroll the full loop
|
9 |
# ==================================================================
|
10 |
# load all models
|
@@ -19,7 +21,7 @@ unet.to(torch_device)
|
|
19 |
vqvae.to(torch_device)
|
20 |
|
21 |
# generate gaussian noise to be decoded
|
22 |
-
generator = torch.manual_seed(
|
23 |
noise = torch.randn(
|
24 |
(1, unet.in_channels, unet.image_size, unet.image_size),
|
25 |
generator=generator,
|
@@ -50,8 +52,6 @@ image_processed = (image_processed + 1.0) * 127.5
|
|
50 |
image_processed = image_processed.numpy().astype(np.uint8)
|
51 |
image_pil = PIL.Image.fromarray(image_processed[0])
|
52 |
|
53 |
-
image_pil.save("generated_image_unrolled.png")
|
54 |
-
|
55 |
|
56 |
# 2. Use pipeline
|
57 |
# ==================================================================
|
@@ -64,7 +64,7 @@ import tqdm
|
|
64 |
pipeline = LatentDiffusionUncondPipeline.from_pretrained("./")
|
65 |
|
66 |
# generatae image by calling the pipeline
|
67 |
-
generator = torch.manual_seed(
|
68 |
image = pipeline(generator=generator, num_inference_steps=200)["sample"]
|
69 |
|
70 |
# process image
|
@@ -73,4 +73,4 @@ 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("
|
|
|
5 |
import numpy as np
|
6 |
import tqdm
|
7 |
|
8 |
+
seed = 3
|
9 |
+
|
10 |
# 1. Unroll the full loop
|
11 |
# ==================================================================
|
12 |
# load all models
|
|
|
21 |
vqvae.to(torch_device)
|
22 |
|
23 |
# generate gaussian noise to be decoded
|
24 |
+
generator = torch.manual_seed(seed)
|
25 |
noise = torch.randn(
|
26 |
(1, unet.in_channels, unet.image_size, unet.image_size),
|
27 |
generator=generator,
|
|
|
52 |
image_processed = image_processed.numpy().astype(np.uint8)
|
53 |
image_pil = PIL.Image.fromarray(image_processed[0])
|
54 |
|
|
|
|
|
55 |
|
56 |
# 2. Use pipeline
|
57 |
# ==================================================================
|
|
|
64 |
pipeline = LatentDiffusionUncondPipeline.from_pretrained("./")
|
65 |
|
66 |
# generatae image by calling the pipeline
|
67 |
+
generator = torch.manual_seed(seed)
|
68 |
image = pipeline(generator=generator, num_inference_steps=200)["sample"]
|
69 |
|
70 |
# process image
|
|
|
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")
|