Skip to content

Commit

Permalink
Skip invalid images (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtalcott authored Dec 27, 2023
1 parent eabafb6 commit 7b9d266
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/lib/duplicate_image_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,17 @@ def _calculate_embeddings(self):
for i in trange(len(self.media_items), ascii=False):
media_item = self.media_items[i]
storage_path = self._get_storage_path(media_item)
mp_image = mp.Image.create_from_file(storage_path)

mp_image = None
try:
mp_image = mp.Image.create_from_file(storage_path)
except RuntimeError as error:
logging.warning(
f"Skipping invalid image file:\n"
f"error: {error}\n"
f"media_item: {media_item}\n"
)
continue
embedding_result = embedder.embed(mp_image)
embeddings.append(embedding_result.embeddings[0].embedding)

Expand Down

0 comments on commit 7b9d266

Please sign in to comment.