(self, device)
| 300 | |
| 301 | class ImageCaptioning: |
| 302 | def __init__(self, device): |
| 303 | print(f"Initializing ImageCaptioning to {device}") |
| 304 | self.device = device |
| 305 | self.torch_dtype = torch.float16 if 'cuda' in device else torch.float32 |
| 306 | self.processor = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-base") |
| 307 | self.model = BlipForConditionalGeneration.from_pretrained( |
| 308 | "Salesforce/blip-image-captioning-base", torch_dtype=self.torch_dtype).to(self.device) |
| 309 | |
| 310 | @prompts(name="Get Photo Description", |
| 311 | description="useful when you want to know what is inside the photo. receives image_path as input. " |
nothing calls this directly
no outgoing calls
no test coverage detected