Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to load the model i trained and denoise from a given step? #348

Open
ohaiyoskibidi opened this issue Oct 21, 2024 · 0 comments
Open

Comments

@ohaiyoskibidi
Copy link

i'm using the training code offered by the author:

from denoising_diffusion_pytorch import Unet, GaussianDiffusion, Trainer

model = Unet(
dim = 64,
dim_mults = (1, 2, 4, 8),
flash_attn = True
)

diffusion = GaussianDiffusion(
model,
image_size = 128,
timesteps = 1000, # number of steps
sampling_timesteps = 250 # number of sampling timesteps (using ddim for faster inference [see citation for ddim paper])
)

trainer = Trainer(
diffusion,
'ImageDataset',
train_batch_size = 32,
train_lr = 8e-5,
train_num_steps = 700000, # total training steps
gradient_accumulate_every = 2, # gradient accumulation steps
ema_decay = 0.995, # exponential moving average decay
amp = True, # turn on mixed precision
calculate_fid = True # whether to calculate fid during training
)

trainer.train()

Now I'm trying to verify the model I trained in another 'denoising.py' file, let's say the model's save path is "./results/model-best.pt"
Should I type the code above again except trainer.train() and add trainer.load("best")?
And do that means after this I can just type some code such as

for t in tqdm(reversed(range(0, t_max+1)), desc = 'sampling loop time step', total = t_max+1):

img, x_start = diffusion.p_sample(img, t)

to start denoising from the step t_max and image img i want?
Excuse me for my bad expression.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant