From 812369688369fca30a4428de79e7ecfcb2027ddd Mon Sep 17 00:00:00 2001 From: pharmapsychotic Date: Mon, 28 Nov 2022 12:36:24 -0600 Subject: [PATCH] Handle exception trying to load cached table --- clip_interrogator/clip_interrogator.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/clip_interrogator/clip_interrogator.py b/clip_interrogator/clip_interrogator.py index da664a3..e7d0ca1 100644 --- a/clip_interrogator/clip_interrogator.py +++ b/clip_interrogator/clip_interrogator.py @@ -251,10 +251,13 @@ class LabelTable(): cache_filepath = os.path.join(config.cache_path, f"{sanitized_name}_{desc}.pkl") if desc is not None and os.path.exists(cache_filepath): with open(cache_filepath, 'rb') as f: - data = pickle.load(f) - if data.get('hash') == hash: - self.labels = data['labels'] - self.embeds = data['embeds'] + try: + data = pickle.load(f) + if data.get('hash') == hash: + self.labels = data['labels'] + self.embeds = data['embeds'] + except Exception as e: + print(f"Error loading cached table {desc}: {e}") if len(self.labels) != len(self.embeds): self.embeds = []