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

Toggle use_table with image logger #66

Merged
merged 2 commits into from
Sep 11, 2023
Merged
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
7 changes: 5 additions & 2 deletions diffusion/callbacks/log_diffusion_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class LogDiffusionImages(Callback):
to use for evaluation. Default: ``None``.
seed (int, optional): Random seed to use for generation. Set a seed for reproducible generation.
Default: ``1138``.
use_table (bool): Whether to make a table of the images or not. Default: ``False``.
"""

def __init__(self,
Expand All @@ -40,14 +41,16 @@ def __init__(self,
guidance_scale: Optional[float] = 0.0,
text_key: Optional[str] = 'captions',
tokenized_prompts: Optional[torch.LongTensor] = None,
seed: Optional[int] = 1138):
seed: Optional[int] = 1138,
use_table: bool = False):
self.prompts = prompts
self.size = size
self.num_inference_steps = num_inference_steps
self.guidance_scale = guidance_scale
self.text_key = text_key
self.seed = seed
self.tokenized_prompts = tokenized_prompts
self.use_table = use_table

def eval_batch_end(self, state: State, logger: Logger):
# Only log once per eval epoch
Expand Down Expand Up @@ -81,4 +84,4 @@ def eval_batch_end(self, state: State, logger: Logger):

# Log images to wandb
for prompt, image in zip(self.prompts, gen_images):
logger.log_images(images=image, name=prompt, step=state.timestamp.batch.value)
logger.log_images(images=image, name=prompt, step=state.timestamp.batch.value, use_table=self.use_table)