Pipeline से कैप्शन जनरेशन
इस अभ्यास में, आप फिर से flickr डेटासेट का उपयोग करेंगे, जिसमें 30,000 इमेज और उनके कैप्शन हैं. अब आप auto classes की बजाय एक pipeline का उपयोग करके नीचे दी गई इमेज के लिए कैप्शन जनरेट करेंगे.

डेटासेट (dataset) निम्नलिखित संरचना के साथ लोड किया गया है:
Dataset({
features: ['image', 'caption', 'sentids', 'split', 'img_id', 'filename'],
num_rows: 10
})
Pipeline मॉड्यूल (pipeline) लोड किया गया है.
यह अभ्यास पाठ्यक्रम का हिस्सा है
Hugging Face के साथ मल्टी-मोडल मॉडल्स
अभ्यास निर्देश
Salesforce/blip-image-captioning-basepretrained मॉडल के साथimage-to-textpipeline लोड करें.- Index
3पर मौजूद इमेज के लिए कैप्शन जनरेट करने के लिए pipeline का उपयोग करें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Load the image-to-text pipeline
pipe = pipeline(task="____", model="____")
# Use the pipeline to generate a caption with the image of datapoint 3
pred = ____(dataset[3]["____"])
print(pred)