def image_to_product_description()

in experiments/google/cloud/ml/applied/images/image_to_text.py [0:0]


def image_to_product_description(image: str) -> m.TextValue:
    prompt = """Write enriched product description for the main product in
    the image for retailer's product catalog"""

    if image.startswith("gs://"):
        im = from_gsc_uri(image)
    else:
        im = from_url(image)
    responses = content_generation(prompt, im)
    res = ""
    for response in responses:
        res += response.candidates[0].content.parts[0].text
    desc = res.strip()

    return m.TextValue(text=desc)