├── README.md ├── camera_interface.lua ├── deepdream.lua ├── download_net.sh ├── imagenet_resnet.lua ├── test_display_camera.lua ├── test_single.lua └── test_single_resnet.lua /README.md: -------------------------------------------------------------------------------- 1 | # DEEP PI 2 | 3 | ## An example of running deep neural-net image classifier on Raspberry PI 4 | 5 | ### Installing torch on Raspbian 6 | If you are using minimal version of Raspbian, you will need to install several packages first: 7 | ``` 8 | sudo apt-get install -y build-essential gcc g++ curl cmake libreadline-dev libjpeg-dev libpng-dev ncurses-dev imagemagick gfortran libopenblas-base libopenblas-dev 9 | ``` 10 | The clone [torch](http://torch.ch/) distribution: 11 | ``` 12 | git clone https://github.com/torch/distro.git ~/torch --recursive 13 | ``` 14 | And start building (takes several hours on Raspberry PI B+: 15 | ``` 16 | cd ~/torch 17 | ./install.sh 18 | ``` 19 | If you encounter following error: 20 | ```...In function ‘THByteVector_vectorDispatchInit’: /home/pi/torch/pkg/torch/lib/TH/generic/simd/simd.h:64:3: error: impossible constraint in ‘asm’ ...``` 21 | it means that you are building on a cpu without NEON extension (the kind Raspberry PI Version A & B have). You will need to checkout latest version of torch and disable submodule update command in install.sh script ( comment out line 45 in ~/torch/install.sh ) and then update torch torch: 22 | ``` 23 | cd ~/torch/pkg/torch/ 24 | git checkout master 25 | git pull 26 | ``` 27 | and run `./install.sh` script again. 28 | 29 | After ./install.sh is finished - it will ask if you want to update .bashrc to include call to initialize torch environment every time you login. If you don't want it, you will have to execute command `. ~/torch/install/bin/torch-activate` before you will be able to lauch th. 30 | 31 | ### Alternative way to install torch on Raspbian, using precompiled blob 32 | I created an archive of torch installation compiled for Raspberry PI B+ , running Raspbian 8 33 | You can download it here : https://github.com/vfonov/deep-pi/releases/download/v1/torch_intstall_raspbian_arm6l_20161218.tar.gz 34 | Copy file to /home/pi, then run `tar zxf torch_intstall_raspbian_arm6l_20161218.tar.gz` - this will create torch subdirectory that will include only precompiled binaries. To activate it add `. torch/install/bin/torch-activate` in the end of the `~/.bashrc` file. 35 | 36 | ### Running MNIST digit classifier from torch demos 37 | You can install various torch example from https://github.com/torch/demos, here is an output from MNIST digit classieifer training session: 38 | 39 | ``` 40 | pi:~/src/demos/train-a-digit-classifier $ th train-on-mnist.lua 41 | set nb of threads to 4 42 | using model: 43 | nn.Sequential { 44 | [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> (9) -> (10) -> output] 45 | (1): nn.SpatialConvolutionMM(1 -> 32, 5x5) 46 | (2): nn.Tanh 47 | (3): nn.SpatialMaxPooling(3x3, 3,3, 1,1) 48 | (4): nn.SpatialConvolutionMM(32 -> 64, 5x5) 49 | (5): nn.Tanh 50 | (6): nn.SpatialMaxPooling(2x2, 2,2) 51 | (7): nn.Reshape(576) 52 | (8): nn.Linear(576 -> 200) 53 | (9): nn.Tanh 54 | (10): nn.Linear(200 -> 10) 55 | } 56 | only using 2000 samples to train quickly (use flag -full to use 60000 samples) 57 | loading only 2000 examples 58 | done 59 | loading only 1000 examples 60 | done 61 | on training set: 62 | online epoch # 1 [batchSize = 10] 63 | [===================>.................... 471/2000 ....................................] ETA: 2m20s | Step: 92ms 64 | ``` 65 | Overall it is about 5 times slower then running the same example on a desktop with Core i5 @ 3.30GHz without using GPU. 66 | 67 | ### Installing deep-pi 68 | ``` 69 | git clone https://github.com/vfonov/deep-pi 70 | ``` 71 | After that you can launch `download_net.sh` script to download the pretrained NIN network ( based on https://gist.github.com/szagoruyko/0f5b4c5e2d2b18472854 ) to the `/home/pi` path. **WARNING** pretrained network is 33Mb file! 72 | 73 | 74 | #### Running 75 | To run on a single image: `th test_single.lua ` 76 | To run continious classification using frames from camera ( I recommend using external USB camera) : 77 | ``` 78 | nohup th -ldisplay.start 8000 0.0.0.0 & 79 | th camera_interface.lua 80 | ``` 81 | Then open web browser and point to to location http://your.raspberry.ip:8000 - replace your.raspberry.ip with IP address that your Raspberry PI is configured to use. 82 | 83 | #### Setup 84 | ![Camera and test object](https://cloud.githubusercontent.com/assets/628822/21299836/637e738a-c56d-11e6-80a4-c20605527d89.jpg) 85 | 86 | #### Output 87 | ![Example 1](https://cloud.githubusercontent.com/assets/628822/21299835/637e6700-c56d-11e6-9c01-8e600417ac4d.jpg) 88 | 89 | ![Example 2](https://cloud.githubusercontent.com/assets/628822/21299834/637e11ce-c56d-11e6-82e1-c78ebf69004b.jpg) 90 | 91 | ![Example 3](https://cloud.githubusercontent.com/assets/628822/21299833/637df9b4-c56d-11e6-8f06-6c4e22f45957.jpg) 92 | 93 | -------------------------------------------------------------------------------- /camera_interface.lua: -------------------------------------------------------------------------------- 1 | -- useOpenCV=true 2 | require 'nn' 3 | require 'image' 4 | require 'camera' -- for camera 5 | display = require 'display' -- for displaying 6 | 7 | 8 | local display_sample_in={} 9 | local display_output={} 10 | 11 | torch.setdefaulttensortype('torch.FloatTensor') 12 | 13 | -- load pre-trained model 14 | local prefix=os.getenv("HOME") 15 | 16 | local t = torch.Timer() 17 | local m=torch.load(prefix..'nin_bn_final_arm.t7') 18 | print(string.format("loading model:%.2fsec",t:time().real)) 19 | 20 | local model=m:unpack() 21 | 22 | -- add soft max layer, to ouput pseudo-probabilities 23 | model:add(nn.LogSoftMax()) 24 | -- switch model to evaluate mode 25 | model:evaluate() 26 | 27 | local classes=model.classes 28 | local words=torch.load(prefix..'words_1000_ascii.t7','ascii') 29 | 30 | local mean_std=model.transform 31 | 32 | -- input (from camera) 33 | local iW=320 34 | local iH=240 35 | 36 | -- output (for model) 37 | local oW=224 38 | local oH=224 39 | 40 | local topk=5 41 | 42 | -- parameters for cropping: 43 | local w1 = math.ceil((iW-oW)/2) 44 | local h1 = math.ceil((iH-oH)/2) 45 | 46 | local cam = image.Camera {idx=0,width=iW,height=iH} 47 | 48 | -- starting infinte loop 49 | while true do 50 | 51 | local frame = cam:forward() 52 | local cropped = image.crop(frame, w1, h1, w1+oW, h1+oH) -- center patch 53 | 54 | -- perform normalization (remove pre-trained mean and std) 55 | for i=1,3 do 56 | cropped[{{i},{},{}}]:add(-mean_std.mean[i]) 57 | cropped[{{i},{},{}}]:div(mean_std.std[i]) 58 | end 59 | 60 | display_sample_in.win=display.image(cropped,display_sample_in) 61 | 62 | -- add a fake dimension of size 1 63 | cropped=cropped:view(1,3,oH,oW) 64 | local output=model:forward(cropped) 65 | 66 | -- extract topK classes: 67 | output=output:view(1000) 68 | local output_x, output_sorted = output:sort(1,true) 69 | probs=torch.exp(output_x) 70 | 71 | local out_text="" 72 | for i=1,topk do 73 | out_text=out_text..string.format(" %0.1f:%s
\n ",probs[i]*100,words[ classes[ output_sorted[i] ] ]) 74 | end 75 | 76 | display_output.win=display.text(out_text,display_output) 77 | -- print output in the terminal too 78 | print(out_text) 79 | 80 | end 81 | -------------------------------------------------------------------------------- /deepdream.lua: -------------------------------------------------------------------------------- 1 | require 'nn' 2 | require 'image' 3 | 4 | local n_iter = 10 5 | local n_end_layer = 5 -- max 43 for NiN 6 | local step_size=0.1 7 | local clip=true 8 | 9 | torch.setdefaulttensortype('torch.FloatTensor') 10 | 11 | local input_img='frame.jpg' -- 12 | -- load pre-trained model 13 | local prefix=os.getenv("HOME")..'/' 14 | 15 | local m=torch.load( prefix..'nin_bn_final_arm.t7' ) 16 | net=m:unpack() 17 | cls=m.classes 18 | 19 | 20 | local Normalization=net.transform 21 | 22 | function reduceNet(full_net, end_layer) 23 | local net = nn.Sequential() 24 | if end_layer>=#full_net then 25 | return full_net 26 | end 27 | for l=1,end_layer do 28 | net:add(full_net:get(l)) 29 | end 30 | --net:evaluate() 31 | net:training() 32 | return net 33 | end 34 | 35 | 36 | function make_step(net, img, clip, step_size) 37 | local step_size = step_size or 0.01 38 | local clip = clip 39 | if clip == nil then clip = true end 40 | 41 | local dst, g 42 | 43 | local cpu_img = img:view(1,img:size(1),img:size(2),img:size(3)) 44 | dst = net:forward(cpu_img) 45 | g = net:updateGradInput(cpu_img,dst):squeeze() 46 | 47 | -- apply normalized ascent step to the input image 48 | img:add(g:mul(step_size/torch.abs(g):mean())) 49 | 50 | if clip then 51 | local i 52 | for i=1,3 do 53 | local bias = Normalization.mean[i]/Normalization.std[i] 54 | img[{i,{},{}}]:clamp(-bias,1/Normalization.std[i]-bias) 55 | end 56 | end 57 | return img 58 | end 59 | 60 | function deepdream(net, base_img, iter_n, clip, step_size) 61 | local iter_n = iter_n 62 | local net = net 63 | local step_size = step_size 64 | 65 | local clip = clip 66 | -- prepare base images for all octaves 67 | local i 68 | 69 | local img=base_img:clone() 70 | 71 | for i=1,3 do 72 | img[{{i},{},{}}]:add(-Normalization.mean[i]) 73 | img[{{i},{},{}}]:div(Normalization.std[i]) 74 | end 75 | 76 | src = img 77 | 78 | for i=1,iter_n do 79 | src = make_step(net, src, clip, step_size) 80 | end 81 | 82 | -- returning the resulting image 83 | for i=1,3 do 84 | src[{i,{},{}}]:mul(Normalization.std[i]):add(Normalization.mean[i]) 85 | end 86 | 87 | return src 88 | end 89 | 90 | local t = torch.Timer() 91 | if n_end_layer then 92 | net = reduceNet(net, n_end_layer) 93 | end 94 | print(string.format("reducing net: %.2fsec",t:time().real)) 95 | 96 | print(net) 97 | -- 98 | img = image.load(input_img) 99 | -- 100 | local t = torch.Timer() 101 | x = deepdream(net, img, n_iter, clip, step_size) 102 | print(string.format("dreaming: %.2fsec",t:time().real)) 103 | --image.display(x) 104 | image.save('test.jpg',x) 105 | -------------------------------------------------------------------------------- /download_net.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | if [ ! -e $HOME/words_1000_ascii.t7 ];then 4 | echo Will download words_1000_ascii.t7 5 | curl -L https://github.com/vfonov/deep-pi/releases/download/v1/words_1000_ascii.t7 -o $HOME/words_1000_ascii.t7 6 | echo Downloaded $HOME/words_1000_ascii.t7 7 | fi 8 | 9 | if [ ! -e $HOME/nin_bn_final_arm.t7 ];then 10 | echo Will download nin_bn_final_arm.t7 , WARNING: 33.1MB! 11 | curl -L https://github.com/vfonov/deep-pi/releases/download/v1/nin_bn_final_arm.t7 -o $HOME/nin_bn_final_arm.t7 12 | echo Downloaded $HOME/nin_bn_final_arm.t7 13 | fi 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /imagenet_resnet.lua: -------------------------------------------------------------------------------- 1 | return{ 2 | 'tench, Tinca tinca', 3 | 'goldfish, Carassius auratus', 4 | 'great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias', 5 | 'tiger shark, Galeocerdo cuvieri', 6 | 'hammerhead, hammerhead shark', 7 | 'electric ray, crampfish, numbfish, torpedo', 8 | 'stingray', 9 | 'cock', 10 | 'hen', 11 | 'ostrich, Struthio camelus', 12 | 'brambling, Fringilla montifringilla', 13 | 'goldfinch, Carduelis carduelis', 14 | 'house finch, linnet, Carpodacus mexicanus', 15 | 'junco, snowbird', 16 | 'indigo bunting, indigo finch, indigo bird, Passerina cyanea', 17 | 'robin, American robin, Turdus migratorius', 18 | 'bulbul', 19 | 'jay', 20 | 'magpie', 21 | 'chickadee', 22 | 'water ouzel, dipper', 23 | 'kite', 24 | 'bald eagle, American eagle, Haliaeetus leucocephalus', 25 | 'vulture', 26 | 'great grey owl, great gray owl, Strix nebulosa', 27 | 'European fire salamander, Salamandra salamandra', 28 | 'common newt, Triturus vulgaris', 29 | 'eft', 30 | 'spotted salamander, Ambystoma maculatum', 31 | 'axolotl, mud puppy, Ambystoma mexicanum', 32 | 'bullfrog, Rana catesbeiana', 33 | 'tree frog, tree-frog', 34 | 'tailed frog, bell toad, ribbed toad, tailed toad, Ascaphus trui', 35 | 'loggerhead, loggerhead turtle, Caretta caretta', 36 | 'leatherback turtle, leatherback, leathery turtle, Dermochelys coriacea', 37 | 'mud turtle', 38 | 'terrapin', 39 | 'box turtle, box tortoise', 40 | 'banded gecko', 41 | 'common iguana, iguana, Iguana iguana', 42 | 'American chameleon, anole, Anolis carolinensis', 43 | 'whiptail, whiptail lizard', 44 | 'agama', 45 | 'frilled lizard, Chlamydosaurus kingi', 46 | 'alligator lizard', 47 | 'Gila monster, Heloderma suspectum', 48 | 'green lizard, Lacerta viridis', 49 | 'African chameleon, Chamaeleo chamaeleon', 50 | 'Komodo dragon, Komodo lizard, dragon lizard, giant lizard, Varanus komodoensis', 51 | 'African crocodile, Nile crocodile, Crocodylus niloticus', 52 | 'American alligator, Alligator mississipiensis', 53 | 'triceratops', 54 | 'thunder snake, worm snake, Carphophis amoenus', 55 | 'ringneck snake, ring-necked snake, ring snake', 56 | 'hognose snake, puff adder, sand viper', 57 | 'green snake, grass snake', 58 | 'king snake, kingsnake', 59 | 'garter snake, grass snake', 60 | 'water snake', 61 | 'vine snake', 62 | 'night snake, Hypsiglena torquata', 63 | 'boa constrictor, Constrictor constrictor', 64 | 'rock python, rock snake, Python sebae', 65 | 'Indian cobra, Naja naja', 66 | 'green mamba', 67 | 'sea snake', 68 | 'horned viper, cerastes, sand viper, horned asp, Cerastes cornutus', 69 | 'diamondback, diamondback rattlesnake, Crotalus adamanteus', 70 | 'sidewinder, horned rattlesnake, Crotalus cerastes', 71 | 'trilobite', 72 | 'harvestman, daddy longlegs, Phalangium opilio', 73 | 'scorpion', 74 | 'black and gold garden spider, Argiope aurantia', 75 | 'barn spider, Araneus cavaticus', 76 | 'garden spider, Aranea diademata', 77 | 'black widow, Latrodectus mactans', 78 | 'tarantula', 79 | 'wolf spider, hunting spider', 80 | 'tick', 81 | 'centipede', 82 | 'black grouse', 83 | 'ptarmigan', 84 | 'ruffed grouse, partridge, Bonasa umbellus', 85 | 'prairie chicken, prairie grouse, prairie fowl', 86 | 'peacock', 87 | 'quail', 88 | 'partridge', 89 | 'African grey, African gray, Psittacus erithacus', 90 | 'macaw', 91 | 'sulphur-crested cockatoo, Kakatoe galerita, Cacatua galerita', 92 | 'lorikeet', 93 | 'coucal', 94 | 'bee eater', 95 | 'hornbill', 96 | 'hummingbird', 97 | 'jacamar', 98 | 'toucan', 99 | 'drake', 100 | 'red-breasted merganser, Mergus serrator', 101 | 'goose', 102 | 'black swan, Cygnus atratus', 103 | 'tusker', 104 | 'echidna, spiny anteater, anteater', 105 | 'platypus, duckbill, duckbilled platypus, duck-billed platypus, Ornithorhynchus anatinus', 106 | 'wallaby, brush kangaroo', 107 | 'koala, koala bear, kangaroo bear, native bear, Phascolarctos cinereus', 108 | 'wombat', 109 | 'jellyfish', 110 | 'sea anemone, anemone', 111 | 'brain coral', 112 | 'flatworm, platyhelminth', 113 | 'nematode, nematode worm, roundworm', 114 | 'conch', 115 | 'snail', 116 | 'slug', 117 | 'sea slug, nudibranch', 118 | 'chiton, coat-of-mail shell, sea cradle, polyplacophore', 119 | 'chambered nautilus, pearly nautilus, nautilus', 120 | 'Dungeness crab, Cancer magister', 121 | 'rock crab, Cancer irroratus', 122 | 'fiddler crab', 123 | 'king crab, Alaska crab, Alaskan king crab, Alaska king crab, Paralithodes camtschatica', 124 | 'American lobster, Northern lobster, Maine lobster, Homarus americanus', 125 | 'spiny lobster, langouste, rock lobster, crawfish, crayfish, sea crawfish', 126 | 'crayfish, crawfish, crawdad, crawdaddy', 127 | 'hermit crab', 128 | 'isopod', 129 | 'white stork, Ciconia ciconia', 130 | 'black stork, Ciconia nigra', 131 | 'spoonbill', 132 | 'flamingo', 133 | 'little blue heron, Egretta caerulea', 134 | 'American egret, great white heron, Egretta albus', 135 | 'bittern', 136 | 'crane', 137 | 'limpkin, Aramus pictus', 138 | 'European gallinule, Porphyrio porphyrio', 139 | 'American coot, marsh hen, mud hen, water hen, Fulica americana', 140 | 'bustard', 141 | 'ruddy turnstone, Arenaria interpres', 142 | 'red-backed sandpiper, dunlin, Erolia alpina', 143 | 'redshank, Tringa totanus', 144 | 'dowitcher', 145 | 'oystercatcher, oyster catcher', 146 | 'pelican', 147 | 'king penguin, Aptenodytes patagonica', 148 | 'albatross, mollymawk', 149 | 'grey whale, gray whale, devilfish, Eschrichtius gibbosus, Eschrichtius robustus', 150 | 'killer whale, killer, orca, grampus, sea wolf, Orcinus orca', 151 | 'dugong, Dugong dugon', 152 | 'sea lion', 153 | 'Chihuahua', 154 | 'Japanese spaniel', 155 | 'Maltese dog, Maltese terrier, Maltese', 156 | 'Pekinese, Pekingese, Peke', 157 | 'Shih-Tzu', 158 | 'Blenheim spaniel', 159 | 'papillon', 160 | 'toy terrier', 161 | 'Rhodesian ridgeback', 162 | 'Afghan hound, Afghan', 163 | 'basset, basset hound', 164 | 'beagle', 165 | 'bloodhound, sleuthhound', 166 | 'bluetick', 167 | 'black-and-tan coonhound', 168 | 'Walker hound, Walker foxhound', 169 | 'English foxhound', 170 | 'redbone', 171 | 'borzoi, Russian wolfhound', 172 | 'Irish wolfhound', 173 | 'Italian greyhound', 174 | 'whippet', 175 | 'Ibizan hound, Ibizan Podenco', 176 | 'Norwegian elkhound, elkhound', 177 | 'otterhound, otter hound', 178 | 'Saluki, gazelle hound', 179 | 'Scottish deerhound, deerhound', 180 | 'Weimaraner', 181 | 'Staffordshire bullterrier, Staffordshire bull terrier', 182 | 'American Staffordshire terrier, Staffordshire terrier, American pit bull terrier, pit bull terrier', 183 | 'Bedlington terrier', 184 | 'Border terrier', 185 | 'Kerry blue terrier', 186 | 'Irish terrier', 187 | 'Norfolk terrier', 188 | 'Norwich terrier', 189 | 'Yorkshire terrier', 190 | 'wire-haired fox terrier', 191 | 'Lakeland terrier', 192 | 'Sealyham terrier, Sealyham', 193 | 'Airedale, Airedale terrier', 194 | 'cairn, cairn terrier', 195 | 'Australian terrier', 196 | 'Dandie Dinmont, Dandie Dinmont terrier', 197 | 'Boston bull, Boston terrier', 198 | 'miniature schnauzer', 199 | 'giant schnauzer', 200 | 'standard schnauzer', 201 | 'Scotch terrier, Scottish terrier, Scottie', 202 | 'Tibetan terrier, chrysanthemum dog', 203 | 'silky terrier, Sydney silky', 204 | 'soft-coated wheaten terrier', 205 | 'West Highland white terrier', 206 | 'Lhasa, Lhasa apso', 207 | 'flat-coated retriever', 208 | 'curly-coated retriever', 209 | 'golden retriever', 210 | 'Labrador retriever', 211 | 'Chesapeake Bay retriever', 212 | 'German short-haired pointer', 213 | 'vizsla, Hungarian pointer', 214 | 'English setter', 215 | 'Irish setter, red setter', 216 | 'Gordon setter', 217 | 'Brittany spaniel', 218 | 'clumber, clumber spaniel', 219 | 'English springer, English springer spaniel', 220 | 'Welsh springer spaniel', 221 | 'cocker spaniel, English cocker spaniel, cocker', 222 | 'Sussex spaniel', 223 | 'Irish water spaniel', 224 | 'kuvasz', 225 | 'schipperke', 226 | 'groenendael', 227 | 'malinois', 228 | 'briard', 229 | 'kelpie', 230 | 'komondor', 231 | 'Old English sheepdog, bobtail', 232 | 'Shetland sheepdog, Shetland sheep dog, Shetland', 233 | 'collie', 234 | 'Border collie', 235 | 'Bouvier des Flandres, Bouviers des Flandres', 236 | 'Rottweiler', 237 | 'German shepherd, German shepherd dog, German police dog, alsatian', 238 | 'Doberman, Doberman pinscher', 239 | 'miniature pinscher', 240 | 'Greater Swiss Mountain dog', 241 | 'Bernese mountain dog', 242 | 'Appenzeller', 243 | 'EntleBucher', 244 | 'boxer', 245 | 'bull mastiff', 246 | 'Tibetan mastiff', 247 | 'French bulldog', 248 | 'Great Dane', 249 | 'Saint Bernard, St Bernard', 250 | 'Eskimo dog, husky', 251 | 'malamute, malemute, Alaskan malamute', 252 | 'Siberian husky', 253 | 'dalmatian, coach dog, carriage dog', 254 | 'affenpinscher, monkey pinscher, monkey dog', 255 | 'basenji', 256 | 'pug, pug-dog', 257 | 'Leonberg', 258 | 'Newfoundland, Newfoundland dog', 259 | 'Great Pyrenees', 260 | 'Samoyed, Samoyede', 261 | 'Pomeranian', 262 | 'chow, chow chow', 263 | 'keeshond', 264 | 'Brabancon griffon', 265 | 'Pembroke, Pembroke Welsh corgi', 266 | 'Cardigan, Cardigan Welsh corgi', 267 | 'toy poodle', 268 | 'miniature poodle', 269 | 'standard poodle', 270 | 'Mexican hairless', 271 | 'timber wolf, grey wolf, gray wolf, Canis lupus', 272 | 'white wolf, Arctic wolf, Canis lupus tundrarum', 273 | 'red wolf, maned wolf, Canis rufus, Canis niger', 274 | 'coyote, prairie wolf, brush wolf, Canis latrans', 275 | 'dingo, warrigal, warragal, Canis dingo', 276 | 'dhole, Cuon alpinus', 277 | 'African hunting dog, hyena dog, Cape hunting dog, Lycaon pictus', 278 | 'hyena, hyaena', 279 | 'red fox, Vulpes vulpes', 280 | 'kit fox, Vulpes macrotis', 281 | 'Arctic fox, white fox, Alopex lagopus', 282 | 'grey fox, gray fox, Urocyon cinereoargenteus', 283 | 'tabby, tabby cat', 284 | 'tiger cat', 285 | 'Persian cat', 286 | 'Siamese cat, Siamese', 287 | 'Egyptian cat', 288 | 'cougar, puma, catamount, mountain lion, painter, panther, Felis concolor', 289 | 'lynx, catamount', 290 | 'leopard, Panthera pardus', 291 | 'snow leopard, ounce, Panthera uncia', 292 | 'jaguar, panther, Panthera onca, Felis onca', 293 | 'lion, king of beasts, Panthera leo', 294 | 'tiger, Panthera tigris', 295 | 'cheetah, chetah, Acinonyx jubatus', 296 | 'brown bear, bruin, Ursus arctos', 297 | 'American black bear, black bear, Ursus americanus, Euarctos americanus', 298 | 'ice bear, polar bear, Ursus Maritimus, Thalarctos maritimus', 299 | 'sloth bear, Melursus ursinus, Ursus ursinus', 300 | 'mongoose', 301 | 'meerkat, mierkat', 302 | 'tiger beetle', 303 | 'ladybug, ladybeetle, lady beetle, ladybird, ladybird beetle', 304 | 'ground beetle, carabid beetle', 305 | 'long-horned beetle, longicorn, longicorn beetle', 306 | 'leaf beetle, chrysomelid', 307 | 'dung beetle', 308 | 'rhinoceros beetle', 309 | 'weevil', 310 | 'fly', 311 | 'bee', 312 | 'ant, emmet, pismire', 313 | 'grasshopper, hopper', 314 | 'cricket', 315 | 'walking stick, walkingstick, stick insect', 316 | 'cockroach, roach', 317 | 'mantis, mantid', 318 | 'cicada, cicala', 319 | 'leafhopper', 320 | 'lacewing, lacewing fly', 321 | "dragonfly, darning needle, devil's darning needle, sewing needle, snake feeder, snake doctor, mosquito hawk, skeeter hawk", 322 | 'damselfly', 323 | 'admiral', 324 | 'ringlet, ringlet butterfly', 325 | 'monarch, monarch butterfly, milkweed butterfly, Danaus plexippus', 326 | 'cabbage butterfly', 327 | 'sulphur butterfly, sulfur butterfly', 328 | 'lycaenid, lycaenid butterfly', 329 | 'starfish, sea star', 330 | 'sea urchin', 331 | 'sea cucumber, holothurian', 332 | 'wood rabbit, cottontail, cottontail rabbit', 333 | 'hare', 334 | 'Angora, Angora rabbit', 335 | 'hamster', 336 | 'porcupine, hedgehog', 337 | 'fox squirrel, eastern fox squirrel, Sciurus niger', 338 | 'marmot', 339 | 'beaver', 340 | 'guinea pig, Cavia cobaya', 341 | 'sorrel', 342 | 'zebra', 343 | 'hog, pig, grunter, squealer, Sus scrofa', 344 | 'wild boar, boar, Sus scrofa', 345 | 'warthog', 346 | 'hippopotamus, hippo, river horse, Hippopotamus amphibius', 347 | 'ox', 348 | 'water buffalo, water ox, Asiatic buffalo, Bubalus bubalis', 349 | 'bison', 350 | 'ram, tup', 351 | 'bighorn, bighorn sheep, cimarron, Rocky Mountain bighorn, Rocky Mountain sheep, Ovis canadensis', 352 | 'ibex, Capra ibex', 353 | 'hartebeest', 354 | 'impala, Aepyceros melampus', 355 | 'gazelle', 356 | 'Arabian camel, dromedary, Camelus dromedarius', 357 | 'llama', 358 | 'weasel', 359 | 'mink', 360 | 'polecat, fitch, foulmart, foumart, Mustela putorius', 361 | 'black-footed ferret, ferret, Mustela nigripes', 362 | 'otter', 363 | 'skunk, polecat, wood pussy', 364 | 'badger', 365 | 'armadillo', 366 | 'three-toed sloth, ai, Bradypus tridactylus', 367 | 'orangutan, orang, orangutang, Pongo pygmaeus', 368 | 'gorilla, Gorilla gorilla', 369 | 'chimpanzee, chimp, Pan troglodytes', 370 | 'gibbon, Hylobates lar', 371 | 'siamang, Hylobates syndactylus, Symphalangus syndactylus', 372 | 'guenon, guenon monkey', 373 | 'patas, hussar monkey, Erythrocebus patas', 374 | 'baboon', 375 | 'macaque', 376 | 'langur', 377 | 'colobus, colobus monkey', 378 | 'proboscis monkey, Nasalis larvatus', 379 | 'marmoset', 380 | 'capuchin, ringtail, Cebus capucinus', 381 | 'howler monkey, howler', 382 | 'titi, titi monkey', 383 | 'spider monkey, Ateles geoffroyi', 384 | 'squirrel monkey, Saimiri sciureus', 385 | 'Madagascar cat, ring-tailed lemur, Lemur catta', 386 | 'indri, indris, Indri indri, Indri brevicaudatus', 387 | 'Indian elephant, Elephas maximus', 388 | 'African elephant, Loxodonta africana', 389 | 'lesser panda, red panda, panda, bear cat, cat bear, Ailurus fulgens', 390 | 'giant panda, panda, panda bear, coon bear, Ailuropoda melanoleuca', 391 | 'barracouta, snoek', 392 | 'eel', 393 | 'coho, cohoe, coho salmon, blue jack, silver salmon, Oncorhynchus kisutch', 394 | 'rock beauty, Holocanthus tricolor', 395 | 'anemone fish', 396 | 'sturgeon', 397 | 'gar, garfish, garpike, billfish, Lepisosteus osseus', 398 | 'lionfish', 399 | 'puffer, pufferfish, blowfish, globefish', 400 | 'abacus', 401 | 'abaya', 402 | "academic gown, academic robe, judge's robe", 403 | 'accordion, piano accordion, squeeze box', 404 | 'acoustic guitar', 405 | 'aircraft carrier, carrier, flattop, attack aircraft carrier', 406 | 'airliner', 407 | 'airship, dirigible', 408 | 'altar', 409 | 'ambulance', 410 | 'amphibian, amphibious vehicle', 411 | 'analog clock', 412 | 'apiary, bee house', 413 | 'apron', 414 | 'ashcan, trash can, garbage can, wastebin, ash bin, ash-bin, ashbin, dustbin, trash barrel, trash bin', 415 | 'assault rifle, assault gun', 416 | 'backpack, back pack, knapsack, packsack, rucksack, haversack', 417 | 'bakery, bakeshop, bakehouse', 418 | 'balance beam, beam', 419 | 'balloon', 420 | 'ballpoint, ballpoint pen, ballpen, Biro', 421 | 'Band Aid', 422 | 'banjo', 423 | 'bannister, banister, balustrade, balusters, handrail', 424 | 'barbell', 425 | 'barber chair', 426 | 'barbershop', 427 | 'barn', 428 | 'barometer', 429 | 'barrel, cask', 430 | 'barrow, garden cart, lawn cart, wheelbarrow', 431 | 'baseball', 432 | 'basketball', 433 | 'bassinet', 434 | 'bassoon', 435 | 'bathing cap, swimming cap', 436 | 'bath towel', 437 | 'bathtub, bathing tub, bath, tub', 438 | 'beach wagon, station wagon, wagon, estate car, beach waggon, station waggon, waggon', 439 | 'beacon, lighthouse, beacon light, pharos', 440 | 'beaker', 441 | 'bearskin, busby, shako', 442 | 'beer bottle', 443 | 'beer glass', 444 | 'bell cote, bell cot', 445 | 'bib', 446 | 'bicycle-built-for-two, tandem bicycle, tandem', 447 | 'bikini, two-piece', 448 | 'binder, ring-binder', 449 | 'binoculars, field glasses, opera glasses', 450 | 'birdhouse', 451 | 'boathouse', 452 | 'bobsled, bobsleigh, bob', 453 | 'bolo tie, bolo, bola tie, bola', 454 | 'bonnet, poke bonnet', 455 | 'bookcase', 456 | 'bookshop, bookstore, bookstall', 457 | 'bottlecap', 458 | 'bow', 459 | 'bow tie, bow-tie, bowtie', 460 | 'brass, memorial tablet, plaque', 461 | 'brassiere, bra, bandeau', 462 | 'breakwater, groin, groyne, mole, bulwark, seawall, jetty', 463 | 'breastplate, aegis, egis', 464 | 'broom', 465 | 'bucket, pail', 466 | 'buckle', 467 | 'bulletproof vest', 468 | 'bullet train, bullet', 469 | 'butcher shop, meat market', 470 | 'cab, hack, taxi, taxicab', 471 | 'caldron, cauldron', 472 | 'candle, taper, wax light', 473 | 'cannon', 474 | 'canoe', 475 | 'can opener, tin opener', 476 | 'cardigan', 477 | 'car mirror', 478 | 'carousel, carrousel, merry-go-round, roundabout, whirligig', 479 | "carpenter's kit, tool kit", 480 | 'carton', 481 | 'car wheel', 482 | 'cash machine, cash dispenser, automated teller machine, automatic teller machine, automated teller, automatic teller, ATM', 483 | 'cassette', 484 | 'cassette player', 485 | 'castle', 486 | 'catamaran', 487 | 'CD player', 488 | 'cello, violoncello', 489 | 'cellular telephone, cellular phone, cellphone, cell, mobile phone', 490 | 'chain', 491 | 'chainlink fence', 492 | 'chain mail, ring mail, mail, chain armor, chain armour, ring armor, ring armour', 493 | 'chain saw, chainsaw', 494 | 'chest', 495 | 'chiffonier, commode', 496 | 'chime, bell, gong', 497 | 'china cabinet, china closet', 498 | 'Christmas stocking', 499 | 'church, church building', 500 | 'cinema, movie theater, movie theatre, movie house, picture palace', 501 | 'cleaver, meat cleaver, chopper', 502 | 'cliff dwelling', 503 | 'cloak', 504 | 'clog, geta, patten, sabot', 505 | 'cocktail shaker', 506 | 'coffee mug', 507 | 'coffeepot', 508 | 'coil, spiral, volute, whorl, helix', 509 | 'combination lock', 510 | 'computer keyboard, keypad', 511 | 'confectionery, confectionary, candy store', 512 | 'container ship, containership, container vessel', 513 | 'convertible', 514 | 'corkscrew, bottle screw', 515 | 'cornet, horn, trumpet, trump', 516 | 'cowboy boot', 517 | 'cowboy hat, ten-gallon hat', 518 | 'cradle', 519 | 'crane', 520 | 'crash helmet', 521 | 'crate', 522 | 'crib, cot', 523 | 'Crock Pot', 524 | 'croquet ball', 525 | 'crutch', 526 | 'cuirass', 527 | 'dam, dike, dyke', 528 | 'desk', 529 | 'desktop computer', 530 | 'dial telephone, dial phone', 531 | 'diaper, nappy, napkin', 532 | 'digital clock', 533 | 'digital watch', 534 | 'dining table, board', 535 | 'dishrag, dishcloth', 536 | 'dishwasher, dish washer, dishwashing machine', 537 | 'disk brake, disc brake', 538 | 'dock, dockage, docking facility', 539 | 'dogsled, dog sled, dog sleigh', 540 | 'dome', 541 | 'doormat, welcome mat', 542 | 'drilling platform, offshore rig', 543 | 'drum, membranophone, tympan', 544 | 'drumstick', 545 | 'dumbbell', 546 | 'Dutch oven', 547 | 'electric fan, blower', 548 | 'electric guitar', 549 | 'electric locomotive', 550 | 'entertainment center', 551 | 'envelope', 552 | 'espresso maker', 553 | 'face powder', 554 | 'feather boa, boa', 555 | 'file, file cabinet, filing cabinet', 556 | 'fireboat', 557 | 'fire engine, fire truck', 558 | 'fire screen, fireguard', 559 | 'flagpole, flagstaff', 560 | 'flute, transverse flute', 561 | 'folding chair', 562 | 'football helmet', 563 | 'forklift', 564 | 'fountain', 565 | 'fountain pen', 566 | 'four-poster', 567 | 'freight car', 568 | 'French horn, horn', 569 | 'frying pan, frypan, skillet', 570 | 'fur coat', 571 | 'garbage truck, dustcart', 572 | 'gasmask, respirator, gas helmet', 573 | 'gas pump, gasoline pump, petrol pump, island dispenser', 574 | 'goblet', 575 | 'go-kart', 576 | 'golf ball', 577 | 'golfcart, golf cart', 578 | 'gondola', 579 | 'gong, tam-tam', 580 | 'gown', 581 | 'grand piano, grand', 582 | 'greenhouse, nursery, glasshouse', 583 | 'grille, radiator grille', 584 | 'grocery store, grocery, food market, market', 585 | 'guillotine', 586 | 'hair slide', 587 | 'hair spray', 588 | 'half track', 589 | 'hammer', 590 | 'hamper', 591 | 'hand blower, blow dryer, blow drier, hair dryer, hair drier', 592 | 'hand-held computer, hand-held microcomputer', 593 | 'handkerchief, hankie, hanky, hankey', 594 | 'hard disc, hard disk, fixed disk', 595 | 'harmonica, mouth organ, harp, mouth harp', 596 | 'harp', 597 | 'harvester, reaper', 598 | 'hatchet', 599 | 'holster', 600 | 'home theater, home theatre', 601 | 'honeycomb', 602 | 'hook, claw', 603 | 'hoopskirt, crinoline', 604 | 'horizontal bar, high bar', 605 | 'horse cart, horse-cart', 606 | 'hourglass', 607 | 'iPod', 608 | 'iron, smoothing iron', 609 | "jack-o'-lantern", 610 | 'jean, blue jean, denim', 611 | 'jeep, landrover', 612 | 'jersey, T-shirt, tee shirt', 613 | 'jigsaw puzzle', 614 | 'jinrikisha, ricksha, rickshaw', 615 | 'joystick', 616 | 'kimono', 617 | 'knee pad', 618 | 'knot', 619 | 'lab coat, laboratory coat', 620 | 'ladle', 621 | 'lampshade, lamp shade', 622 | 'laptop, laptop computer', 623 | 'lawn mower, mower', 624 | 'lens cap, lens cover', 625 | 'letter opener, paper knife, paperknife', 626 | 'library', 627 | 'lifeboat', 628 | 'lighter, light, igniter, ignitor', 629 | 'limousine, limo', 630 | 'liner, ocean liner', 631 | 'lipstick, lip rouge', 632 | 'Loafer', 633 | 'lotion', 634 | 'loudspeaker, speaker, speaker unit, loudspeaker system, speaker system', 635 | "loupe, jeweler's loupe", 636 | 'lumbermill, sawmill', 637 | 'magnetic compass', 638 | 'mailbag, postbag', 639 | 'mailbox, letter box', 640 | 'maillot', 641 | 'maillot, tank suit', 642 | 'manhole cover', 643 | 'maraca', 644 | 'marimba, xylophone', 645 | 'mask', 646 | 'matchstick', 647 | 'maypole', 648 | 'maze, labyrinth', 649 | 'measuring cup', 650 | 'medicine chest, medicine cabinet', 651 | 'megalith, megalithic structure', 652 | 'microphone, mike', 653 | 'microwave, microwave oven', 654 | 'military uniform', 655 | 'milk can', 656 | 'minibus', 657 | 'miniskirt, mini', 658 | 'minivan', 659 | 'missile', 660 | 'mitten', 661 | 'mixing bowl', 662 | 'mobile home, manufactured home', 663 | 'Model T', 664 | 'modem', 665 | 'monastery', 666 | 'monitor', 667 | 'moped', 668 | 'mortar', 669 | 'mortarboard', 670 | 'mosque', 671 | 'mosquito net', 672 | 'motor scooter, scooter', 673 | 'mountain bike, all-terrain bike, off-roader', 674 | 'mountain tent', 675 | 'mouse, computer mouse', 676 | 'mousetrap', 677 | 'moving van', 678 | 'muzzle', 679 | 'nail', 680 | 'neck brace', 681 | 'necklace', 682 | 'nipple', 683 | 'notebook, notebook computer', 684 | 'obelisk', 685 | 'oboe, hautboy, hautbois', 686 | 'ocarina, sweet potato', 687 | 'odometer, hodometer, mileometer, milometer', 688 | 'oil filter', 689 | 'organ, pipe organ', 690 | 'oscilloscope, scope, cathode-ray oscilloscope, CRO', 691 | 'overskirt', 692 | 'oxcart', 693 | 'oxygen mask', 694 | 'packet', 695 | 'paddle, boat paddle', 696 | 'paddlewheel, paddle wheel', 697 | 'padlock', 698 | 'paintbrush', 699 | "pajama, pyjama, pj's, jammies", 700 | 'palace', 701 | 'panpipe, pandean pipe, syrinx', 702 | 'paper towel', 703 | 'parachute, chute', 704 | 'parallel bars, bars', 705 | 'park bench', 706 | 'parking meter', 707 | 'passenger car, coach, carriage', 708 | 'patio, terrace', 709 | 'pay-phone, pay-station', 710 | 'pedestal, plinth, footstall', 711 | 'pencil box, pencil case', 712 | 'pencil sharpener', 713 | 'perfume, essence', 714 | 'Petri dish', 715 | 'photocopier', 716 | 'pick, plectrum, plectron', 717 | 'pickelhaube', 718 | 'picket fence, paling', 719 | 'pickup, pickup truck', 720 | 'pier', 721 | 'piggy bank, penny bank', 722 | 'pill bottle', 723 | 'pillow', 724 | 'ping-pong ball', 725 | 'pinwheel', 726 | 'pirate, pirate ship', 727 | 'pitcher, ewer', 728 | "plane, carpenter's plane, woodworking plane", 729 | 'planetarium', 730 | 'plastic bag', 731 | 'plate rack', 732 | 'plow, plough', 733 | "plunger, plumber's helper", 734 | 'Polaroid camera, Polaroid Land camera', 735 | 'pole', 736 | 'police van, police wagon, paddy wagon, patrol wagon, wagon, black Maria', 737 | 'poncho', 738 | 'pool table, billiard table, snooker table', 739 | 'pop bottle, soda bottle', 740 | 'pot, flowerpot', 741 | "potter's wheel", 742 | 'power drill', 743 | 'prayer rug, prayer mat', 744 | 'printer', 745 | 'prison, prison house', 746 | 'projectile, missile', 747 | 'projector', 748 | 'puck, hockey puck', 749 | 'punching bag, punch bag, punching ball, punchball', 750 | 'purse', 751 | 'quill, quill pen', 752 | 'quilt, comforter, comfort, puff', 753 | 'racer, race car, racing car', 754 | 'racket, racquet', 755 | 'radiator', 756 | 'radio, wireless', 757 | 'radio telescope, radio reflector', 758 | 'rain barrel', 759 | 'recreational vehicle, RV, R.V.', 760 | 'reel', 761 | 'reflex camera', 762 | 'refrigerator, icebox', 763 | 'remote control, remote', 764 | 'restaurant, eating house, eating place, eatery', 765 | 'revolver, six-gun, six-shooter', 766 | 'rifle', 767 | 'rocking chair, rocker', 768 | 'rotisserie', 769 | 'rubber eraser, rubber, pencil eraser', 770 | 'rugby ball', 771 | 'rule, ruler', 772 | 'running shoe', 773 | 'safe', 774 | 'safety pin', 775 | 'saltshaker, salt shaker', 776 | 'sandal', 777 | 'sarong', 778 | 'sax, saxophone', 779 | 'scabbard', 780 | 'scale, weighing machine', 781 | 'school bus', 782 | 'schooner', 783 | 'scoreboard', 784 | 'screen, CRT screen', 785 | 'screw', 786 | 'screwdriver', 787 | 'seat belt, seatbelt', 788 | 'sewing machine', 789 | 'shield, buckler', 790 | 'shoe shop, shoe-shop, shoe store', 791 | 'shoji', 792 | 'shopping basket', 793 | 'shopping cart', 794 | 'shovel', 795 | 'shower cap', 796 | 'shower curtain', 797 | 'ski', 798 | 'ski mask', 799 | 'sleeping bag', 800 | 'slide rule, slipstick', 801 | 'sliding door', 802 | 'slot, one-armed bandit', 803 | 'snorkel', 804 | 'snowmobile', 805 | 'snowplow, snowplough', 806 | 'soap dispenser', 807 | 'soccer ball', 808 | 'sock', 809 | 'solar dish, solar collector, solar furnace', 810 | 'sombrero', 811 | 'soup bowl', 812 | 'space bar', 813 | 'space heater', 814 | 'space shuttle', 815 | 'spatula', 816 | 'speedboat', 817 | "spider web, spider's web", 818 | 'spindle', 819 | 'sports car, sport car', 820 | 'spotlight, spot', 821 | 'stage', 822 | 'steam locomotive', 823 | 'steel arch bridge', 824 | 'steel drum', 825 | 'stethoscope', 826 | 'stole', 827 | 'stone wall', 828 | 'stopwatch, stop watch', 829 | 'stove', 830 | 'strainer', 831 | 'streetcar, tram, tramcar, trolley, trolley car', 832 | 'stretcher', 833 | 'studio couch, day bed', 834 | 'stupa, tope', 835 | 'submarine, pigboat, sub, U-boat', 836 | 'suit, suit of clothes', 837 | 'sundial', 838 | 'sunglass', 839 | 'sunglasses, dark glasses, shades', 840 | 'sunscreen, sunblock, sun blocker', 841 | 'suspension bridge', 842 | 'swab, swob, mop', 843 | 'sweatshirt', 844 | 'swimming trunks, bathing trunks', 845 | 'swing', 846 | 'switch, electric switch, electrical switch', 847 | 'syringe', 848 | 'table lamp', 849 | 'tank, army tank, armored combat vehicle, armoured combat vehicle', 850 | 'tape player', 851 | 'teapot', 852 | 'teddy, teddy bear', 853 | 'television, television system', 854 | 'tennis ball', 855 | 'thatch, thatched roof', 856 | 'theater curtain, theatre curtain', 857 | 'thimble', 858 | 'thresher, thrasher, threshing machine', 859 | 'throne', 860 | 'tile roof', 861 | 'toaster', 862 | 'tobacco shop, tobacconist shop, tobacconist', 863 | 'toilet seat', 864 | 'torch', 865 | 'totem pole', 866 | 'tow truck, tow car, wrecker', 867 | 'toyshop', 868 | 'tractor', 869 | 'trailer truck, tractor trailer, trucking rig, rig, articulated lorry, semi', 870 | 'tray', 871 | 'trench coat', 872 | 'tricycle, trike, velocipede', 873 | 'trimaran', 874 | 'tripod', 875 | 'triumphal arch', 876 | 'trolleybus, trolley coach, trackless trolley', 877 | 'trombone', 878 | 'tub, vat', 879 | 'turnstile', 880 | 'typewriter keyboard', 881 | 'umbrella', 882 | 'unicycle, monocycle', 883 | 'upright, upright piano', 884 | 'vacuum, vacuum cleaner', 885 | 'vase', 886 | 'vault', 887 | 'velvet', 888 | 'vending machine', 889 | 'vestment', 890 | 'viaduct', 891 | 'violin, fiddle', 892 | 'volleyball', 893 | 'waffle iron', 894 | 'wall clock', 895 | 'wallet, billfold, notecase, pocketbook', 896 | 'wardrobe, closet, press', 897 | 'warplane, military plane', 898 | 'washbasin, handbasin, washbowl, lavabo, wash-hand basin', 899 | 'washer, automatic washer, washing machine', 900 | 'water bottle', 901 | 'water jug', 902 | 'water tower', 903 | 'whiskey jug', 904 | 'whistle', 905 | 'wig', 906 | 'window screen', 907 | 'window shade', 908 | 'Windsor tie', 909 | 'wine bottle', 910 | 'wing', 911 | 'wok', 912 | 'wooden spoon', 913 | 'wool, woolen, woollen', 914 | 'worm fence, snake fence, snake-rail fence, Virginia fence', 915 | 'wreck', 916 | 'yawl', 917 | 'yurt', 918 | 'web site, website, internet site, site', 919 | 'comic book', 920 | 'crossword puzzle, crossword', 921 | 'street sign', 922 | 'traffic light, traffic signal, stoplight', 923 | 'book jacket, dust cover, dust jacket, dust wrapper', 924 | 'menu', 925 | 'plate', 926 | 'guacamole', 927 | 'consomme', 928 | 'hot pot, hotpot', 929 | 'trifle', 930 | 'ice cream, icecream', 931 | 'ice lolly, lolly, lollipop, popsicle', 932 | 'French loaf', 933 | 'bagel, beigel', 934 | 'pretzel', 935 | 'cheeseburger', 936 | 'hotdog, hot dog, red hot', 937 | 'mashed potato', 938 | 'head cabbage', 939 | 'broccoli', 940 | 'cauliflower', 941 | 'zucchini, courgette', 942 | 'spaghetti squash', 943 | 'acorn squash', 944 | 'butternut squash', 945 | 'cucumber, cuke', 946 | 'artichoke, globe artichoke', 947 | 'bell pepper', 948 | 'cardoon', 949 | 'mushroom', 950 | 'Granny Smith', 951 | 'strawberry', 952 | 'orange', 953 | 'lemon', 954 | 'fig', 955 | 'pineapple, ananas', 956 | 'banana', 957 | 'jackfruit, jak, jack', 958 | 'custard apple', 959 | 'pomegranate', 960 | 'hay', 961 | 'carbonara', 962 | 'chocolate sauce, chocolate syrup', 963 | 'dough', 964 | 'meat loaf, meatloaf', 965 | 'pizza, pizza pie', 966 | 'potpie', 967 | 'burrito', 968 | 'red wine', 969 | 'espresso', 970 | 'cup', 971 | 'eggnog', 972 | 'alp', 973 | 'bubble', 974 | 'cliff, drop, drop-off', 975 | 'coral reef', 976 | 'geyser', 977 | 'lakeside, lakeshore', 978 | 'promontory, headland, head, foreland', 979 | 'sandbar, sand bar', 980 | 'seashore, coast, seacoast, sea-coast', 981 | 'valley, vale', 982 | 'volcano', 983 | 'ballplayer, baseball player', 984 | 'groom, bridegroom', 985 | 'scuba diver', 986 | 'rapeseed', 987 | 'daisy', 988 | "yellow lady's slipper, yellow lady-slipper, Cypripedium calceolus, Cypripedium parviflorum", 989 | 'corn', 990 | 'acorn', 991 | 'hip, rose hip, rosehip', 992 | 'buckeye, horse chestnut, conker', 993 | 'coral fungus', 994 | 'agaric', 995 | 'gyromitra', 996 | 'stinkhorn, carrion fungus', 997 | 'earthstar', 998 | 'hen-of-the-woods, hen of the woods, Polyporus frondosus, Grifola frondosa', 999 | 'bolete', 1000 | 'ear, spike, capitulum', 1001 | 'toilet tissue, toilet paper, bathroom tissue' 1002 | } 1003 | -------------------------------------------------------------------------------- /test_display_camera.lua: -------------------------------------------------------------------------------- 1 | -- useOpenCV=true 2 | require 'image' 3 | require 'camera' -- for camera 4 | display = require 'display' -- for displaying 5 | 6 | local display_sample_in={} 7 | cam = image.Camera {idx=0,width=320,height=240} 8 | 9 | while true do 10 | frame = cam:forward() 11 | display_sample_in.win=display.image(frame,display_sample_in) 12 | end 13 | -------------------------------------------------------------------------------- /test_single.lua: -------------------------------------------------------------------------------- 1 | require 'nn' 2 | require 'image' 3 | 4 | 5 | local topk=5 6 | local test_image_file=arg[1] 7 | 8 | 9 | torch.setdefaulttensortype('torch.FloatTensor') 10 | -- load pre-trained model 11 | local prefix=os.getenv("HOME")..'/' 12 | local t = torch.Timer() 13 | local m=torch.load(prefix..'nin_bn_final_arm.t7') 14 | print(string.format("loading model: %.2fsec",t:time().real)) 15 | 16 | local model=m:unpack() 17 | local classes=model.classes 18 | local mean_std=model.transform 19 | 20 | -- add soft max layer, to ouput pseudo-probabilities 21 | model:add(nn.LogSoftMax()) 22 | model:evaluate() 23 | local words=torch.load(prefix..'words_1000_ascii.t7','ascii') 24 | 25 | -- load test image 26 | test_image_file=test_image_file or prefix.."n07579787_ILSVRC2012_val_00049211.JPEG" 27 | 28 | print("Using test image: "..test_image_file) 29 | local input=image.load(test_image_file) 30 | 31 | -- model input size 32 | local oW=224 33 | local oH=224 34 | 35 | -- find the smaller dimension, and resize it to loadSize (while keeping aspect ratio) 36 | if input:size(3) < input:size(2) then 37 | input = image.scale(input, oW, oH * input:size(2) / input:size(3)) 38 | else 39 | input = image.scale(input, oW * input:size(3) / input:size(2), oH) 40 | end 41 | 42 | local w1 = math.ceil((input:size(3)-oW)/2) 43 | local h1 = math.ceil((input:size(2)-oH)/2) 44 | 45 | local cropped = image.crop(input, w1, h1, w1+oW, h1+oH) -- center patch 46 | 47 | -- perform normalization (remove pre-trained mean and std) 48 | for i=1,3 do 49 | cropped[{{i},{},{}}]:add(-mean_std.mean[i]) 50 | cropped[{{i},{},{}}]:div(mean_std.std[i]) 51 | end 52 | 53 | -- add a fake dimension of size 1 54 | cropped=cropped:view(1,3,oH,oW) 55 | 56 | t = torch.Timer() 57 | local output=model:forward(cropped) 58 | print(string.format("Running neural net: %.2fsec",t:time().real)) 59 | 60 | -- extract topK classes: 61 | output=output:view(1000) 62 | local output_x, output_sorted = output:sort(1,true) 63 | probs=torch.exp(output_x) 64 | 65 | for i=1,topk do 66 | print(string.format(" %0.1f%%: %s: %s ",probs[i]*100,classes[ output_sorted[i] ], words[ classes[ output_sorted[i] ] ]) ) 67 | end 68 | 69 | -------------------------------------------------------------------------------- /test_single_resnet.lua: -------------------------------------------------------------------------------- 1 | require 'nn' 2 | require 'image' 3 | local imagenetLabel = require './imagenet_resnet' 4 | 5 | local topk=5 6 | local test_image_file=arg[1] 7 | 8 | 9 | torch.setdefaulttensortype('torch.FloatTensor') 10 | -- load pre-trained model 11 | local prefix=os.getenv("HOME")..'/' 12 | local t = torch.Timer() 13 | local m=torch.load(prefix..'resnet-18-cpu_arm.t7') 14 | print(string.format("loading model: %.2fsec",t:time().real)) 15 | 16 | local model=m 17 | --print(model) 18 | --local mean_std=model.transform 19 | local mean_std = { 20 | mean = { 0.485, 0.456, 0.406 }, 21 | std = { 0.229, 0.224, 0.225 }, 22 | } 23 | 24 | -- add soft max layer, to ouput pseudo-probabilities 25 | model:add(nn.LogSoftMax()) 26 | model:evaluate() 27 | --local words=torch.load(prefix..'words_1000_ascii.t7','ascii') 28 | 29 | -- load test image 30 | test_image_file=test_image_file or prefix.."n07579787_ILSVRC2012_val_00049211.JPEG" 31 | 32 | print("Using test image: "..test_image_file) 33 | local input=image.load(test_image_file) 34 | 35 | -- model input size 36 | local oW=224 37 | local oH=224 38 | 39 | -- find the smaller dimension, and resize it to loadSize (while keeping aspect ratio) 40 | if input:size(3) < input:size(2) then 41 | input = image.scale(input, oW, oH * input:size(2) / input:size(3)) 42 | else 43 | input = image.scale(input, oW * input:size(3) / input:size(2), oH) 44 | end 45 | 46 | local w1 = math.ceil((input:size(3)-oW)/2) 47 | local h1 = math.ceil((input:size(2)-oH)/2) 48 | 49 | local cropped = image.crop(input, w1, h1, w1+oW, h1+oH) -- center patch 50 | 51 | -- perform normalization (remove pre-trained mean and std) 52 | for i=1,3 do 53 | cropped[{{i},{},{}}]:add(-mean_std.mean[i]) 54 | cropped[{{i},{},{}}]:div(mean_std.std[i]) 55 | end 56 | 57 | -- add a fake dimension of size 1 58 | cropped=cropped:view(1,3,oH,oW) 59 | 60 | t = torch.Timer() 61 | local output=model:forward(cropped) 62 | print(string.format("Running neural net: %.2fsec",t:time().real)) 63 | 64 | -- extract topK classes: 65 | output=output:view(1000) 66 | local output_x, output_sorted = output:sort(1,true) 67 | probs=torch.exp(output_x) 68 | 69 | for i=1,topk do 70 | print(string.format(" %0.1f%%: %s",probs[i]*100,imagenetLabel[ output_sorted[i] ]) ) 71 | end 72 | 73 | --------------------------------------------------------------------------------