|
# 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 |
|
|
|
``` |