30 lines
566 B
Python
30 lines
566 B
Python
#!/usr/bin/env python3
|
|
|
|
# make a 3x3 grid of all pngs in current directory
|
|
# requires pytorch
|
|
# License AGPLv3
|
|
import os
|
|
|
|
import torch
|
|
import torchvision
|
|
from torchvision.io import read_image
|
|
from torchvision.utils import make_grid
|
|
|
|
filenames = []
|
|
|
|
for n in os.listdir('.'):
|
|
if n.endswith('.png'):
|
|
filenames.append(n)
|
|
|
|
cells = []
|
|
|
|
for n in filenames:
|
|
cells.append(read_image(n))
|
|
|
|
print(len(cells))
|
|
grid = make_grid(cells, nrow=3)
|
|
print("size of grid:", grid.size())
|
|
img = torchvision.transforms.ToPILImage()(grid)
|
|
img.show()
|
|
img.save(f'tenowls.png')
|