Skip to content

Commit

Permalink
Log global_step instead of epoch to tensorboard (huggingface#4493)
Browse files Browse the repository at this point in the history
Co-authored-by: mrlzla <[email protected]>
  • Loading branch information
mrlzla and mrlzla authored Aug 7, 2023
1 parent 9c29bc2 commit 2e69cf1
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions examples/dreambooth/train_dreambooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,16 @@ def save_model_card(


def log_validation(
text_encoder, tokenizer, unet, vae, args, accelerator, weight_dtype, epoch, prompt_embeds, negative_prompt_embeds
text_encoder,
tokenizer,
unet,
vae,
args,
accelerator,
weight_dtype,
global_step,
prompt_embeds,
negative_prompt_embeds,
):
logger.info(
f"Running validation... \n Generating {args.num_validation_images} images with prompt:"
Expand Down Expand Up @@ -173,7 +182,7 @@ def log_validation(
for tracker in accelerator.trackers:
if tracker.name == "tensorboard":
np_images = np.stack([np.asarray(img) for img in images])
tracker.writer.add_images("validation", np_images, epoch, dataformats="NHWC")
tracker.writer.add_images("validation", np_images, global_step, dataformats="NHWC")
if tracker.name == "wandb":
tracker.log(
{
Expand Down Expand Up @@ -1308,7 +1317,7 @@ def compute_text_embeddings(prompt):
args,
accelerator,
weight_dtype,
epoch,
global_step,
validation_prompt_encoder_hidden_states,
validation_prompt_negative_prompt_embeds,
)
Expand Down

0 comments on commit 2e69cf1

Please sign in to comment.