INNER CODE UNIT · Python

display_products

patrickjohncyh/fashion-clip · fashion_clip/fashion_clip.py:70

    def display_products(self, ids: List[str], fields: Tuple[str] = ('id', 'short_description'), **kwargs):
        idxs = [self.id_to_idx[id] for id in ids]
        im_paths = list(self.images_path[idxs])
        prod_info = [{field: row[field] for field in fields}  for row in self.catalog[idxs]]
        return self._display_images(im_paths, product_info=prod_info, **kwargs)

    def random_product_id(self):
        return self.ids[random.randint(0, len(self.ids))]

    def _retrieve_row(self, id: str):
        return self.catalog[self.id_to_idx[id]]

    # def get_metadata(self, id, fields=['caption', 'price']):
    #     pass
    def _hash_list(self, l: List[str]):
        l_hash = map(lambda el: hashlib.sha256(str(el).encode()).hexdigest(), l)
        l_hash = ' '.join(l_hash)
        return hashlib.sha256(l_hash.encode()).hexdigest()

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…