CIFAR-100のスーパークラスを調べた
こんにちは.
このブログを始めた当初は週一くらいのペースで更新するつもりでしたが, 先週はうっかり更新を忘れていました. まぁ気楽に行きましょう.
ChainerからCIFAR-100を読み込む
ChainerにはMNISTやCIFAR-10,CIFAR-100などといったよく使われているデータセットを読み込む機能が実装されています.
import chainer from chainer import datasets train, test = datasets.get_cifar100()
中身を覗いてみます.画像の出力にはOpenCVを使いました.
#さっきの続き import cv2 import numpy as np image = train[0][0] # trainの0番目の画像 label = train[0][1] # trainの0番目のラベル print label # 画素が0~1に正規化されているので255倍 cv2.imwrite("image.jpg", np.rollaxis(image, 0, 3) * 255)
以下の画像が出力されました.
なんでしょうか.牛ですかね.ラベルは19番でした.
CIFAR-100のスーパークラス
CIFAR-100は100クラスの画像データセットになっていますが, これは20のスーパークラスに分類されており, 各スーパークラスは5クラスが内包されています.
CIFAR-10 and CIFAR-100 datasets
ところがどっこい, Chainerのget_cifar100()から取得したデータにはこのスーパークラスの情報が(多分)含まれていません. 私はデータがスーパークラスに分かれた状態のデータセットが欲しかったので, なんとかスーパークラスにに振り分ける方法はないものか,と調べてみたものの結局見つからず…….
手動でクラスを調べてやりましたよ
OpenCVで画像を可視化して,0番がリンゴで1番が観賞魚で……と一枚一枚確認していきました. 以下に私の努力の成果(笑)を示します.間違いがあったらごめんなさい.
Superclass | Classes |
---|---|
aquatic mammals | beaver(4), dolphin(30), otter(55), seal(72), whale(95) |
fish | aquarium fish(1), flatfish(32), ray(67), shark(73), trout(91) |
flowers | orchids(54), poppies(62), roses(70), sunflowers(82), tulips(92) |
food containers | bottles(9), bowls(10), cans(16), cups(28), plates(61) |
fruit and vegetables | apples(0), mushrooms(51), oranges(53), pears(57), sweet peppers(83) |
household electrical devices | clock(22), computer keyboard(39), lamp(40), telephone(86), television(97) |
household furniture | bed(5), chair(20), couch(25), table(84), wardrobe(94) |
insects | bee(6), beetle(7), butterfly(14), caterpillar(18), cockroach(24) |
large carnivores | bear(3), leopard(42), lion(43), tiger(88), wolf(97) |
large man-made outdoor things | bridge(12), castle(17), house(37), road(68), skyscraper(76) |
large natural outdoor scenes | cloud(23), forest(33), mountain(49), plain(60), sea(71) |
large omnivores and herbivores | camel(15), cattle(19), chimpanzee(21), elephant(31), kangaroo(38) |
medium-sized mammals | fox(34), porcupine(63), possum(64), raccoon(66), skunk(75) |
non-insect invertebrates | crab(26), lobster(45), snail(77), spider(79), worm(99) |
people | baby(2), boy(11), girl(35), man(46), woman(98) |
reptiles | crocodile(27), dinosaur(29), lizard(44), snake(78), turtle(93) |
small mammals | hamster(36), mouse(50), rabbit(65), shrew(74), squirrel(80) |
trees | maple(47), oak(52), palm(56), pine(59), willow(96) |
vehicles 1 | bicycle(8), bus(13), motorcycle(48), pickup truck(58), train(90) |
vehicles 2 | lawn-mower(41), rocket(69), streetcar(81), tank(85), tractor(89) |
※かっこ内が0~99のラベル番号になります.