Spaces:
Sleeping
Sleeping
File size: 605 Bytes
85552cb 0ae85a9 85552cb 7199a54 0ae85a9 7199a54 0ae85a9 85552cb 0ae85a9 85552cb 0ae85a9 7199a54 85552cb 7199a54 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | import gradio as gr
from transformers import pipeline
# Lightweight image captioning model
pipe = pipeline(
"image-text-to-text",
model="microsoft/git-base"
)
def describe_image(image):
try:
result = pipe(image)
return result[0]["generated_text"]
except Exception as e:
return f"Error: {str(e)}"
demo = gr.Interface(
fn=describe_image,
inputs=gr.Image(type="pil"),
outputs="text",
title="🖼️ Image Description AI (Lightweight)",
description="Upload an image and the AI will describe it."
)
if __name__ == "__main__":
demo.launch()
|