From 15080055bf4330a806c409d3ca69ec5b0eab99f2 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Thu, 22 Jun 2023 11:22:28 +0200 Subject: Update --- training/strategy/dreambooth.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'training') diff --git a/training/strategy/dreambooth.py b/training/strategy/dreambooth.py index 43fe838..35cccbb 100644 --- a/training/strategy/dreambooth.py +++ b/training/strategy/dreambooth.py @@ -203,10 +203,13 @@ def dreambooth_prepare( text_encoder, unet, optimizer, train_dataloader, val_dataloader, lr_scheduler ) - for layer in text_encoder.text_model.encoder.layers[ - : (-1 * text_encoder_unfreeze_last_n_layers) - ]: - layer.requires_grad_(False) + if text_encoder_unfreeze_last_n_layers == 0: + text_encoder.text_model.encoder.requires_grad_(False) + elif text_encoder_unfreeze_last_n_layers > 0: + for layer in text_encoder.text_model.encoder.layers[ + : (-1 * text_encoder_unfreeze_last_n_layers) + ]: + layer.requires_grad_(False) text_encoder.text_model.embeddings.requires_grad_(False) -- cgit v1.2.3-70-g09d2