Spaces:
Sleeping
Sleeping
| from transformers import pipeline | |
| class ImageCaptioning: | |
| def __init__(self): | |
| self.captioner = pipeline("image-to-text", model="Salesforce/blip-image-captioning-large") | |
| def generate_caption(self, image_data): | |
| try: | |
| caption = self.captioner(image_data)[0]['generated_text'] | |
| return caption | |
| except Exception as e: | |
| print(f"Error during image captioning: {e}") | |
| return "Error processing image." |