safer writing of batch schedule

This commit is contained in:
Victor Hall 2023-01-02 18:02:35 -05:00
parent 51ee7253bb
commit 07125135a8
1 changed files with 5 additions and 3 deletions

View File

@ -89,10 +89,12 @@ class EveryDreamBatch(Dataset):
self.write_batch_schedule(0) self.write_batch_schedule(0)
def write_batch_schedule(self, epoch_n): def write_batch_schedule(self, epoch_n):
with open(f"{self.log_folder}/ep{epoch_n}_batch_schedule.txt", "w") as f: with open(f"{self.log_folder}/ep{epoch_n}_batch_schedule.txt", "w", encoding='utf-8') as f:
for i in range(len(self.image_train_items)): for i in range(len(self.image_train_items)):
try:
f.write(f"step:{int(i / self.batch_size)}, wh:{self.image_train_items[i].target_wh}, r:{self.image_train_items[i].runt_size}, path:{self.image_train_items[i].pathname}\n") f.write(f"step:{int(i / self.batch_size)}, wh:{self.image_train_items[i].target_wh}, r:{self.image_train_items[i].runt_size}, path:{self.image_train_items[i].pathname}\n")
#exit() except Exception as e:
logging.error(f" * Error writing to batch schedule for file path: {self.image_train_items[i].pathname}")
def get_runts(): def get_runts():
return dls.shared_dataloader.runts return dls.shared_dataloader.runts