Giter Site home page Giter Site logo

tencent-ml-images's Introduction

Tencent ML-Images

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.

Contents

[back to top]

[back to top]

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.

[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:

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:

  • Download the whole database of ImageNet
  • Extract the training/validation images using the image IDs in train_image_id_from_imagenet.txt and val_image_id_from_imagenet.txt

The format of train_image_id_from_imagenet.txt is as follows:

...
n04310904/n04310904_8388.JPEG   2367:1  2172:1  1831:1  1054:1  1041:1  865:1   2:1
n11753700/n11753700_1897.JPEG   5725:1  5619:1  5191:1  5181:1  5173:1  5170:1  1042:1  865:1   2:1
...

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.

The images from Open Images can be downloaded using URLs. The format of train_urls_from_openimages.txt is as follows:

...
https://c4.staticflickr.com/8/7239/6997334729_e5fb3938b1_o.jpg  3:1  5193:0.9  5851:0.9 9413:1 9416:1
https://c2.staticflickr.com/4/3035/3033882900_a9a4263c55_o.jpg  1053:0.8  1193:0.8  1379:0.8
...

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.

[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 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.

[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.

  • 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.

[back to top]

The main statistics of ML-Images are summarized in ML-Images.

# Train images # Validation images # Classes # Trainable Classes # Avg tags per image # Avg images per class
17,609,752 88,739 11,166 10,505 8.72 13,843

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.

GitHub GitHub

[back to top]

[back to top]

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/.

[back to top]

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.

[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.

./example/finetune.sh

[back to top]

  • ckpt-resnet101-mlimages (link1, link2): pretrained on ML-Images
  • ckpt-resnet101-mlimages-imagenet (link1, link2): pretrained on ML-Images and finetuned on ImageNet (ILSVRC2012)

Please download above two checkpoints and move them into the folder checkpoints/, if you want to extract features using them.

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.

[back to top]

./example/extract_feature.sh

[back to top]

The retults of different ResNet-101 checkpoints on the validation set of ImageNet (ILSVRC2012) are summarized in the following table.

Checkpoints Train and finetune setting Top-1 acc
on Val 224
Top-5 acc
on Val 224
Top-1 acc
on Val 299
Top-5 acc
on Val 299
MSRA ResNet-101 train on ImageNet 76.4 92.9 -- --
Google ResNet-101 ckpt1 train on ImageNet, 299 x 299 -- -- 77.5 93.9
Our ResNet-101 ckpt1 train on ImageNet 77.8 93.9 79.0 94.5
Google ResNet-101 ckpt2 Pretrain on JFT-300M, finetune on ImageNet, 299 x 299 -- -- 79.2 94.7
Our ResNet-101 ckpt2 Pretrain on ML-Images, finetune on ImageNet 78.8 94.5 79.5 94.9
Our ResNet-101 ckpt3 Pretrain on ML-Images, finetune on ImageNet 224 to 299 78.3 94.2 80.73 95.5
Our ResNet-101 ckpt4 Pretrain on ML-Images, finetune on ImageNet 299 x 299 75.8 92.7 79.6 94.6

Note:

  • if not specified, the image size in training/finetuning is 224 x 224.
  • finetune on ImageNet from 224 to 299 means that the image size in early epochs of finetuning is 224 x 224, then 299 x 299 in late epochs.
  • Top-1 acc on Val 224 indicates the top-1 accuracy on 224 x 224 validation images.

[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.

[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.

@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's People

Contributors

0xflotus avatar wubaoyuan avatar yanbofan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tencent-ml-images's Issues

Category mapping from Open Images to WordNet

Thank you for the great work!
The paper says

We firstly map the categories from both ImageNet and Open Images to the WordIDs in WordNet. According to the WordIDs, we construct the semantic hierarchy among these 11,166 categories

How did you make the mapping? And, is the mapping list available in this repository?

imagenet数据集

请问imagenet数据集对应的是其中的所有数据么?还是只有ISLVRC 2012,能提供下确切的数据版本么?

How does you generate the confidence score?

Hi:
Great thanks for releasing such large dataset. I'm wondering how did you generate the confidence score? Is it similar to openimages, where the confidence is predicted by Google cloud vision API?

Thanks.

训练的时候train_accuracy一直下降

我训练自己的模型,但是我只用了train文件夹进行训练,没有创建val文件夹也没有对应的文件,可是查看tensorboard有一个train_accuracy曲线,从1开始往下掉,到30多万次的时候降到了0.6几,请问这是怎么回事啊

数据集图像

问题1:多少张图像链接在train_urls.txt里面?我下载train_urls.txt之后,看了一下,有17609808行,但是你们的文档说应该有17,609,752张图像才对。请问是我下载过程中出问题了,还是文档出现了错误?
问题2:train_urls.txt中的图像和train_urls_and_index_from_imagenet.txt中的图像到底是什么关系?没看懂文档什么意思。如果train_urls.txt中的链接失效了,应该去train_urls_and_index_from_imagenet.txt中找相应的有效链接吗?也就是我们需要自己根据下载时的情况监测链接是否有效?
谢谢

Finetune on my own multi-label dataset loss goes up

I build my own multi-label dataset, which have 746 categories. And I restore from ckpt-resnet101-mlimages. But when I use finetune.py my loss goes up. Any ideas?
env: win7, python3, tf: 1.10, gpu: tesla k80
init-lr: 0.001, lr_decay_step: 5000

snipaste_2019-01-17_20-16-45
snipaste_2019-01-17_20-26-20

I had checked my data. Seems no problem.
snipaste_2019-01-17_14-23-26

Download shell get more invalid urls

Hi,

I am downloading the train datasets thses days. As for its a big data, I divided all urls into 34 parts. So every part may contains 20w images. Then I used your shell to download every part. But a strange thing happened, the number of invalid urls add the number of images is more than 20w. I checked it in one part, the invalid urls contain some image is downloaded successfully. I wonder have you met this situation?

[bug] duplicate image names can cause overwrite problem

In the download script, saving images with path "save_dir + im_name" will overwrite any images with same name.

For example:
http://i.ytimg.com/vi/6rMwgpPSJyU/3.jpg 8486:1 8479:1 8473:1 5175:1 5170:1 1042:1 865:1 2:1

http://web.mit.edu/admissions/blogs/photos/jenny-whitesox/3.jpg 10591:1 1914:1 1897:1 1829:1 1054:1 1041:1 865:1 2:1

http://bp2.blogger.com/_u3lFqBksmrE/Rgoqe1STw-I/AAAAAAAACKI/sl1nY4Q4RAc/s400/3.jpg 9199:1 9170:1 8585:1 5177:1 5170:1 1042:1 865:1 2:1
....

they have the same image name.

Training epoch of ML-Images pretrain

Hi, would you mind sharing the training setting of ML-Images pretrain model?
I check the setting in example/train.sh and found that the BATCHSIZE is 1. There maybe something wrong in the example/train.sh.

Thanks!

An Error when load the pretrained model?

when I load the pretrained model trained on ml-images(ckpt-resnet101-mlimages), an error occur as follow:

KeyError: u'TfplusAllreduce

my loaded code is:
saver = tf.train.import_meta_graph("./pretrain_model/ckpt-resnet101-mlimages/model.ckpt.meta")
saver.restore(sess, "./pretrain_model/ckpt-resnet101-mlimages")

my tensorflow version is 1.10.0

thank you for your advision, sincerely!

分类数量

想问下这个不是最大支持1w多分类吗,有无这块的代码和例子哈

Image cannot be downloaded correctly

when i ran the script to download image from URL that listed in train_url_tiny.txt, i got the bad image.
im_0
when i copied the URL to web browser,i can see the correct image。
Do you know the cause of the problem?

About finetune

Thank you for your contribution. When finetune i find that the ImageNet dataset is too big. Can I build a multi-label data for finetune ?

不管是train还是finetune,咋都不把跑验证集的加上去。

腾讯开源代码质量堪忧啊。
还有一个问题就是,README写的够烂,踩了很多坑,train.py和finetune.py能运行tfrecord文件都不一样,一个多标签,一个多分类的代码,README里面完全没提。
另外tf1.6也不是所有的都能跑,根据cudnn的版本才行,这个也没提。

the slow down

many urls were connection timeout, and it has a slow download speed, can I gei the original image quickly?
thank you~!

图像数据集

问题1:多少张图像链接在train_urls.txt里面?我下载train_urls.txt之后,看了一下,有17609808行,但是你们的文档说应该有17,609,752张图像才对。请问是我下载过程中出问题了,还是文档出现了错误?
问题2:train_urls.txt中的图像和train_urls_and_index_from_imagenet.txt中的图像到底是什么关系?没看懂文档什么意思。如果train_urls.txt中的链接失效了,应该去train_urls_and_index_from_imagenet.txt中找相应的有效链接吗?也就是我们需要自己根据下载时的情况监测链接是否有效?
谢谢

Finetune Error

finetune报错如下
image
尝试了好久没有解决。。不知道会是何原因呢。。

我的环境是python3+tensorflow1.10.1

imagenet数据集

请问imagenet数据集对应的是其中的所有数据么?还是只有ISLVRC 2012,能提供下确切的数据版本么?

Tag Augmentation of Images

Thank you for the great work!
1、The paper says
Note that each image from ImageNet-11K is annotated by a single tag.

Is each image just annotated by the leaf tag?

2、The paper says
Besides, as some categories from Open Images are similar to or synonyms of above 10,032 categories, we merge these redundant categories into unique categories. If all tags of one image are removed, then this image is also abandoned. Consequently, 6,902,811 training images and 38,739 validation images are remained, covering 1,134 unique categories .

Is 6,902,811 training images and 38,739 validation images in 1,134 unique categories, which is meaning if any tag of a image from Open Images is similar to or synonyms of above 10,032 categories, then the image will be removed, or in 1,134 plus 10,032 unique categories?

thanks for your reply.

Train with multi gpus in one node?

sir,
Can I train with multi gpus ? Just I modify the the code in train.py

config.gpu_options.visible_device_list = str(FLAGS.train_gpus)

FLAGS.train_gpus='0,1,2,3,4,5,6,7'

Does if affect the loss function computing or the final model's effect?

Is it a normal training process with this modified?

why I set the visible_device_list in config, but only the first gpu is computing(99% using),other gpus is sleeping?

Thank you very much!

will you provide one multi-gpu version for train? I think I should modify your estimatorSpec or resnet_model_fn code, it is trouble for me specially because I am not very familiar with tensorflow.

About image processing

Hi

I have some question about image normalization. as I notice the preprocess way is not like some standard resnet .

if we have an image in rgb order with dataformat of int8 ranging from 0~255. so are we suppose to do the nomalization as below:

image = ((image/255) -0.5 ) * 2

Thanks

About the loss function?

Thank you for your explanation for the loss function, do you have any supplement material about the loss?

I am curious about some code in the loss function, and I found some variables were not changed at all after computation, eg.

non_neg_mask = tf.fill(tf.shape(labels), -1.0, name='non_neg')
non_neg_mask = tf.cast(tf.not_equal(labels, non_neg_mask), tf.float32)

because all the value in labels is '0' or '1', and then , the non_neg_mask will be assigned with '1' all ?

And the same case with the variable pos_count, neg_count,

because the pos_count and neg_count were initialized with '0' all, and the pos_curr_count and neg_curr_count were complementary at the same position, then, is pos_count equal to pos_curr_count ,
and neg_count equal to neg_curr_count * neg_select, after follow computation?

133 pos_count = tf.assign_sub(
134 tf.assign_add(pos_count, pos_curr_count),
135 tf.multiply(pos_count, neg_curr_count))
136 neg_count = tf.assign_sub(
137 tf.assign_add(neg_count, tf.multiply(neg_curr_count, neg_select)),
138 tf.multiply(neg_count, pos_curr_count))

thank you!

Suggestion: Add requirements.txt

Didn't find requirements.txt in the repository.
I had to install the following dependencies to run example:

numpy==1.15.4
opencv==3.4.2
tensorflow-gpu==1.12.0

It should be more convenient to add dependencies explicitly to requirements file

Some question about codes and paper

sorry to bother you, I have two questions:

  1. when calculating loss, the first step is "a. get loss coeficiente" and the corresponding codes as follows:
    image
    Whether it refers to r in loss function:
    image
    But the explanation of r is not matched with these codes,
    image
    So, can you tell me what is these codes? Especially for pos_loss_coef(0.01), neg_loss_coef(8) and loss_coef...

  2. In train.py, record_parser_fn make image like
    image = image_preprocess.preprocess_image(image=image, output_height=FLAGS.image_size, output_width=FLAGS.image_size, object_cover=0.7, area_cover=0.7, is_training=is_training,, bbox=bbox)
    But in finetune.py, record_parser_fn make image like
    image = image_preprocess.preprocess_image(image=image, output_height=FLAGS.image_size, output_width=FLAGS.image_size, object_cover=0.0, area_cover=0.05, is_training=is_training,, bbox=bbox)
    Can you tell me why differ in object_cover and area_cover?

Thanks!

Some image index is Repeated

Hi,

These days I try to download the data as your instruction. As for I already have the imagenet dataset, I just make a map with yout imagenet_index and my imagenet dataset. But after I have done the map, I find some imagenet index is repeated in your txt file. I wonder is it a right thing?

Error when extracting features

I downloaded ckpt-resnet101-mlimages checkpoint and used the extract_feature.py script to extarct features as follows:

python extract_feature.py --resnet_size=101 --data_format='NCWH' --visiable_gpu=0 --pretrain_ckpt=checkpoints/ckpt-resnet101-mlimages/model.ckpt --result=result.txt --images=imglist.txt

But I got the following error:

InvalidArgumentError (see above for traceback): Restoring from checkpoint failed. This is most likely due to a mismatch between the current graph and the graph from the checkpoint. Please ensure that you have not altered the graph expected based on the checkpoint. Original error:

Assign requires shapes of both tensors to match. lhs shape= [2048,1000] rhs shape= [2048,11166]
[[node save/Assign_6 (defined at extract_feature.py:67) ]]

So many image links are invalid

I run the mutithreading shell in windows with virtual linux env, but the terminal output shows that so many image urls are invalid. 1218 images in total, but i just download 228.
image
In addtion,in 228 downloaded images, some images are still invalid.
image
how can I solve this problem and get enough images to do some research.

多labels

你好,我看到有一个single label的例子,要是多labels如何使用

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.