Views
No views yet
| Coupling Layers | 32 |
| Coupling Types | 4:1 channel/spatial |
| Training Data | Downsampled ImageNet |
| Training Duration | 50 epochs |
| Performance | 3.79 bits per dim (validation) |
pip install jet-pytorch1from jet_pytorch import Jet
2
3jet_config = dict(
4 patch_size=4,
5 patch_dim=48,
6 n_patches=256,
7 coupling_layers=32,
8 block_depth=2,
9 block_width=512,
10 num_heads=8,
11 scale_factor=2.0,
12 coupling_types=(
13 "channels", "channels",
14 "channels", "channels",
15 "spatial",
16 ),
17 spatial_coupling_projs=(
18 "checkerboard", "checkerboard-inv",
19 "vstripes", "vstripes-inv",
20 "hstripes", "hstripes-inv",
21 )
22)
23model = Jet(**jet_config)1from jet_pytorch.util import get_pretrained
2
3weights = get_pretrained()
4model.load_state_dict(weights)1from torch.distributions import Normal
2
3batch_size = 16
4n_patches = 256
5patch_dim = 48
6pdf = Normal(0, 1)
7z = pdf.sample((batch_size, n_patches, patch_dim))
8img, logdet = model.inverse(z)1from jet_pytorch.train import train
2
3jet_config = dict(...)
4train(
5 jet_config=jet_config,
6 batch_size=64,
7 accumulate_steps=16,
8 device="cuda:0",
9 epochs=50,
10 warmup_percentage=0.1,
11 max_grad_norm=1.0,
12 learning_rate=3e-4,
13 weight_decay=1e-5,
14 adam_betas=(0.9, 0.95),
15 images_path_train="/path/to/train/images",
16 images_path_valid="/path/to/validation/images",
17 num_workers=8,
18 checkpoint_path="jet.pt",
19)batch_size * accumulate_steps. Note that the default configuration assumes at least 24GB of VRAM.1from jet_pytorch.sample import sample
2
3# Creates visualization using the default Jet config/pretrained weights
4sample("path/to/your/images")
5
6# Creates visualization using default Jet config/a local checkpoint
7sample(
8 "path/to/your/images",
9 checkpoint_path="path/to/your/checkpoint.pt",
10)
11
12# Creates visualization using custom Jet config/a local checkpoint
13jet_config = dict(...)
14sample(
15 "path/to/your/images",
16 jet_config=jet_config,
17 checkpoint_path="path/to/your/checkpoint.pt",
18)output/jet.png