如何获取图像格式的ILSVRC12数据或如何创建ilsvrc12_val_lmdb? [英] How do I get ILSVRC12 data in image format or how to create ilsvrc12_val_lmdb?

查看:315
本文介绍了如何获取图像格式的ILSVRC12数据或如何创建ilsvrc12_val_lmdb?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Caffe中运行imagenet示例.在此( https://github.com/BVLC/caffe/tree/master /examples/imagenet )页面,他们说

I am trying to run imagenet example in Caffe. In this(https://github.com/BVLC/caffe/tree/master/examples/imagenet) page they say

We assume that you already have downloaded the ImageNet training data and validation data, and they are stored on your disk like:

/path/to/imagenet/train/n01440764/n01440764_10026.JPEG
/path/to/imagenet/val/ILSVRC2012_val_00000001.JPEG

我在哪里可以找到这些数据?

Where do I find this data?

推荐答案

这有点过程.
1.转到 imagenet的下载页面,然后选择下载图像URL".
2.从页面底部的链接下载图像URL列表,例如,秋天2011年榜单.
3.从图像的URL下载图像(这可能需要几天时间).

It's a bit of a process.
1. Got to imagenet's download page and select "Download Image URLs".
2. Download the image URL list from the links at the bottom of the page, e.g., fall 2011's list.
3. Download the images from their URLs (this may take a few days).

请注意,某些网址(我上次检查时约为5%)不再有效,并且将返回"stub" flickr图片.

Note that some of the URLs (~5% last time I checked) are no longer valid, and will return a "stub" flickr image.

这是我用来使用

Here's a perl script I used to download the images using convert utility:

#!/usr/bin/perl

use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
use File::Copy;

my $base = "/path/to/imagenet/train/";

open my $fh, '/path/to/train_image_urls.txt' or die "Cannot not open url list: $!";
while( my $line = <$fh> )  {
    # a line in the url list looks like:
    # n00005787_13    http://www.powercai.net/Photo/UploadPhotos/200503/20050307172201492.jpg
    chomp($line);
    if ( $line =~ /^(n\d+)_(\d+)\s+(\S.+)$/ ) {
      my $type = $1;
      my $filename = $1 . "_" . $2;
      my $url = $3;
      my $dst = "$base/$type/$filename" . ".JPEG";
      if (! -d $base.$type ) {
        mkdir($base.$type)
      }
      my $convertCmd = "convert \"$url\" $dst";
      if ( system( $convertCmd ) == 0 ) {
         if ( -e $dst ) {
           my $size = -s $dst;
           # check that image is not a "flickr" stub:
           if ( $size == 24921 || $size == 6898 ) {
              open( my $FILE, $dst );
              binmode($FILE);
              my $md5sum = Digest::MD5->new->addfile($FILE)->hexdigest;
              if ( $md5sum eq "513dd080b92472dab22ad3e09f58f1af" || $md5sum == "ed15d4fe8b5680d1b3e01c0d2778d145" ) {
                print $invl "$dst\n";
                move( $dst, $base . "../invalid/" );
              }
              close($FILE);
           }
         }
      } else {
        # invalid image file
      }
    } else {
      # error downloading an image
    }
}
close $fh;
exit(0);

这篇关于如何获取图像格式的ILSVRC12数据或如何创建ilsvrc12_val_lmdb?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆