mirror of
https://github.com/kohya-ss/sd-scripts.git
synced 2026-04-09 06:45:09 +00:00
Set grad enabled if is_train and train_text_encoder
We only want to be enabling grad if we are training.
This commit is contained in:
@@ -145,7 +145,7 @@ class NetworkTrainer:
|
|||||||
latents = latents * self.vae_scale_factor
|
latents = latents * self.vae_scale_factor
|
||||||
b_size = latents.shape[0]
|
b_size = latents.shape[0]
|
||||||
|
|
||||||
with torch.set_grad_enabled(train_text_encoder), accelerator.autocast():
|
with torch.set_grad_enabled(is_train and train_text_encoder), accelerator.autocast():
|
||||||
# Get the text embedding for conditioning
|
# Get the text embedding for conditioning
|
||||||
if args.weighted_captions:
|
if args.weighted_captions:
|
||||||
text_encoder_conds = get_weighted_text_embeddings(
|
text_encoder_conds = get_weighted_text_embeddings(
|
||||||
|
|||||||
Reference in New Issue
Block a user