1. Learn
  2. /
  3. Courses
  4. /
  5. Hugging Face で学ぶマルチモーダルモデル

Connected

Exercise

キャプション品質の自動評価

ワンピースの画像は正しく分類できましたが、元の説明文はどれくらい的確だったでしょうか?

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 スコアでこの説明がどれほど正確かを定量的に評価します。キャプション(description)、画像(image)、ToTensor クラス、そして torchmetrics の clip_score() 関数は読み込まれています。

Instructions

100 XP
  • 画像を、画素強度が 0~255 の範囲になるように PyTorch テンソルへ変換します。
  • clip_score() 関数を使い、openai/clip-vit-base-patch32 モデルで image_tensor と description を比較してキャプションの品質を評価します。