该项目着重于嵌入和检索从Aarong,Allen Solly,Bata,Apex和Infinity等主要品牌收集的大型时尚产品数据集。该数据集由20,000多种产品组成,涵盖了各种类型和样式。笔记本电脑利用强大的模型和工具来为文本和图像创建嵌入式,然后使用QDRANT将这些嵌入在矢量数据库中。该设置可以根据语义相似性有效,准确地检索时尚产品。
该数据集托管在拥抱面前,包括超过20,000种从多个来源刮掉的时尚产品,其中包括产品类别,公司,名称,描述,规格,图像链接等细节。您可以在此处探索数据集。
text-embedding-3-large模型来为产品描述和摘要创建高维嵌入。SentenceTransformer库中的夹子( clip-ViT-B-32 )来生成图像嵌入。该模型捕获了可根据其外观来查找类似产品的视觉功能。对于每种产品,都会生成一个摘要字符串,捕获关键细节,例如类别,公司,名称和规格。然后使用文本模型嵌入此字符串。同时,将主要产品图像下载,处理和编码以生成图像嵌入。两个嵌入都存储在QDRANT集合中,以进行有效的向量搜索。
QDRANT数据库被用作这些嵌入的矢量存储,从而支持基于文本和图像查询的实时相似性搜索。该笔记本创建了一个集合,可以使用余弦相似性来适应摘要和图像向量。
笔记本在数据集上迭代,并:
此设置允许基于多模式数据的时尚产品建议或搜索功能的任何系统无缝集成。
上面的图像展示了QDRANT集合中存储的向量点的数量,可视化数据集的规模和存储的嵌入。
该项目是希望探索多模式嵌入,向量数据库和时尚数据的任何人的绝佳资源。
该项目利用LLAVA(语言和视觉助手)模型来生成图像中的产品描述和规格。该模型基于可以与文本和视觉输入相互作用的对话AI体系结构。
在运行代码之前,请确保您安装了以下依赖项:
transformers和datasets集库torchPIL安装LLAVA软件包:
! pip install git+https://github.com/haotian-liu/LLaVA.git@786aa6a19ea10edc6f574ad2e16276974e9aaa3a安装其他依赖项:
! pip install -qU datasets初始化llava聊天机器人:
from transformers import AutoTokenizer , BitsAndBytesConfig
from llava . model import LlavaLlamaForCausalLM
from llava . utils import disable_torch_init
from llava . constants import IMAGE_TOKEN_INDEX , DEFAULT_IMAGE_TOKEN , DEFAULT_IM_START_TOKEN , DEFAULT_IM_END_TOKEN
from llava . mm_utils import tokenizer_image_token , KeywordsStoppingCriteria
from llava . conversation import conv_templates , SeparatorStyle
import torch
from PIL import Image
import requests
from io import BytesIO
chatbot = LLaVAChatBot ( load_in_8bit = True ,
bnb_8bit_compute_dtype = torch . float16 ,
bnb_8bit_use_double_quant = True ,
bnb_8bit_quant_type = 'nf8' )加载数据集:
from datasets import load_dataset
fashion = load_dataset (
"thegreyhound/demo2" ,
split = "train"
)
product_df = fashion . to_pandas ()生成产品描述和规格:
cnt = 1
for index , row in product_df . iterrows ():
str1 = "Given Image detail was: " + row [ 'Description' ] + " Now generate a brief high level description for the product shown in the image"
str2 = "Given Image detail was: " + row [ 'Description' ] + " Now generate a detailed specifications for the product shown in the image including the fabric, color, design, style etc"
ans1 = chatbot . start_new_chat ( img_path = row [ 'Image_link' ],
prompt = str1 )
ans2 = chatbot . start_new_chat ( img_path = row [ 'Image_link' ],
prompt = str2 )
product_df . loc [ index , 'Description' ] = ans1
product_df . loc [ index , 'Specifications' ] = ans2
print ( cnt )
cnt += 1脚本处理图像并生成高级产品描述和详细规范。最终输出保存在包含一系列产品信息的JSON文件中。
该项目是根据MIT许可证获得许可的 - 有关详细信息,请参见许可证文件。
您可以找到更多详细信息,并在拥抱面前访问数据集。