INNER CODE UNIT · Python
is_image_meta_equal
yurijmikhalevich/rclip · rclip/main.py:38
def is_image_meta_equal(image: db.ImageState, meta: ImageMeta) -> bool:
return meta["modified_at"] == image["modified_at"] and meta["size"] == image["size"]
def _too_large_message(path: str, pixels: int, limit: int) -> str:
size = f" ({pixels / 1_000_000:.0f} MP)" if pixels else ""
return (
f"skipping {path}: it is too large to process{size};"
f" the limit is {limit / 1_000_000:.0f} MP."
' Raise or disable it with "--max-image-megapixels" if you want to index this image'
)
def _read_and_preprocess(path: str) -> Tuple[str, str, npt.NDArray[np.float32]]:
"""Reads an image, computes its hash, and runs the CLIP preprocessing on it. Runs on the loader
threads so that the decoding and resizing happen in parallel and only the
model forward pass is left for the consumer."""
file_hash = helpers.compute_file_hash(path)