CLIP के साथ Zero-shot learning
आप rajuptvs/ecommerce_products_clip डेटासेट से एक image को zero-shot learning की मदद से classify करेंगे, जिसमें लगभग 2k प्रोडक्ट images उनके विवरणों के साथ हैं:

आपके लिए डेटासेट (dataset), CLIPProcessor (processor), और CLIPModel (model) पहले से लोड हैं, साथ ही categories की एक सूची भी:
categories = ["shirt", "trousers", "shoes", "dress", "hat",
"bag", "watch", "glasses", "jacket", "belt"]
यह अभ्यास पाठ्यक्रम का हिस्सा है
Hugging Face के साथ मल्टी-मोडल मॉडल्स
अभ्यास निर्देश
processorका उपयोग करकेcategoriesऔरdatasetके index999पर मौजूद image को preprocess करें; padding सक्षम करें.- अनपैक किए गए
inputsकोmodelमें पास करें. .logits_per_imageattribute और.softmax()मेथड का उपयोग करके हर category की probabilities निकालें.probsऔरcategoriesका उपयोग करके सबसे संभावित category ढूँढें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Preprocess the categories and image
inputs = ____(text=____, images=____, return_tensors="pt", padding=____)
# Process the unpacked inputs with the model
outputs = ____
# Calculate the probabilities of each category
probs = outputs.____.____(dim=1)
# Find the most likely category
category = categories[probs.____.item()]
print(f"Predicted category: {category}")