This repository introduces the open-source project dubbed Tencent ML-Images, which publishes
ML-Images: the largest open-source multi-label image database, including 17,609,752 training and 88,739 validation image URLs, which are annotated with up to 11,166 categories
Resnet-101 model: it is pre-trained on ML-Images, and achieves the top-1 accuracy 80.73% on ImageNet via transfer learning
Updates
[2019/12/26] Our manuscript of this open-source project has been accepted to IEEE Access (Journal, ArXiv). It presents more details of the database, the loss function, the training algorithm, and more experimental results.
[2018/12/19] We simplify the procedure of downloading images. Please see Download Images.
The image URLs of ML-Images are collected from ImageNet and Open Images.
Specifically,
Part 1: From the whole database of ImageNet, we adopt 10,706,941 training and 50,000 validation image URLs, covering 10,032 categories.
Part 2: From Open Images, we adopt 6,902,811 training and 38,739 validation image URLs, covering 1,134 unique categories (note that some other categories are merged with their synonymous categories from ImageNet).
Finally, ML-Images includes 17,609,752 training and 88,739 validation image URLs, covering 11,166 categories.
We find that massive urls provided by ImageNet have expired (please check the file List of all image URLs of Fall 2011 Release at http://image-net.org/download-imageurls). Thus, here we provide the original image IDs of ImageNet used in our database. One can obtain the training/validation images of our database through the following steps:
As shown above, one image corresponds to one row. The first term is the original image ID of ImageNet. The followed terms separated by space are the annotations. For example, “2367:1” indicates class 2367 and its confidence 1. Note that the class index starts from 0, and you can find the class name from the file data/dictionary_and_semantic_hierarchy.txt.
NOTE: We find that there are some repeated URLs in List of all image URLs of Fall 2011 Release of ImageNet, i.e., the image corresponding to one URL may be stored in multiple sub-folders with different image IDs. We manually check a few repeated images, and find the reason is that one image annotated with a child class may also be annotated with its parent class, then it is saved to two sub-folders with different image IDs. To the best of our knowledge, this point has never been claimed in ImageNet or any other place. If one want to use ImageNet, this point should be noticed.
Due to that, there are also a few repeated images in our database, but our training is not significantly influenced. In future, we will update the database by removing the repeated images.
As shown above, one image corresponds to one row. The first term is the image URL. The followed terms separated by space are the annotations. For example, “5193:0.9” indicates class 5193 and its confidence 0.9.
Download Images using URLs
We also provide the code to download images using URLs.
As train_urls_from_openimages.txt is very large, here we provide a tiny file train_urls_tiny.txt to demonstrate the downloading procedure.
cd data
./download_urls_multithreading.sh
A sub-folder data/images will be generated to save the downloaded jpeg images, as well as a file train_im_list_tiny.txt to save the image list and the corresponding annotations.
We build the semantic hiearchy of 11,166 categories, according to WordNet.
The direct parent categories of each class can be found from the file data/dictionary_and_semantic_hierarchy.txt. The whole semantic hierarchy includes 4 independent trees, of which
the root nodes are thing, matter, object, physical object and atmospheric phenomenon, respectively.
The length of the longest semantic path from root to leaf nodes is 16, and the average length is 7.47.
Since the image URLs of ML-Images are collected from ImageNet and Open Images, the annotations of ML-Images are constructed based on the
original annotations from ImageNet and Open Images. Note that the original annotations from Open Images are licensed by Google Inc. under CC BY-4.0. Specifically, we conduct the following steps to construct the new annotations of ML-Images.
For the 6,902,811 training URLs from Open Images, we remove the annotated tags that are out of the remained 1,134 categories.
According to the constructed semantic hierarchy of 11,166 categories, we augment the annotations of all URLs of ML-Images following the cateria that if one URL is annotated with category i, then all ancestor categories will also be annotated to this URL.
We train a ResNet-101 model based on the 6,902,811 training URLs from Open Images, with 1,134 outputs. Using this ResNet-101 model, we predict the tags from 1,134 categories for the 10,756,941 single-annotated image URLs from ImageNet. Consequently, we obtain a normalized co-occurrence matrix between 10,032 categories from ImageNet and 1,134 categories from Open Images. We can determine the strongly co-occurrenced pairs of categories. For example, category i and j are strongly co-occurrenced; then, if one image is annotated with category i, then category j should also be annotated.
The annotations of all URLs in ML-Images are stored in train_urls.txt and val_urls.txt.
Here we generate the tfrecords using the multithreading module. One should firstly split the file train_im_list_tiny.txt into multiple smaller files, and save them into the sub-folder data/image_lists/.
cd data
./tfrecord.sh
Multiple tfrecords (named like x.tfrecords) will saved to data/tfrecords/.
Before training, one should move the train and validation tfrecords to data/ml-images/train and data/ml-images/val, respectively.
Then,
./example/train.sh
Note: Here we only provide the training code in the single node single GPU framework, while our actual training on ML-Images is based on an internal distributed training framework (not released yet). One could modify the training code to the distributed framework following distributed tensorFlow.
One should firstly download the ImageNet (ILSVRC2012) database, then prepare the tfrecord file using tfrecord.sh.
Then, you can finetune the ResNet-101 model on ImageNet as follows, with the checkpoint pre-trained on ML-Images.
Here we provide a demo for single-label image-classification, using the checkpoint ckpt-resnet101-mlimages-imagenet downloaded above.
./example/image_classification.sh
The prediction will be saved to label_pred.txt. If one wants to recognize other images, data/im_list_for_classification.txt should be modified to include the path of these images.
The annotations of images are licensed by Tencent under CC BY 4.0 license.
The contents of this repository, including the codes, documents and checkpoints, are released under an BSD 3-Clause license. Please refer to LICENSE for more details.
If there is any concern about the copyright of any image used in this project, please email us.
If any content of this project is utilized in your work (such as data, checkpoint, code, or the proposed loss or training algorithm), please cite the following manuscript.
@article{tencent-ml-images-2019,
title={Tencent ML-Images: A Large-Scale Multi-Label Image Database for Visual Representation Learning},
author={Wu, Baoyuan and Chen, Weidong and Fan, Yanbo and Zhang, Yong and Hou, Jinlong and Liu, Jie and Zhang, Tong},
journal={IEEE Access},
volume={7},
year={2019}
}
Tencent ML-Images
This repository introduces the open-source project dubbed Tencent ML-Images, which publishes
Updates
Contents
Dependencies
Data
Train
Results
Copyright
Citation
Dependencies
Data
[back to top]
Image Source
[back to top]
The image URLs of ML-Images are collected from ImageNet and Open Images. Specifically,
Finally, ML-Images includes 17,609,752 training and 88,739 validation image URLs, covering 11,166 categories.
Download Images
[back to top]
Due to the copyright, we cannot provide the original images directly. However, one can obtain all images of our database using the following files:
Download Images from ImageNet
We find that massive urls provided by ImageNet have expired (please check the file
List of all image URLs of Fall 2011 Releaseat http://image-net.org/download-imageurls). Thus, here we provide the original image IDs of ImageNet used in our database. One can obtain the training/validation images of our database through the following steps:train_image_id_from_imagenet.txtandval_image_id_from_imagenet.txtThe format of
train_image_id_from_imagenet.txtis as follows:As shown above, one image corresponds to one row. The first term is the original image ID of ImageNet. The followed terms separated by space are the annotations. For example, “2367:1” indicates class 2367 and its confidence 1. Note that the class index starts from 0, and you can find the class name from the file data/dictionary_and_semantic_hierarchy.txt.
NOTE: We find that there are some repeated URLs in
List of all image URLs of Fall 2011 Releaseof ImageNet, i.e., the image corresponding to one URL may be stored in multiple sub-folders with different image IDs. We manually check a few repeated images, and find the reason is that one image annotated with a child class may also be annotated with its parent class, then it is saved to two sub-folders with different image IDs. To the best of our knowledge, this point has never been claimed in ImageNet or any other place. If one want to use ImageNet, this point should be noticed. Due to that, there are also a few repeated images in our database, but our training is not significantly influenced. In future, we will update the database by removing the repeated images.Download Images from Open Images
The images from Open Images can be downloaded using URLs. The format of
train_urls_from_openimages.txtis as follows:As shown above, one image corresponds to one row. The first term is the image URL. The followed terms separated by space are the annotations. For example, “5193:0.9” indicates class 5193 and its confidence 0.9.
Download Images using URLs
We also provide the code to download images using URLs. As
train_urls_from_openimages.txtis very large, here we provide a tiny file train_urls_tiny.txt to demonstrate the downloading procedure.A sub-folder
data/imageswill be generated to save the downloaded jpeg images, as well as a filetrain_im_list_tiny.txtto save the image list and the corresponding annotations.Semantic Hierarchy
[back to top]
We build the semantic hiearchy of 11,166 categories, according to WordNet. The direct parent categories of each class can be found from the file data/dictionary_and_semantic_hierarchy.txt. The whole semantic hierarchy includes 4 independent trees, of which the root nodes are
thing,matter,object, physical objectandatmospheric phenomenon, respectively. The length of the longest semantic path from root to leaf nodes is 16, and the average length is 7.47.Annotations
[back to top]
Since the image URLs of ML-Images are collected from ImageNet and Open Images, the annotations of ML-Images are constructed based on the original annotations from ImageNet and Open Images. Note that the original annotations from Open Images are licensed by Google Inc. under CC BY-4.0. Specifically, we conduct the following steps to construct the new annotations of ML-Images.
The annotations of all URLs in ML-Images are stored in
train_urls.txtandval_urls.txt.Statistics
[back to top]
The main statistics of ML-Images are summarized in ML-Images.
Note: Trainable class indicates the class that has over 100 train images.
The number of images per class and the histogram of the number of annotations in training set are shown in the following figures.
Train
[back to top]
Prepare the TFRecord File
[back to top]
Here we generate the tfrecords using the multithreading module. One should firstly split the file
train_im_list_tiny.txtinto multiple smaller files, and save them into the sub-folderdata/image_lists/.Multiple tfrecords (named like
x.tfrecords) will saved todata/tfrecords/.Pretrain on ML-Images
[back to top]
Before training, one should move the train and validation tfrecords to
data/ml-images/trainanddata/ml-images/val, respectively. Then,Note: Here we only provide the training code in the single node single GPU framework, while our actual training on ML-Images is based on an internal distributed training framework (not released yet). One could modify the training code to the distributed framework following distributed tensorFlow.
Finetune on ImageNet
[back to top]
One should firstly download the ImageNet (ILSVRC2012) database, then prepare the tfrecord file using tfrecord.sh. Then, you can finetune the ResNet-101 model on ImageNet as follows, with the checkpoint pre-trained on ML-Images.
Checkpoints
[back to top]
Please download above two checkpoints and move them into the folder
checkpoints/, if you want to extract features using them.Single-Label Image Classification
Here we provide a demo for single-label image-classification, using the checkpoint
ckpt-resnet101-mlimages-imagenetdownloaded above.The prediction will be saved to
label_pred.txt. If one wants to recognize other images,data/im_list_for_classification.txtshould be modified to include the path of these images.Feature Extraction
[back to top]
Results
[back to top]
The retults of different ResNet-101 checkpoints on the validation set of ImageNet (ILSVRC2012) are summarized in the following table.
on Val 224
on Val 224
on Val 299
on Val 299
Note:
Copyright
[back to top]
The annotations of images are licensed by Tencent under CC BY 4.0 license. The contents of this repository, including the codes, documents and checkpoints, are released under an BSD 3-Clause license. Please refer to LICENSE for more details.
If there is any concern about the copyright of any image used in this project, please email us.
Citation
[back to top]
If any content of this project is utilized in your work (such as data, checkpoint, code, or the proposed loss or training algorithm), please cite the following manuscript.