Fix other things...
Browse files- rct_diffusion_pipeline.py +1 -0
- test_pipeline.py +5 -5
- train_model.py +0 -1
rct_diffusion_pipeline.py
CHANGED
@@ -29,6 +29,7 @@ class RCTDiffusionPipeline(DiffusionPipeline):
|
|
29 |
|
30 |
# channels for 1 image
|
31 |
self.num_channels = int(self.unet.config.in_channels / 4)
|
|
|
32 |
|
33 |
def load_dictionaries_from_dataset(self):
|
34 |
dataset = load_dataset('frutiemax/rct_dataset')
|
|
|
29 |
|
30 |
# channels for 1 image
|
31 |
self.num_channels = int(self.unet.config.in_channels / 4)
|
32 |
+
self.load_dictionaries_from_dataset()
|
33 |
|
34 |
def load_dictionaries_from_dataset(self):
|
35 |
dataset = load_dataset('frutiemax/rct_dataset')
|
test_pipeline.py
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
from rct_diffusion_pipeline import RCTDiffusionPipeline
|
2 |
from diffusers import UNet2DConditionModel, DDPMScheduler, AutoencoderKL
|
3 |
-
|
4 |
|
5 |
torch_device = "cuda"
|
6 |
|
7 |
-
unet = UNet2DConditionModel(sample_size=
|
8 |
down_block_types=('CrossAttnDownBlock2D', 'CrossAttnDownBlock2D', 'DownBlock2D'),\
|
9 |
up_block_types=('UpBlock2D', 'CrossAttnUpBlock2D', 'CrossAttnUpBlock2D'), cross_attention_dim=160,
|
10 |
block_out_channels=(64, 128, 256), norm_num_groups=32)
|
|
|
11 |
scheduler = DDPMScheduler(num_train_timesteps=20)
|
12 |
-
vae = AutoencoderKL.from_pretrained("
|
13 |
-
vae.
|
14 |
-
|
15 |
|
16 |
pipeline = RCTDiffusionPipeline(unet, scheduler, vae)
|
17 |
output = pipeline([[('aleppo pine tree', 1.0)]], [[('dark green', 1.0)]])
|
|
|
1 |
from rct_diffusion_pipeline import RCTDiffusionPipeline
|
2 |
from diffusers import UNet2DConditionModel, DDPMScheduler, AutoencoderKL
|
3 |
+
import torch
|
4 |
|
5 |
torch_device = "cuda"
|
6 |
|
7 |
+
unet = UNet2DConditionModel(sample_size=32, in_channels=16, out_channels=16, \
|
8 |
down_block_types=('CrossAttnDownBlock2D', 'CrossAttnDownBlock2D', 'DownBlock2D'),\
|
9 |
up_block_types=('UpBlock2D', 'CrossAttnUpBlock2D', 'CrossAttnUpBlock2D'), cross_attention_dim=160,
|
10 |
block_out_channels=(64, 128, 256), norm_num_groups=32)
|
11 |
+
unet = unet.to('cuda', dtype=torch.float16)
|
12 |
scheduler = DDPMScheduler(num_train_timesteps=20)
|
13 |
+
vae = AutoencoderKL.from_pretrained("stabilityai/sd-vae-ft-mse", use_safetensors=True)
|
14 |
+
vae = vae.to('cuda', dtype=torch.float16)
|
|
|
15 |
|
16 |
pipeline = RCTDiffusionPipeline(unet, scheduler, vae)
|
17 |
output = pipeline([[('aleppo pine tree', 1.0)]], [[('dark green', 1.0)]])
|
train_model.py
CHANGED
@@ -119,7 +119,6 @@ def train_model(batch_size=4, epochs=100, scheduler_num_timesteps=20, save_model
|
|
119 |
num_training_steps=num_images * epochs
|
120 |
)
|
121 |
model = RCTDiffusionPipeline(unet, scheduler, vae)
|
122 |
-
model.load_dictionaries_from_dataset()
|
123 |
labels = convert_labels(dataset, model, num_images)
|
124 |
del model
|
125 |
|
|
|
119 |
num_training_steps=num_images * epochs
|
120 |
)
|
121 |
model = RCTDiffusionPipeline(unet, scheduler, vae)
|
|
|
122 |
labels = convert_labels(dataset, model, num_images)
|
123 |
del model
|
124 |
|