Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion examples/dreambooth/train_dreambooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import torch.utils.checkpoint
from torch.utils.data import Dataset

from torch.cuda.amp import autocast

from accelerate import Accelerator
from accelerate.logging import get_logger
from accelerate.utils import set_seed
Expand Down Expand Up @@ -629,7 +631,8 @@ def collate_fn(examples):
encoder_hidden_states = text_encoder(batch["input_ids"])[0]

# Predict the noise residual
model_pred = unet(noisy_latents, timesteps, encoder_hidden_states).sample
with autocast():
model_pred = unet(noisy_latents, timesteps, encoder_hidden_states).sample

# Get the target for loss depending on the prediction type
if noise_scheduler.config.prediction_type == "epsilon":
Expand Down