Skip to content

Commit 6b71849

Browse files
authored
Add multimodal dataset based on COCO text-image pairs (#559)
* add coco image2image and text2image datasets * split and build coco datasets from raw features * updated dataset entry in README table
1 parent 4d734fb commit 6b71849

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ We have a number of precomputed data sets in HDF5 format. All data sets have bee
7171
| [NYTimes](https://archive.ics.uci.edu/ml/datasets/bag+of+words) | 256 | 290,000 | 10,000 | 100 | Angular | [HDF5](http://ann-benchmarks.com/nytimes-256-angular.hdf5) (301MB) |
7272
| [SIFT](http://corpus-texmex.irisa.fr/) | 128 | 1,000,000 | 10,000 | 100 | Euclidean | [HDF5](http://ann-benchmarks.com/sift-128-euclidean.hdf5) (501MB) |
7373
| [Last.fm](https://github.com/erikbern/ann-benchmarks/pull/91) | 65 | 292,385 | 50,000 | 100 | Angular | [HDF5](http://ann-benchmarks.com/lastfm-64-dot.hdf5) (135MB) |
74+
| [COCO-I2I](https://cocodataset.org/) | 512 | 113,287 | 10,000 | 100 | Angular | [HDF5](https://github.com/fabiocarrara/str-encoders/releases/download/v0.1.3/coco-i2i-512-angular.hdf5) (136MB) |
75+
| [COCO-T2I](https://cocodataset.org/) | 512 | 113,287 | 10,000 | 100 | Angular | [HDF5](https://github.com/fabiocarrara/str-encoders/releases/download/v0.1.3/coco-t2i-512-angular.hdf5) (136MB) |
7476

7577
Results
7678
=======

ann_benchmarks/datasets.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,25 @@ def dbpedia_entities_openai_1M(out_fn, n = None):
577577

578578
write_output(X_train, X_test, out_fn, "angular")
579579

580+
def coco(out_fn: str, kind: str):
581+
assert kind in ('t2i', 'i2i')
582+
583+
local_fn = "coco-clip-b16-512-features.hdf5"
584+
url = "https://github.com/fabiocarrara/str-encoders/releases/download/v0.1.3/%s" % local_fn
585+
download(url, local_fn)
586+
587+
with h5py.File(local_fn, "r") as f:
588+
img_X = f['img_feats'][:]
589+
590+
X_train, X_test = train_test_split(img_X, test_size=10_000)
591+
592+
if kind == 't2i':
593+
# there are 5 captions per image, take the first one
594+
txt_X = f['txt_feats'][::5]
595+
_, X_test = train_test_split(txt_X, test_size=10_000)
596+
597+
write_output(X_train, X_test, out_fn, "angular")
598+
580599

581600
DATASETS: Dict[str, Callable[[str], None]] = {
582601
"deep-image-96-angular": deep_image,
@@ -606,6 +625,8 @@ def dbpedia_entities_openai_1M(out_fn, n = None):
606625
"movielens1m-jaccard": movielens1m,
607626
"movielens10m-jaccard": movielens10m,
608627
"movielens20m-jaccard": movielens20m,
628+
"coco-i2i-512-angular": lambda out_fn: coco(out_fn, "i2i"),
629+
"coco-t2i-512-angular": lambda out_fn: coco(out_fn, "t2i"),
609630
}
610631

611632
DATASETS.update({

0 commit comments

Comments
 (0)