File size: 620 Bytes
4f97b8d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Unconditional Pothole Images Generation 

## Generating New Images

```{python}
from diffusers import DDPMPipeline
import torch
from PIL import Image

pipe = DDPMPipeline.from_pretrained("ridzy619/pothole-unconditional-generation")

device = "cuda" if torch.cuda.is_available() else "cpu"
pipe.to(device)

images = pipe(batch_size=16).images

def make_grid(images, rows, cols):
    w, h = images[0].size
    grid = Image.new('RGB', size=(cols*w, rows*h))
    for i, image in enumerate(images):
        grid.paste(image, box=(i%cols*w, i//cols*h))
    return grid

images_grid = make_grid(images, 4, 4)
images_grid

```