def compute_gallery_embeddings(self): ''' Computes embedding vectors for the gallery images. ''' images = [] for full_path in tqdm(self.impaths, desc='Reading gallery images.'): image = cv2.imread(str(full_path)) if image is None: log.error("Cannot process image, full_path =", str(full_path)) continue image = crop_resize(image, self.input_size) images.append(image) embeddings = np.vstack([ self.model.predict(image) for image in tqdm(images, desc='Computing embeddings of gallery images.') ]) return embeddings
def compute_embedding(self, image): ''' Takes input image and computes embedding vector. ''' image = crop_resize(image, self.input_size) embedding = self.model.predict(image) return embedding