Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Unconditional Pothole Images Generation
|
| 2 |
+
|
| 3 |
+
## Generating New Images
|
| 4 |
+
|
| 5 |
+
```{python}
|
| 6 |
+
from diffusers import DDPMPipeline
|
| 7 |
+
import torch
|
| 8 |
+
from PIL import Image
|
| 9 |
+
|
| 10 |
+
pipe = DDPMPipeline.from_pretrained("ridzy619/pothole-unconditional-generation")
|
| 11 |
+
|
| 12 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 13 |
+
pipe.to(device)
|
| 14 |
+
|
| 15 |
+
images = pipe(batch_size=16).images
|
| 16 |
+
|
| 17 |
+
def make_grid(images, rows, cols):
|
| 18 |
+
w, h = images[0].size
|
| 19 |
+
grid = Image.new('RGB', size=(cols*w, rows*h))
|
| 20 |
+
for i, image in enumerate(images):
|
| 21 |
+
grid.paste(image, box=(i%cols*w, i//cols*h))
|
| 22 |
+
return grid
|
| 23 |
+
|
| 24 |
+
images_grid = make_grid(images, 4, 4)
|
| 25 |
+
images_grid
|
| 26 |
+
|
| 27 |
+
```
|