From 07125135a8ad149f3faeb19c67a8bb6213d4937b Mon Sep 17 00:00:00 2001 From: Victor Hall Date: Mon, 2 Jan 2023 18:02:35 -0500 Subject: [PATCH] safer writing of batch schedule --- data/every_dream.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/data/every_dream.py b/data/every_dream.py index c36ee99..00aea14 100644 --- a/data/every_dream.py +++ b/data/every_dream.py @@ -89,10 +89,12 @@ class EveryDreamBatch(Dataset): self.write_batch_schedule(0) 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)): - 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() + 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") + except Exception as e: + logging.error(f" * Error writing to batch schedule for file path: {self.image_train_items[i].pathname}") def get_runts(): return dls.shared_dataloader.runts