Spaces:
Sleeping
Sleeping
from transformers import pipeline | |
import gradio as gr | |
from PIL import Image | |
import numpy as np | |
# Load the image captioning pipeline | |
pipe = pipeline("image-to-text", model="Salesforce/blip-image-captioning-large") | |
def fun2(image): | |
# Convert input image (which may be a NumPy array) to PIL Image | |
if isinstance(image, np.ndarray): | |
image = Image.fromarray(image) | |
ans = pipe(image) | |
return ans[0]['generated_text'] | |
# Set up Gradio interface | |
obj4 = gr.Interface(fn=fun2, inputs="image", outputs="text") | |
obj4.launch(debug=True) | |