-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest_successive_ddnm_diffusion.py
44 lines (38 loc) · 1.42 KB
/
test_successive_ddnm_diffusion.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
34
35
36
37
38
39
40
41
42
43
44
from denoising_diffusion_pytorch.successive_ddnm_diffusion import Unet, GaussianDiffusion, Tester
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--resume',
default=None,
type=int,
help='checkpoint to load')
parser.add_argument('--num_scenes',
default=4,
type=int,
help='how many scenes to generate')
parser.add_argument('--num_samples',
default=4,
type=int,
help='sample numbers for each scene')
args = parser.parse_args()
model = Unet(dim=64, param_cond_dim=4, dim_mults=(1, 2, 4, 8), channels=1)
diffusion = GaussianDiffusion(
model,
image_size=256,
timesteps=1000, # number of steps
sampling_timesteps=
32, # number of sampling timesteps (using ddim for faster inference [see citation for ddim paper])
loss_type='l1', # L1 or L2
objective='pred_x0',
beta_schedule='sigmoid',
ddim_sampling_eta=1.0,
is_ddnm_sampling=True)
tester = Tester(
diffusion,
batch_size=4,
ema_decay=0.995, # exponential moving average decay
results_folder='./successive_ddnm_diffusion_results',
samples_folder='./successive_ddnm_diffusion_samples',
amp=False # turn on mixed precision
)
tester.load("{}".format(args.resume))
tester.sample(num_scenes=args.num_scenes, num_samples=args.num_samples)