शुरू करेंमुफ़्त में शुरू करें

CLIP के साथ Zero-shot learning

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

Image of a woman modeling a dress

आपके लिए डेटासेट (dataset), CLIPProcessor (processor), और CLIPModel (model) पहले से लोड हैं, साथ ही categories की एक सूची भी:

categories = ["shirt", "trousers", "shoes", "dress", "hat", 
              "bag", "watch", "glasses", "jacket", "belt"]

यह अभ्यास पाठ्यक्रम का हिस्सा है

Hugging Face के साथ मल्टी-मोडल मॉडल्स

पाठ्यक्रम देखें

अभ्यास निर्देश

  • processor का उपयोग करके categories और dataset के index 999 पर मौजूद image को preprocess करें; padding सक्षम करें.
  • अनपैक किए गए inputs को model में पास करें.
  • .logits_per_image attribute और .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}")
कोड संपादित करें और चलाएँ