เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

Image classification

In this exercise, you will use the same flickr dataset as previously, which has 30,000 images and associated captions. Now you will classify the image using a pretrained model.

Photo of 2 people, 1 is playing the guitar

The sample image (image) and pipeline module (pipeline) have been loaded.

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

Multi-Modal Models with Hugging Face

ดูคอร์ส

คำแนะนำการฝึกหัด

  • Load the image-classification pipeline with google/mobilenet_v2_1.0_224 pretrained model.
  • Use the pipeline to predict the class of the sample image.
  • Print the first (highest probability) label.

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

# Load the image-classification pipeline
pipe = ____

# Use the pipeline to predict the class of the sample image
pred = ____

# Print the first (highest probability) label
print("Predicted class:", ____)
แก้ไขและรันโค้ด