MCPcopy
hub / github.com/MaartenGr/BERTopic / _images_to_text

Method _images_to_text

bertopic/_bertopic.py:3884–3899  ·  view source on GitHub ↗

Convert images to text.

(self, documents: pd.DataFrame, embeddings: np.ndarray)

Source from the content-addressed store, hash-verified

3882 return embeddings
3883
3884 def _images_to_text(self, documents: pd.DataFrame, embeddings: np.ndarray) -> pd.DataFrame:
3885 """Convert images to text."""
3886 logger.info("Images - Converting images to text. This might take a while.")
3887 if isinstance(self.representation_model, dict):
3888 for tuner in self.representation_model.values():
3889 if getattr(tuner, "image_to_text_model", False):
3890 documents = tuner.image_to_text(documents, embeddings)
3891 elif isinstance(self.representation_model, list):
3892 for tuner in self.representation_model:
3893 if getattr(tuner, "image_to_text_model", False):
3894 documents = tuner.image_to_text(documents, embeddings)
3895 elif isinstance(self.representation_model, BaseRepresentation):
3896 if getattr(self.representation_model, "image_to_text_model", False):
3897 documents = self.representation_model.image_to_text(documents, embeddings)
3898 logger.info("Images - Completed \u2713")
3899 return documents
3900
3901 def _map_predictions(self, predictions: List[int]) -> List[int]:
3902 """Map predictions to the correct topics if topics were reduced."""

Callers 1

fit_transformMethod · 0.95

Calls 2

infoMethod · 0.80
image_to_textMethod · 0.80

Tested by

no test coverage detected