ibm_1 / app.py
marcellohalfeld's picture
Create app.py
f8ad3f6 verified
raw
history blame
976 Bytes
import gradio as gr
import numpy as np
from PIL import Image
from transformers import AutoProcessor, BlipForConditionalGeneration
processor = # write your code here
model = # write your code here
def caption_image(input_image: np.ndarray):
# Convert numpy array to PIL Image and convert to RGB
raw_image = Image.fromarray(input_image).convert('RGB')
# Process the image
# Generate a caption for the image
# Decode the generated tokens to text and store it into `caption`
return caption
iface = gr.Interface(
fn=caption_image,
inputs=gr.Image(),
outputs="text",
title="Image Captioning",
description="This is a simple web app for generating captions for images using a trained model."
)
iface = gr.Interface(
fn=caption_image,
inputs=gr.Image(),
outputs="text",
title="Image Captioning",
description="This is a simple web app for generating captions for images using a trained model."
)