inputs = caption_processor(images, text, return_tensors="pt").to(device="cuda", dtype=caption_generator.dtype)
caption_generator.to("cuda")
outputs = caption_generator.generate(**inputs, max_new_tokens=128)

# offload caption generator
caption_generator.to("cpu")

caption = caption_processor.batch_decode(outputs, skip_special_tokens=True)[0]
return caption
```  
Load an input image and generate a caption for it using the `generate_caption` function:  
```py
from diffusers.utils import load_image