Spaces:
Runtime error
Runtime error
| import os | |
| import huggingface_hub as hf_hub | |
| import gradio as gr | |
| client = hf_hub.InferenceClient(token = os.environ['HF_TOKEN']) | |
| client.headers["x-use-cache"] = "0" | |
| def image_interface(img): | |
| response = client.image_to_text( | |
| image = img, | |
| model = 'Salesforce/blip-image-captioning-large' | |
| ) | |
| return response | |
| app = gr.Interface( | |
| fn = image_interface, | |
| inputs = gr.Image(type = 'filepath'), | |
| outputs = gr.Textbox(label = 'Image caption'), | |
| title = 'BLIP Image Captioning' | |
| ) | |
| app.launch() |