Flickr30k图像标注数据集下载及使用方法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/gaoyueace/article/details/80564642

Flickr30k数据集的下载

  1. 可在http://shannon.cs.illinois.edu/DenotationGraph/中填表,获取下载地址http://shannon.cs.illinois.edu/DenotationGraph/data/index.html,但是下载地址不稳定,有时会崩溃。
    这里写图片描述
    一般下载前两个,第一个是图像(大小为4.14G),第二个是图像所带的标注。
  2. 直接从百度云盘中下载
    链接:https://pan.baidu.com/s/1r0RVUwctJsI0iNuVXHQ6kA 密码:hrf3
    flickr30k-images.tar是图像,flickr30k.tar.gz是标注。
    若链接失效,可联系我。

Flickr30k数据集的使用

图像文件夹中有31783张图像,标注文件夹中是一个results_20130124.token文件。
下面的代码是如何打开token文件并且读取图像标注:

import pandas as pd

annotations = pd.read_table('results_20130124.token', sep='\t', header=None,
                            names=['image', 'caption'])
print(annotations['caption'])

结果为:

                   image                                            caption
0       1000092795.jpg#0  Two young guys with shaggy hair look at their ...
1       1000092795.jpg#1  Two young , White males are outside near many ...
2       1000092795.jpg#2   Two men in green shirts are standing in a yard .
3       1000092795.jpg#3       A man in a blue shirt standing in a garden .
4       1000092795.jpg#4            Two friends enjoy time spent together .
5         10002456.jpg#0  Several men in hard hats are operating a giant...
6         10002456.jpg#1  Workers look down from up above on a piece of ...
7         10002456.jpg#2   Two men working on a machine wearing hard hats .
8         10002456.jpg#3              Four men on top of a tall structure .
9         10002456.jpg#4                         Three men on a large rig .
10      1000268201.jpg#0  A child in a pink dress is climbing up a set o...
11      1000268201.jpg#1  A little girl in a pink dress going into a woo...
12      1000268201.jpg#2  A little girl climbing the stairs to her playh...
13      1000268201.jpg#3   A little girl climbing into a wooden playhouse .
14      1000268201.jpg#4              A girl going into a wooden building .
15      1000344755.jpg#0  Someone in a blue shirt and hat is standing on...
16      1000344755.jpg#1  A man in a blue shirt is standing on a ladder ...
17      1000344755.jpg#2  A man on a ladder cleans the window of a tall ...
18      1000344755.jpg#3  man in blue shirt and jeans on ladder cleaning...
19      1000344755.jpg#4                  a man on a ladder cleans a window
20      1000366164.jpg#0  Two men , one in a gray shirt , one in a black...
21      1000366164.jpg#1  Two guy cooking and joking around with the cam...
22      1000366164.jpg#2     Two men in a kitchen cooking food on a stove .
23      1000366164.jpg#3          Two men are at the stove preparing food .
24      1000366164.jpg#4                       Two men are cooking a meal .
25      1000523639.jpg#0  Two people in the photo are playing the guitar...
26      1000523639.jpg#1  A man in green holds a guitar while the other ...
27      1000523639.jpg#2       A man is fixing the guitar players costume .
28      1000523639.jpg#3           a guy stitching up another man 's coat .
29      1000523639.jpg#4                        the two boys playing guitar
...                  ...                                                ...
158885   996962407.jpg#0  a man with a wheelbarrow is standing outside a...
158886   996962407.jpg#1  A man in a silver rain poncho standing next to...
158887   996962407.jpg#2  A man in a silver raincoat standing outside by...
158888   996962407.jpg#3  A man in a raincoat stands outside a house in ...
158889   996962407.jpg#4      A man in a raincoat is standing in the rain .
158890   997338199.jpg#0  Woman writing on a pad in room with gold , dec...
158891   997338199.jpg#1    A woman standing near a decorated wall writes .
158892   997338199.jpg#2       The walls are covered in gold and patterns .
158893   997338199.jpg#3          a woman behind a scrolled wall is writing
158894   997338199.jpg#4                A person stands near golden walls .
158895   997722733.jpg#0  A person in a red shirt climbing up a rock fac...
158896   997722733.jpg#1  A rock climber practices on a rock climbing wa...
158897   997722733.jpg#2           A man in a pink shirt climbs a rock face
158898   997722733.jpg#3           A man is rock climbing high in the air .
158899   997722733.jpg#4                    A rock climber in a red shirt .
158900   997876722.jpg#0  Two male construction workers are working on a...
158901   997876722.jpg#1  Two workmen with a wheelbarrow for mixing ceme...
158902   997876722.jpg#2  Men in orange and yellow clothing lean over a ...
158903   997876722.jpg#3  Men are working on pouring concrete outside of...
158904   997876722.jpg#4           Fruits stationed by a dusty old window .
158905    99804383.jpg#0  An older busker in glasses plays an Eastern st...
158906    99804383.jpg#1  This is a man in front of a store performing w...
158907    99804383.jpg#2  A older Asian man is playing an instrument in ...
158908    99804383.jpg#3  An elderly man sits outside a storefront accom...
158909    99804383.jpg#4  An elderly gentleman playing a musical instrum...
158910   998845445.jpg#0  A man in shorts and a Hawaiian shirt leans ove...
158911   998845445.jpg#1  A young man hanging over the side of a boat , ...
158912   998845445.jpg#2  A man is leaning off of the side of a blue and...
158913   998845445.jpg#3  A man riding a small boat in a harbor , with f...
158914   998845445.jpg#4  A man on a moored blue and white boat with hil...

[158915 rows x 2 columns]

前面的数字代表了有多少句标注,中间的image是这句标注所对应的图像,后面的caption则为标注语句。每一张图像都带有5句标注,所以一共158915句话。
若只想提取所有标注,则使用以下代码即可:

print(annotations['caption'])
展开阅读全文

没有更多推荐了,返回首页