INNER CODE UNIT · Python
get_image_urls
openfoodfacts/openfoodfacts-ai · category-detection/main.py:81
def get_image_urls(
barcode: str, images: list[dict[str, Any]], flavor: Flavor
) -> list[str]:
"""Generate image URLs that will be used for product categorization.
We look for the most recent front and ingredients images, and return them
in that order. If only one of them is available, we return just that one.
Args:
barcode (str): The barcode of the product.
images (list[dict[str, Any]]): List of image metadata dictionaries, as
available in the Parquet export.
flavor (Flavor): The flavor of the image to generate URLs for.
"""
images = copy.deepcopy(images)
for image in images:
if not image["key"].isdigit():