INNER CODE UNIT · Python
_generate_vectors
patrickjohncyh/fashion-clip · fashion_clip/fashion_clip.py:134
def _generate_vectors(self, cache=True):
# check if dataset + model embedding exists
if self.vector_hash in _VECTORS:
image_vectors_path = _download(_VECTORS[self.vector_hash]['IMAGE'], _CACHE_DIR)
text_vectors_path = _download(_VECTORS[self.vector_hash]['TEXT'], _CACHE_DIR)
image_vectors = np.load(image_vectors_path)
textual_vectors = np.load(text_vectors_path)
else:
# generate image vectors
image_vectors = self.encode_images(self.dataset.images_path, batch_size=32)
# generate textual vectors
textual_vectors = self.encode_text(self.dataset.captions, batch_size=32)
# TODO: Implement some sort of caching mechanism?
return image_vectors, textual_vectors
def _load_model(self,
name: str,