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

Fix for issue #72 #105

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 main.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ def __init__(self, batch_frequency, max_images, clamp=True, increase_log_steps=T
self.log_on_batch_idx = log_on_batch_idx
self.log_images_kwargs = log_images_kwargs if log_images_kwargs else {}
self.log_first_step = log_first_step
self.last_idx = -1

@rank_zero_only
def _testtube(self, pl_module, images, batch_idx, split):
Expand Down Expand Up @@ -391,6 +392,7 @@ def log_img(self, pl_module, batch, batch_idx, split="train"):
hasattr(pl_module, "log_images") and
callable(pl_module.log_images) and
self.max_images > 0):
self.last_idx = check_idx
logger = type(pl_module.logger)

is_train = pl_module.training
Expand Down Expand Up @@ -418,8 +420,9 @@ def log_img(self, pl_module, batch, batch_idx, split="train"):
pl_module.train()

def check_frequency(self, check_idx):
if ((check_idx % self.batch_freq) == 0 or (check_idx in self.log_steps)) and (
check_idx > 0 or self.log_first_step):
if (self.last_idx != check_idx and
((check_idx % self.batch_freq) == 0 or (check_idx in self.log_steps)) and
(check_idx > 0 or self.log_first_step)):
try:
self.log_steps.pop(0)
except IndexError as e:
Expand Down