การประเมินคุณภาพคำบรรยายภาพแบบอัตโนมัติ
จำแนกประเภทภาพชุดราตรีได้อย่างถูกต้องแล้ว แต่คำบรรยายดั้งเดิมนั้นแม่นยำแค่ไหน?
Maa Fab wrap with a Trendy design dress with Vibrant color for an elegant touch of Fabric completely Soft and Comfortable wear with amazing design of Solid Boat ? Neck Flared Dress to make a perfect addition to your wardrobe collection.
ขั้นตอนนี้จะใช้โมเดล CLIP เพื่อวัดความแม่นยำของคำบรรยายข้างต้นในเชิงปริมาณด้วย CLIP score โดยได้โหลด caption (description), ภาพ (image), คลาส ToTensor และฟังก์ชัน clip_score() จาก torchmetrics ไว้ให้แล้ว
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
โมเดล Multi-Modal ด้วย Hugging Face
คำแนะนำการฝึกหัด
- แปลงภาพให้เป็น PyTorch tensor ที่มีค่าความเข้ม (intensity) อยู่ในช่วง 0-255
- ใช้ฟังก์ชัน
clip_score()เพื่อประเมินคุณภาพของคำบรรยาย โดยเปรียบเทียบimage_tensorกับdescriptionด้วยโมเดลopenai/clip-vit-base-patch32
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# Convert the image to a PyTorch tensor
image_tensor = ____()(image)*____
# Use the clip_score function to assess the quality of the caption
score = ____(____, ____, "____")
print(f"CLIP score: {score}")