這是一個過程。
1.到imagenet's download頁面,選擇「下載圖片網址」。
2.從頁面底部的鏈接下載圖片URL列表,例如fall 2011's list。
3.從網址下載圖片(這可能需要幾天)。
請注意,某些網址(上次檢查時約5%)不再有效,並且會返回一個「存根」flickr圖片。
下面是使用convert
utility一個Perl腳本,我用來下載圖片:
#!/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);
https://stackoverflow.com/questions/47295025/valueerror-at-image-tensor-tensoractivation-5-softmax0-shape -4-dtyp/47300005?noredirect = 1#comment81555441_47300005任何建議 –