Hi
In L2: Image captioning app, I can use correctly up to this point of code:
image_url = “https://free-images.com/sm/9596/dog_animal_greyhound_983023.jpg”
display(IPython.display.Image(url=image_url))
get_completion(image_url)
Output:
[{‘generated_text’: ‘a dog wearing a santa hat and a red scarf’}]
After launch the gradio interface code everything related with local ou remote access is ok, but I always receive a big and red ERROR inside the caption box:
import gradio as gr
def image_to_base64_str(pil_image):
byte_arr = io.BytesIO()
pil_image.save(byte_arr, format=‘PNG’)
byte_arr = byte_arr.getvalue()
return str(base64.b64encode(byte_arr).decode(‘utf-8’))
def captioner(image):
base64_image = image_to_base64_str(image)
result = get_completion(base64_image)
return result[0][‘generated_text’]
gr.close_all()
demo = gr.Interface(fn=captioner,
inputs=[gr.Image(label=“Upload image”, type=“pil”)],
outputs=[gr.Textbox(label=“Caption”)],
title=“Image Captioning with BLIP”,
description=“Caption any image using the BLIP model”,
allow_flagging=“never”,
examples=[“dog.jpeg”, “cow.jpeg”])
demo.launch(share=True)
Any idea of what I need to do to fix this ?
Tks,
Fábio