-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathreconstruct.py
33 lines (26 loc) · 1.12 KB
/
reconstruct.py
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
import torch
from model.dataset import ShapeNet_Dataset
from model.decoder import Decoder
import model.reconstruct as reconstruct
# ------------ setting device on GPU if available, else CPU ------------
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
print('Using device:', device)
# ------------ load validation samples ------------
val_data_path = "./processed_data/validation"
val_dataset = ShapeNet_Dataset(val_data_path)
# ------------ load decoder ------------
decoder = Decoder().to(device)
checkpoint = torch.load("./checkpoints/trained_model.pt")
decoder.load_state_dict(checkpoint["model"])
# ------------ reconstruction ------------
for idx in range(len(val_dataset)):
test_sample = val_dataset[idx]
filename = "./reconstruction/example_" + str(51+idx)
reconstruct.reconstruct(test_sample,
decoder,
filename,
lat_iteration=800,
lat_init_std = 0.01,
lat_lr = 5e-4,
N=256,
max_batch=32 ** 3)