forked from alextamkin/viewmaker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
viewaug6.py.bak
46 lines (38 loc) · 1.35 KB
/
viewaug6.py.bak
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from src.systems.image_systems import PretrainViewMakerSystem
import torch
from torchvision.datasets import FashionMNIST
from torch.utils.data import DataLoader
from src.utils import utils
from dotmap import DotMap
from src.datasets import datasets
from torch.utils.data import DataLoader
import torchvision.transforms as T
from PIL import Image
from ryudrigo.ranking_and_backbone import Backbone
from ryudrigo.custom_datasets import FFHQThumbDataset
from ryudrigo.ranking_and_backbone import Ranking
model = Ranking()
#dataset= FashionMNIST (root='data/fashionmnist', download=True, transform=T.Compose([T.Grayscale(3),T.ToTensor()]))
dataset = FFHQThumbDataset('data/ffhq-thumb')
data_loader = DataLoader(dataset)
transform = T.ToPILImage()
minibatch = []
for i, batch in enumerate(iter(data_loader)):
minibatch.append(batch[0])
if i>3:
break
minibatch = torch.cat(minibatch)
x, y, imgs1, imgs2 = model.generate_backbone_activations(minibatch)
print ('x-shape')
print (x.shape)
print ('y-shape')
print (y.shape)
print('y-hat')
print (model(x))
print ('y-true')
print (y)
for i, (img1, img2) in enumerate(zip (imgs1, imgs2)):
img1 = transform(img1)
img2 = transform(img2)
img1.save('ryudrigo/temp2-ffhq/'+ str(i)+'-img1'+ '.jpg')
img2.save('ryudrigo/temp2-ffhq/'+ str(i)+'-img2'+ '.jpg')