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()