diff --git a/nomic/dataset.py b/nomic/dataset.py index 4906f33..fa412f3 100644 --- a/nomic/dataset.py +++ b/nomic/dataset.py @@ -1409,9 +1409,10 @@ def _add_blobs( # TODO: add support for other modalities images = [] for uuid, blob in tqdm(zip(ids, blobs), total=len(ids), desc="Loading images"): - if isinstance(blob, str) and os.path.exists(blob): + if (isinstance(blob, str) or isinstance(blob, Path)) and os.path.exists(blob): # Auto resize to max 512x512 image = Image.open(blob) + image = image.convert("RGB") if image.height > 512 or image.width > 512: image = image.resize((512, 512)) buffered = BytesIO() @@ -1420,6 +1421,7 @@ def _add_blobs( elif isinstance(blob, bytes): images.append((uuid, blob)) elif isinstance(blob, Image.Image): + blob = blob.convert("RGB") # type: ignore if blob.height > 512 or blob.width > 512: blob = blob.resize((512, 512)) buffered = BytesIO()