該項目著重於嵌入和檢索從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許可證獲得許可的 - 有關詳細信息,請參見許可證文件。
您可以找到更多詳細信息,並在擁抱面前訪問數據集。