Sales Force Model#
caption_image Function#
- caption_image(img: Image, processor, model) tuple[str, str]#
Generates captions for a given Pillow Image using the specified model.
- Parameters:
img (Image) – The Pillow Image object to be captioned.
processor – The processor used for captioning the images.
model – The captioning model used for generating captions.
- Returns:
A tuple containing two captions: conditional and unconditional.
Generates captions for the input image using the provided model and processor. Two types of captions are generated: conditional and unconditional.
Conditional image captioning: This caption is generated by providing a prompt to the model.
Unconditional image captioning: This caption is generated without any specific prompt.
Example usage:#
from PIL import Image from captioning_module import Processor, Model img = Image.open("example.jpg") processor = Processor() model = Model() con_caption, unc_caption = caption_image(img, processor, model) print("Conditional Caption:", con_caption) print("Unconditional Caption:", unc_caption)