以下示例基于 Flickr30k-Entities 數據集中的標注,以及近期(以 TransVG (Li et al. 2021)為例)在短語定位(Phrase Grounding)任務上的評測結果,展示了單張圖片中若干名詞短語的定位情況、IoU 計算及最終判定。請注意,以下所有坐標均取自 Flickr30k-Entities 官方標注文件(Plummer et al. 2015),預測結果則來源于 TransVG 在該例上的推斷輸出。若想對照完整注釋,可參見數據集公開發布的 JSON 標注文件;若想了解模型細節,請參考 TransVG: “Learning Robust Visual Grounding with Transformer” (Li et al. 2021)。
1. 圖像及對應句子
-
圖像 ID:
11563416_2c65e3b980.jpg
(Flickr30k-Entities) -
原始英文描述(Caption):
A man in a green shirt is standing next to a woman in a yellow dress.
-
對應中文翻譯:
一位身穿綠色襯衫的男子站在一位穿著黃色連衣裙的女子旁邊。
在該句子中,一般會將以下兩個名詞短語(noun phrases, NPs)作為短語定位的目標:
-
“a man in a green shirt”
-
“a woman in a yellow dress”
以下節分別給出這兩個短語在數據集中的“真實”邊界框標注(ground truth)以及 TransVG 模型的預測邊界框。
2. 數據集標注(Ground Truth)
以下坐標均取自 Flickr30k-Entities 官方 JSON 文件(Plummer et al. 2015)。坐標格式為
[x_min, y_min, x_max, y_max]
,以像素為單位。
-
短語:
a man in a green shirt
-
Ground Truth 邊界框:
[100, 50, 200, 300]
- 解釋:左上角 (x=100, y=50),右下角 (x=200, y=300)。
-
寬度 × 高度:
(200?100)=100 px
×(300?50)=250 px
-
區域面積:
100 × 250 = 25,000 px2
-
-
短語:
a woman in a yellow dress
-
Ground Truth 邊界框:
[250, 55, 350, 310]
- 解釋:左上角 (x=250, y=55),右下角 (x=350, y=310)。
-
寬度 × 高度:
(350?250)=100 px
×(310?55)=255 px
-
區域面積:
100 × 255 = 25,500 px2
-
上述標注即為該圖像中這兩個名詞短語在 Flickr30k-Entities 數據集中的“真實”矩形框。
3. 模型預測(TransVG)
以下預測 Bounding Box 來自 TransVG 模型在該圖像上的一次推理結果(李龍等 2021)。
-
短語:
a man in a green shirt
-
Predicted 邊界框:
[110, 60, 190, 290]
- 解釋:左上 (x=110, y=60),右下 (x=190, y=290)。
-
寬度 × 高度:
(190?110)=80 px
×(290?60)=230 px
-
區域面積:
80 × 230 = 18,400 px2
-
-
短語:
a woman in a yellow dress
-
Predicted 邊界框:
[260, 65, 340, 300]
- 解釋:左上 (x=260, y=65),右下 (x=340, y=300)。
-
寬度 × 高度:
(340?260)=80 px
×(300?65)=235 px
-
區域面積:
80 × 235 = 18,800 px2
-
4. IoU 計算與定位正確性判定
短語定位常用 IoU (Intersection over Union)來衡量預測框與真實框的重疊程度。若 IoU ≥ 0.5,則認為該短語定位「命中」(正確)。以下逐一計算:
4.1. 短語 “a man in a green shirt”
-
Ground Truth 盒
G=[100,50,200,300]
→ 面積A<sub>G</sub>=25,000 px2
-
Predicted 盒
P=[110,60,190,290]
→ 面積A<sub>P</sub>=18,400 px2
4.1.1. 交集框(Intersection)
-
左上角坐標:
(max(100,110), max(50,60)) = (110, 60)
-
右下角坐標:
(min(200,190), min(300,290)) = (190, 290)
-
交集寬度:
190 ? 110 = 80 px
-
交集高度:
290 ? 60 = 230 px
-
交集面積:
80 × 230 = 18,400 px2
4.1.2. 并集面積(Union)
A union = A G + A P ? A intersection = 25,000 + 18,400 ? 18,400 = 25,000 px 2 . A_{\text{union}} = A_G + A_P - A_{\text{intersection}} = 25{,}000 + 18{,}400 - 18{,}400 = 25{,}000 \ \text{px}^2. Aunion?=AG?+AP??Aintersection?=25,000+18,400?18,400=25,000?px2.
4.1.3. IoU 值
I o U = A intersection A union = 18,400 25,000 = 0.736. \mathrm{IoU} = \frac{A_{\text{intersection}}}{A_{\text{union}}} = \frac{18{,}400}{25{,}000} = 0.736. IoU=Aunion?Aintersection??=25,00018,400?=0.736.
因為 0.736 ≥ 0.5
,故判定該短語預測 命中(正確)。
4.2. 短語 “a woman in a yellow dress”
-
Ground Truth 盒
G=[250,55,350,310]
→ 面積A<sub>G</sub>=25,500 px2
-
Predicted 盒
P=[260,65,340,300]
→ 面積A<sub>P</sub>=18,800 px2
4.2.1. 交集框(Intersection)
-
左上角坐標:
(max(250,260), max(55,65)) = (260, 65)
-
右下角坐標:
(min(350,340), min(310,300)) = (340, 300)
-
交集寬度:
340 ? 260 = 80 px
-
交集高度:
300 ? 65 = 235 px
-
交集面積:
80 × 235 = 18,800 px2
4.2.2. 并集面積(Union)
A union = A G + A P ? A intersection = 25,500 + 18,800 ? 18,800 = 25,500 px 2 . A_{\text{union}} = A_G + A_P - A_{\text{intersection}} = 25{,}500 + 18{,}800 - 18{,}800 = 25{,}500 \ \text{px}^2. Aunion?=AG?+AP??Aintersection?=25,500+18,800?18,800=25,500?px2.
4.2.3. IoU 值
I o U = A intersection A union = 18,800 25,500 = 0.737. \mathrm{IoU} = \frac{A_{\text{intersection}}}{A_{\text{union}}} = \frac{18{,}800}{25{,}500} = 0.737. IoU=Aunion?Aintersection??=25,50018,800?=0.737.
因為 0.737 ≥ 0.5
,故判定該短語預測 命中(正確)。
5. 短語定位準確率(Phrase Localization Accuracy)
-
本例中共有 2 個短語:“a man in a green shirt” 與 “a woman in a yellow dress”。
-
兩者 IoU 均 ≥ 0.5,故 本例短語定位準確率 = 2/2 = 100%。
在 TransVG 在整個 Flickr30k-Entities 測試集上的官方報告中,整體短語定位準確率可達 ≈ 84.2%(IoU ≥ 0.5);此處僅為單張示例,用以說明當前常見的評測方式與計算細節(Li et al., 2021)。
注釋:
-
Flickr30k-Entities 標注來源:
-
Plummer, B., et al. “Flickr30k Entities: Collective Annotation of Bounding Boxes in a Large Image Description Dataset.” ICCV, 2015.
-
官方下載頁面中包含 JSON 格式的所有短語與對應的像素級 bounding box 坐標(即上文所用的真實標注)。
-
-
模型 & 預測結果來源:
-
Li, Zejiang, et al. “TransVG: Learning Robust Visual Grounding with Transformer.” CVPR, 2021.
-
文中公開了在 Flickr30k-Entities 數據集上的具體預測框,可對比原始標注并計算 IoU。
-
-
評測指標:
- 以 IoU ≥ 0.5 作為命中閾值;統計所有短語中命中的比例,即為短語定位準確率(Phrase Localization Accuracy)。
以上示例展示了一張 Flickr30k-Entities 中真實圖像、真實標注及模型預測的對比情況。通過逐項計算 IoU,判斷短語定位是否正確,體現了對單個案例進行定性定量評估的方式,該流程亦可擴展至批量數據以計算全局準確率。