INNER CODE UNIT · Python

download_image_from_filesystem

openfoodfacts/openfoodfacts-ai · category-detection/main.py:277

async def download_image_from_filesystem(url: str, base_dir: Path) -> bytes:
    """Download an image from the filesystem and return its content as bytes.

    Args:
        url (str): URL of the image to download.
        base_dir (Path): Base directory where images are stored.
    Returns:
        bytes: Content of the downloaded image.
    """
    file_path = urlparse(url).path[1:]  # Remove leading '/'
    full_file_path = base_dir / file_path
    async with aiofiles.open(full_file_path, "rb") as f:
        return await f.read()


async def upload_to_gcs(
    image_url: str,
    bucket_name: str,

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…