Generate captions for images in the presentation.
(self)
| 43 | shape.caption = stats["caption"] |
| 44 | |
| 45 | def caption_images(self): |
| 46 | """ |
| 47 | Generate captions for images in the presentation. |
| 48 | """ |
| 49 | caption_prompt = open("prompts/caption.txt").read() |
| 50 | for image, stats in self.image_stats.items(): |
| 51 | if "caption" not in stats: |
| 52 | stats["caption"] = llms.vision_model( |
| 53 | caption_prompt, pjoin(self.config.IMAGE_DIR, image) |
| 54 | ) |
| 55 | print("captioned", image, ": ", stats["caption"]) |
| 56 | json.dump( |
| 57 | self.image_stats, |
| 58 | open(self.stats_file, "w"), |
| 59 | indent=4, |
| 60 | ensure_ascii=False, |
| 61 | ) |
| 62 | self.apply_stats() |
| 63 | return self.image_stats |
| 64 | |
| 65 | def collect_images(self): |
| 66 | """ |
no test coverage detected