├── .gitmodules
├── LICENSE.md
├── README.md
├── data
├── classification_graphic.jpg
├── detection_graphic.jpg
└── landing_graphic.jpg
├── examples
├── classification
│ ├── classification.ipynb
│ └── data
│ │ ├── dog-yawning.jpg
│ │ ├── imagenet_labels_1000.txt
│ │ └── imagenet_labels_1001.txt
└── detection
│ ├── data
│ └── huskies.jpg
│ └── detection.ipynb
├── install.sh
├── scripts
└── install_protoc.sh
├── setup.py
└── tf_trt_models
├── __init__.py
├── classification.py
├── detection.py
└── graph_utils.py
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "third_party/models"]
2 | path = third_party/models
3 | url = https://github.com/tensorflow/models
4 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
2 |
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | * Redistributions of source code must retain the above copyright
7 | notice, this list of conditions and the following disclaimer.
8 | * Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | * Neither the name of NVIDIA CORPORATION nor the names of its
12 | contributors may be used to endorse or promote products derived
13 | from this software without specific prior written permission.
14 |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
16 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
19 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | TensorFlow/TensorRT Models on Jetson
2 | ====================================
3 |
4 |
5 |
6 |
7 |
8 | This repository contains scripts and documentation to use TensorFlow image classification and object detection models on NVIDIA Jetson. The models are sourced from the [TensorFlow models repository](https://github.com/tensorflow/models)
9 | and optimized using TensorRT.
10 |
11 | * [Setup](#setup)
12 | * [Image Classification](#ic)
13 | * [Models](#ic_models)
14 | * [Download pretrained model](#ic_download)
15 | * [Build TensorRT / Jetson compatible graph](#ic_build)
16 | * [Optimize with TensorRT](#ic_trt)
17 | * [Jupyter Notebook Sample](#ic_notebook)
18 | * [Train for custom task](#ic_train)
19 | * [Object Detection](#od)
20 | * [Models](#od_models)
21 | * [Download pretrained model](#od_download)
22 | * [Build TensorRT / Jetson compatible graph](#od_build)
23 | * [Optimize with TensorRT](#od_trt)
24 | * [Jupyter Notebook Sample](#od_notebook)
25 | * [Train for custom task](#od_train)
26 |
27 |
28 | Setup
29 | -----
30 |
31 | 1. Flash your Jetson TX2 with JetPack 3.2 (including TensorRT).
32 | 2. Install miscellaneous dependencies on Jetson
33 |
34 | ```
35 | sudo apt-get install python-pip python-matplotlib python-pil
36 | ```
37 |
38 | 3. Install TensorFlow 1.7+ (with TensorRT support). Download the [pre-built pip wheel](https://devtalk.nvidia.com/default/topic/1031300/jetson-tx2/tensorflow-1-8-wheel-with-jetpack-3-2-/) and install using pip.
39 |
40 | ```
41 | pip install tensorflow-1.8.0-cp27-cp27mu-linux_aarch64.whl --user
42 | ```
43 |
44 | or if you're using Python 3.
45 |
46 | ```
47 | pip3 install tensorflow-1.8.0-cp35-cp35m-linux_aarch64.whl --user
48 | ```
49 |
50 |
51 | 4. Clone this repository
52 |
53 | ```
54 | git clone --recursive https://github.com/NVIDIA-Jetson/tf_trt_models.git
55 | cd tf_trt_models
56 | ```
57 |
58 | 5. Run the installation script
59 |
60 | ```
61 | ./install.sh
62 | ```
63 |
64 | or if you want to specify python intepreter
65 |
66 | ```
67 | ./install.sh python3
68 | ```
69 |
70 |
71 | Image Classification
72 | --------------------
73 |
74 |
75 |
76 |
77 |
78 |
79 | ### Models
80 |
81 | | Model | Input Size | TF-TRT TX2 | TF TX2 |
82 | |:------|:----------:|-----------:|-------:|
83 | | inception_v1 | 224x224 | 7.36ms | 22.9ms |
84 | | inception_v2 | 224x224 | 9.08ms | 31.8ms |
85 | | inception_v3 | 299x299 | 20.7ms | 74.3ms |
86 | | inception_v4 | 299x299 | 38.5ms | 129ms |
87 | | inception_resnet_v2 | 299x299 | | 158ms |
88 | | resnet_v1_50 | 224x224 | 12.5ms | 55.1ms |
89 | | resnet_v1_101 | 224x224 | 20.6ms | 91.0ms |
90 | | resnet_v1_152 | 224x224 | 28.9ms | 124ms |
91 | | resnet_v2_50 | 299x299 | 26.5ms | 73.4ms |
92 | | resnet_v2_101 | 299x299 | 46.9ms | |
93 | | resnet_v2_152 | 299x299 | 69.0ms | |
94 | | mobilenet_v1_0p25_128 | 128x128 | 3.72ms | 7.99ms |
95 | | mobilenet_v1_0p5_160 | 160x160 | 4.47ms | 8.69ms |
96 | | mobilenet_v1_1p0_224 | 224x224 | 11.1ms | 17.3ms |
97 |
98 | **TF** - Original TensorFlow graph (FP32)
99 |
100 | **TF-TRT** - TensorRT optimized graph (FP16)
101 |
102 | The above benchmark timings were gathered after placing the Jetson TX2 in MAX-N
103 | mode. To do this, run the following commands in a terminal:
104 |
105 | ```
106 | sudo nvpmodel -m 0
107 | sudo ~/jetson_clocks.sh
108 | ```
109 |
110 |
111 | ### Download pretrained model
112 |
113 | As a convenience, we provide a script to download pretrained models sourced from the
114 | TensorFlow models repository.
115 |
116 | ```python
117 | from tf_trt_models.classification import download_classification_checkpoint
118 |
119 | checkpoint_path = download_classification_checkpoint('inception_v2')
120 | ```
121 | To manually download the pretrained models, follow the links [here](https://github.com/tensorflow/models/tree/master/research/slim#Pretrained).
122 |
123 |
124 |
125 | ### Build TensorRT / Jetson compatible graph
126 |
127 | ```python
128 | from tf_trt_models.classification import build_classification_graph
129 |
130 | frozen_graph, input_names, output_names = build_classification_graph(
131 | model='inception_v2',
132 | checkpoint=checkpoint_path,
133 | num_classes=1001
134 | )
135 | ```
136 |
137 | ### Optimize with TensorRT
138 |
139 | ```python
140 | import tensorflow.contrib.tensorrt as trt
141 |
142 | trt_graph = trt.create_inference_graph(
143 | input_graph_def=frozen_graph,
144 | outputs=output_names,
145 | max_batch_size=1,
146 | max_workspace_size_bytes=1 << 25,
147 | precision_mode='FP16',
148 | minimum_segment_size=50
149 | )
150 | ```
151 |
152 |
153 | ### Jupyter Notebook Sample
154 |
155 | For a comprehensive example of performing the above steps and executing on a real
156 | image, see the [jupyter notebook sample](examples/classification/classification.ipynb).
157 |
158 |
159 | ### Train for custom task
160 |
161 | Follow the documentation from the [TensorFlow models repository](https://github.com/tensorflow/models/tree/master/research/slim).
162 | Once you have obtained a checkpoint, proceed with building the graph and optimizing
163 | with TensorRT as shown above.
164 |
165 |
166 | Object Detection
167 | ----------------
168 |
169 |
170 |
171 |
172 | ### Models
173 |
174 | | Model | Input Size | TF-TRT TX2 | TF TX2 |
175 | |:------|:----------:|-----------:|-------:|
176 | | ssd_mobilenet_v1_coco | 300x300 | 50.5ms | 72.9ms |
177 | | ssd_inception_v2_coco | 300x300 | 54.4ms | 132ms |
178 |
179 | **TF** - Original TensorFlow graph (FP32)
180 |
181 | **TF-TRT** - TensorRT optimized graph (FP16)
182 |
183 | The above benchmark timings were gathered after placing the Jetson TX2 in MAX-N
184 | mode. To do this, run the following commands in a terminal:
185 |
186 | ```
187 | sudo nvpmodel -m 0
188 | sudo ~/jetson_clocks.sh
189 | ```
190 |
191 |
192 | ### Download pretrained model
193 |
194 | As a convenience, we provide a script to download pretrained model weights and config files sourced from the
195 | TensorFlow models repository.
196 |
197 | ```python
198 | from tf_trt_models.detection import download_detection_model
199 |
200 | config_path, checkpoint_path = download_detection_model('ssd_inception_v2_coco')
201 | ```
202 | To manually download the pretrained models, follow the links [here](https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md).
203 |
204 | > **Important:** Some of the object detection configuration files have a very low non-maximum suppression score threshold (ie. 1e-8).
205 | > This can cause unnecessarily large CPU post-processing load. Depending on your application, it may be advisable to raise
206 | > this value to something larger (like 0.3) for improved performance. We do this for the above benchmark timings. This can be done by modifying the configuration
207 | > file directly before calling build_detection_graph. The parameter can be found for example in this [line](https://github.com/tensorflow/models/blob/master/research/object_detection/samples/configs/ssd_mobilenet_v1_coco.config#L130).
208 |
209 |
210 | ### Build TensorRT / Jetson compatible graph
211 |
212 | ```python
213 | from tf_trt_models.detection import build_detection_graph
214 |
215 | frozen_graph, input_names, output_names = build_detection_graph(
216 | config=config_path,
217 | checkpoint=checkpoint_path
218 | )
219 | ```
220 |
221 |
222 | ### Optimize with TensorRT
223 |
224 | ```python
225 | import tensorflow.contrib.tensorrt as trt
226 |
227 | trt_graph = trt.create_inference_graph(
228 | input_graph_def=frozen_graph,
229 | outputs=output_names,
230 | max_batch_size=1,
231 | max_workspace_size_bytes=1 << 25,
232 | precision_mode='FP16',
233 | minimum_segment_size=50
234 | )
235 | ```
236 |
237 |
238 | ### Jupyter Notebook Sample
239 |
240 | For a comprehensive example of performing the above steps and executing on a real
241 | image, see the [jupyter notebook sample](examples/detection/detection.ipynb).
242 |
243 |
244 | ### Train for custom task
245 |
246 | Follow the documentation from the [TensorFlow models repository](https://github.com/tensorflow/models/tree/master/research/object_detection).
247 | Once you have obtained a checkpoint, proceed with building the graph and optimizing
248 | with TensorRT as shown above. Please note that all models are not tested so
249 | you should use an object detection
250 | config file during training that resembles one of the ssd_mobilenet_v1_coco or
251 | ssd_inception_v2_coco models. Some config parameters may be modified, such as the number of
252 | classes, image size, non-max supression parameters, but the performance may vary.
253 |
--------------------------------------------------------------------------------
/data/classification_graphic.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIA-AI-IOT/tf_trt_models/9ce6130c9b7a2aae6f71aa76165d1c594994e621/data/classification_graphic.jpg
--------------------------------------------------------------------------------
/data/detection_graphic.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIA-AI-IOT/tf_trt_models/9ce6130c9b7a2aae6f71aa76165d1c594994e621/data/detection_graphic.jpg
--------------------------------------------------------------------------------
/data/landing_graphic.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIA-AI-IOT/tf_trt_models/9ce6130c9b7a2aae6f71aa76165d1c594994e621/data/landing_graphic.jpg
--------------------------------------------------------------------------------
/examples/classification/data/dog-yawning.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIA-AI-IOT/tf_trt_models/9ce6130c9b7a2aae6f71aa76165d1c594994e621/examples/classification/data/dog-yawning.jpg
--------------------------------------------------------------------------------
/examples/classification/data/imagenet_labels_1000.txt:
--------------------------------------------------------------------------------
1 | tench, Tinca tinca
2 | goldfish, Carassius auratus
3 | great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias
4 | tiger shark, Galeocerdo cuvieri
5 | hammerhead, hammerhead shark
6 | electric ray, crampfish, numbfish, torpedo
7 | stingray
8 | cock
9 | hen
10 | ostrich, Struthio camelus
11 | brambling, Fringilla montifringilla
12 | goldfinch, Carduelis carduelis
13 | house finch, linnet, Carpodacus mexicanus
14 | junco, snowbird
15 | indigo bunting, indigo finch, indigo bird, Passerina cyanea
16 | robin, American robin, Turdus migratorius
17 | bulbul
18 | jay
19 | magpie
20 | chickadee
21 | water ouzel, dipper
22 | kite
23 | bald eagle, American eagle, Haliaeetus leucocephalus
24 | vulture
25 | great grey owl, great gray owl, Strix nebulosa
26 | European fire salamander, Salamandra salamandra
27 | common newt, Triturus vulgaris
28 | eft
29 | spotted salamander, Ambystoma maculatum
30 | axolotl, mud puppy, Ambystoma mexicanum
31 | bullfrog, Rana catesbeiana
32 | tree frog, tree-frog
33 | tailed frog, bell toad, ribbed toad, tailed toad, Ascaphus trui
34 | loggerhead, loggerhead turtle, Caretta caretta
35 | leatherback turtle, leatherback, leathery turtle, Dermochelys coriacea
36 | mud turtle
37 | terrapin
38 | box turtle, box tortoise
39 | banded gecko
40 | common iguana, iguana, Iguana iguana
41 | American chameleon, anole, Anolis carolinensis
42 | whiptail, whiptail lizard
43 | agama
44 | frilled lizard, Chlamydosaurus kingi
45 | alligator lizard
46 | Gila monster, Heloderma suspectum
47 | green lizard, Lacerta viridis
48 | African chameleon, Chamaeleo chamaeleon
49 | Komodo dragon, Komodo lizard, dragon lizard, giant lizard, Varanus komodoensis
50 | African crocodile, Nile crocodile, Crocodylus niloticus
51 | American alligator, Alligator mississipiensis
52 | triceratops
53 | thunder snake, worm snake, Carphophis amoenus
54 | ringneck snake, ring-necked snake, ring snake
55 | hognose snake, puff adder, sand viper
56 | green snake, grass snake
57 | king snake, kingsnake
58 | garter snake, grass snake
59 | water snake
60 | vine snake
61 | night snake, Hypsiglena torquata
62 | boa constrictor, Constrictor constrictor
63 | rock python, rock snake, Python sebae
64 | Indian cobra, Naja naja
65 | green mamba
66 | sea snake
67 | horned viper, cerastes, sand viper, horned asp, Cerastes cornutus
68 | diamondback, diamondback rattlesnake, Crotalus adamanteus
69 | sidewinder, horned rattlesnake, Crotalus cerastes
70 | trilobite
71 | harvestman, daddy longlegs, Phalangium opilio
72 | scorpion
73 | black and gold garden spider, Argiope aurantia
74 | barn spider, Araneus cavaticus
75 | garden spider, Aranea diademata
76 | black widow, Latrodectus mactans
77 | tarantula
78 | wolf spider, hunting spider
79 | tick
80 | centipede
81 | black grouse
82 | ptarmigan
83 | ruffed grouse, partridge, Bonasa umbellus
84 | prairie chicken, prairie grouse, prairie fowl
85 | peacock
86 | quail
87 | partridge
88 | African grey, African gray, Psittacus erithacus
89 | macaw
90 | sulphur-crested cockatoo, Kakatoe galerita, Cacatua galerita
91 | lorikeet
92 | coucal
93 | bee eater
94 | hornbill
95 | hummingbird
96 | jacamar
97 | toucan
98 | drake
99 | red-breasted merganser, Mergus serrator
100 | goose
101 | black swan, Cygnus atratus
102 | tusker
103 | echidna, spiny anteater, anteater
104 | platypus, duckbill, duckbilled platypus, duck-billed platypus, Ornithorhynchus anatinus
105 | wallaby, brush kangaroo
106 | koala, koala bear, kangaroo bear, native bear, Phascolarctos cinereus
107 | wombat
108 | jellyfish
109 | sea anemone, anemone
110 | brain coral
111 | flatworm, platyhelminth
112 | nematode, nematode worm, roundworm
113 | conch
114 | snail
115 | slug
116 | sea slug, nudibranch
117 | chiton, coat-of-mail shell, sea cradle, polyplacophore
118 | chambered nautilus, pearly nautilus, nautilus
119 | Dungeness crab, Cancer magister
120 | rock crab, Cancer irroratus
121 | fiddler crab
122 | king crab, Alaska crab, Alaskan king crab, Alaska king crab, Paralithodes camtschatica
123 | American lobster, Northern lobster, Maine lobster, Homarus americanus
124 | spiny lobster, langouste, rock lobster, crawfish, crayfish, sea crawfish
125 | crayfish, crawfish, crawdad, crawdaddy
126 | hermit crab
127 | isopod
128 | white stork, Ciconia ciconia
129 | black stork, Ciconia nigra
130 | spoonbill
131 | flamingo
132 | little blue heron, Egretta caerulea
133 | American egret, great white heron, Egretta albus
134 | bittern
135 | crane
136 | limpkin, Aramus pictus
137 | European gallinule, Porphyrio porphyrio
138 | American coot, marsh hen, mud hen, water hen, Fulica americana
139 | bustard
140 | ruddy turnstone, Arenaria interpres
141 | red-backed sandpiper, dunlin, Erolia alpina
142 | redshank, Tringa totanus
143 | dowitcher
144 | oystercatcher, oyster catcher
145 | pelican
146 | king penguin, Aptenodytes patagonica
147 | albatross, mollymawk
148 | grey whale, gray whale, devilfish, Eschrichtius gibbosus, Eschrichtius robustus
149 | killer whale, killer, orca, grampus, sea wolf, Orcinus orca
150 | dugong, Dugong dugon
151 | sea lion
152 | Chihuahua
153 | Japanese spaniel
154 | Maltese dog, Maltese terrier, Maltese
155 | Pekinese, Pekingese, Peke
156 | Shih-Tzu
157 | Blenheim spaniel
158 | papillon
159 | toy terrier
160 | Rhodesian ridgeback
161 | Afghan hound, Afghan
162 | basset, basset hound
163 | beagle
164 | bloodhound, sleuthhound
165 | bluetick
166 | black-and-tan coonhound
167 | Walker hound, Walker foxhound
168 | English foxhound
169 | redbone
170 | borzoi, Russian wolfhound
171 | Irish wolfhound
172 | Italian greyhound
173 | whippet
174 | Ibizan hound, Ibizan Podenco
175 | Norwegian elkhound, elkhound
176 | otterhound, otter hound
177 | Saluki, gazelle hound
178 | Scottish deerhound, deerhound
179 | Weimaraner
180 | Staffordshire bullterrier, Staffordshire bull terrier
181 | American Staffordshire terrier, Staffordshire terrier, American pit bull terrier, pit bull terrier
182 | Bedlington terrier
183 | Border terrier
184 | Kerry blue terrier
185 | Irish terrier
186 | Norfolk terrier
187 | Norwich terrier
188 | Yorkshire terrier
189 | wire-haired fox terrier
190 | Lakeland terrier
191 | Sealyham terrier, Sealyham
192 | Airedale, Airedale terrier
193 | cairn, cairn terrier
194 | Australian terrier
195 | Dandie Dinmont, Dandie Dinmont terrier
196 | Boston bull, Boston terrier
197 | miniature schnauzer
198 | giant schnauzer
199 | standard schnauzer
200 | Scotch terrier, Scottish terrier, Scottie
201 | Tibetan terrier, chrysanthemum dog
202 | silky terrier, Sydney silky
203 | soft-coated wheaten terrier
204 | West Highland white terrier
205 | Lhasa, Lhasa apso
206 | flat-coated retriever
207 | curly-coated retriever
208 | golden retriever
209 | Labrador retriever
210 | Chesapeake Bay retriever
211 | German short-haired pointer
212 | vizsla, Hungarian pointer
213 | English setter
214 | Irish setter, red setter
215 | Gordon setter
216 | Brittany spaniel
217 | clumber, clumber spaniel
218 | English springer, English springer spaniel
219 | Welsh springer spaniel
220 | cocker spaniel, English cocker spaniel, cocker
221 | Sussex spaniel
222 | Irish water spaniel
223 | kuvasz
224 | schipperke
225 | groenendael
226 | malinois
227 | briard
228 | kelpie
229 | komondor
230 | Old English sheepdog, bobtail
231 | Shetland sheepdog, Shetland sheep dog, Shetland
232 | collie
233 | Border collie
234 | Bouvier des Flandres, Bouviers des Flandres
235 | Rottweiler
236 | German shepherd, German shepherd dog, German police dog, alsatian
237 | Doberman, Doberman pinscher
238 | miniature pinscher
239 | Greater Swiss Mountain dog
240 | Bernese mountain dog
241 | Appenzeller
242 | EntleBucher
243 | boxer
244 | bull mastiff
245 | Tibetan mastiff
246 | French bulldog
247 | Great Dane
248 | Saint Bernard, St Bernard
249 | Eskimo dog, husky
250 | malamute, malemute, Alaskan malamute
251 | Siberian husky
252 | dalmatian, coach dog, carriage dog
253 | affenpinscher, monkey pinscher, monkey dog
254 | basenji
255 | pug, pug-dog
256 | Leonberg
257 | Newfoundland, Newfoundland dog
258 | Great Pyrenees
259 | Samoyed, Samoyede
260 | Pomeranian
261 | chow, chow chow
262 | keeshond
263 | Brabancon griffon
264 | Pembroke, Pembroke Welsh corgi
265 | Cardigan, Cardigan Welsh corgi
266 | toy poodle
267 | miniature poodle
268 | standard poodle
269 | Mexican hairless
270 | timber wolf, grey wolf, gray wolf, Canis lupus
271 | white wolf, Arctic wolf, Canis lupus tundrarum
272 | red wolf, maned wolf, Canis rufus, Canis niger
273 | coyote, prairie wolf, brush wolf, Canis latrans
274 | dingo, warrigal, warragal, Canis dingo
275 | dhole, Cuon alpinus
276 | African hunting dog, hyena dog, Cape hunting dog, Lycaon pictus
277 | hyena, hyaena
278 | red fox, Vulpes vulpes
279 | kit fox, Vulpes macrotis
280 | Arctic fox, white fox, Alopex lagopus
281 | grey fox, gray fox, Urocyon cinereoargenteus
282 | tabby, tabby cat
283 | tiger cat
284 | Persian cat
285 | Siamese cat, Siamese
286 | Egyptian cat
287 | cougar, puma, catamount, mountain lion, painter, panther, Felis concolor
288 | lynx, catamount
289 | leopard, Panthera pardus
290 | snow leopard, ounce, Panthera uncia
291 | jaguar, panther, Panthera onca, Felis onca
292 | lion, king of beasts, Panthera leo
293 | tiger, Panthera tigris
294 | cheetah, chetah, Acinonyx jubatus
295 | brown bear, bruin, Ursus arctos
296 | American black bear, black bear, Ursus americanus, Euarctos americanus
297 | ice bear, polar bear, Ursus Maritimus, Thalarctos maritimus
298 | sloth bear, Melursus ursinus, Ursus ursinus
299 | mongoose
300 | meerkat, mierkat
301 | tiger beetle
302 | ladybug, ladybeetle, lady beetle, ladybird, ladybird beetle
303 | ground beetle, carabid beetle
304 | long-horned beetle, longicorn, longicorn beetle
305 | leaf beetle, chrysomelid
306 | dung beetle
307 | rhinoceros beetle
308 | weevil
309 | fly
310 | bee
311 | ant, emmet, pismire
312 | grasshopper, hopper
313 | cricket
314 | walking stick, walkingstick, stick insect
315 | cockroach, roach
316 | mantis, mantid
317 | cicada, cicala
318 | leafhopper
319 | lacewing, lacewing fly
320 | dragonfly, darning needle, devil's darning needle, sewing needle, snake feeder, snake doctor, mosquito hawk, skeeter hawk
321 | damselfly
322 | admiral
323 | ringlet, ringlet butterfly
324 | monarch, monarch butterfly, milkweed butterfly, Danaus plexippus
325 | cabbage butterfly
326 | sulphur butterfly, sulfur butterfly
327 | lycaenid, lycaenid butterfly
328 | starfish, sea star
329 | sea urchin
330 | sea cucumber, holothurian
331 | wood rabbit, cottontail, cottontail rabbit
332 | hare
333 | Angora, Angora rabbit
334 | hamster
335 | porcupine, hedgehog
336 | fox squirrel, eastern fox squirrel, Sciurus niger
337 | marmot
338 | beaver
339 | guinea pig, Cavia cobaya
340 | sorrel
341 | zebra
342 | hog, pig, grunter, squealer, Sus scrofa
343 | wild boar, boar, Sus scrofa
344 | warthog
345 | hippopotamus, hippo, river horse, Hippopotamus amphibius
346 | ox
347 | water buffalo, water ox, Asiatic buffalo, Bubalus bubalis
348 | bison
349 | ram, tup
350 | bighorn, bighorn sheep, cimarron, Rocky Mountain bighorn, Rocky Mountain sheep, Ovis canadensis
351 | ibex, Capra ibex
352 | hartebeest
353 | impala, Aepyceros melampus
354 | gazelle
355 | Arabian camel, dromedary, Camelus dromedarius
356 | llama
357 | weasel
358 | mink
359 | polecat, fitch, foulmart, foumart, Mustela putorius
360 | black-footed ferret, ferret, Mustela nigripes
361 | otter
362 | skunk, polecat, wood pussy
363 | badger
364 | armadillo
365 | three-toed sloth, ai, Bradypus tridactylus
366 | orangutan, orang, orangutang, Pongo pygmaeus
367 | gorilla, Gorilla gorilla
368 | chimpanzee, chimp, Pan troglodytes
369 | gibbon, Hylobates lar
370 | siamang, Hylobates syndactylus, Symphalangus syndactylus
371 | guenon, guenon monkey
372 | patas, hussar monkey, Erythrocebus patas
373 | baboon
374 | macaque
375 | langur
376 | colobus, colobus monkey
377 | proboscis monkey, Nasalis larvatus
378 | marmoset
379 | capuchin, ringtail, Cebus capucinus
380 | howler monkey, howler
381 | titi, titi monkey
382 | spider monkey, Ateles geoffroyi
383 | squirrel monkey, Saimiri sciureus
384 | Madagascar cat, ring-tailed lemur, Lemur catta
385 | indri, indris, Indri indri, Indri brevicaudatus
386 | Indian elephant, Elephas maximus
387 | African elephant, Loxodonta africana
388 | lesser panda, red panda, panda, bear cat, cat bear, Ailurus fulgens
389 | giant panda, panda, panda bear, coon bear, Ailuropoda melanoleuca
390 | barracouta, snoek
391 | eel
392 | coho, cohoe, coho salmon, blue jack, silver salmon, Oncorhynchus kisutch
393 | rock beauty, Holocanthus tricolor
394 | anemone fish
395 | sturgeon
396 | gar, garfish, garpike, billfish, Lepisosteus osseus
397 | lionfish
398 | puffer, pufferfish, blowfish, globefish
399 | abacus
400 | abaya
401 | academic gown, academic robe, judge's robe
402 | accordion, piano accordion, squeeze box
403 | acoustic guitar
404 | aircraft carrier, carrier, flattop, attack aircraft carrier
405 | airliner
406 | airship, dirigible
407 | altar
408 | ambulance
409 | amphibian, amphibious vehicle
410 | analog clock
411 | apiary, bee house
412 | apron
413 | ashcan, trash can, garbage can, wastebin, ash bin, ash-bin, ashbin, dustbin, trash barrel, trash bin
414 | assault rifle, assault gun
415 | backpack, back pack, knapsack, packsack, rucksack, haversack
416 | bakery, bakeshop, bakehouse
417 | balance beam, beam
418 | balloon
419 | ballpoint, ballpoint pen, ballpen, Biro
420 | Band Aid
421 | banjo
422 | bannister, banister, balustrade, balusters, handrail
423 | barbell
424 | barber chair
425 | barbershop
426 | barn
427 | barometer
428 | barrel, cask
429 | barrow, garden cart, lawn cart, wheelbarrow
430 | baseball
431 | basketball
432 | bassinet
433 | bassoon
434 | bathing cap, swimming cap
435 | bath towel
436 | bathtub, bathing tub, bath, tub
437 | beach wagon, station wagon, wagon, estate car, beach waggon, station waggon, waggon
438 | beacon, lighthouse, beacon light, pharos
439 | beaker
440 | bearskin, busby, shako
441 | beer bottle
442 | beer glass
443 | bell cote, bell cot
444 | bib
445 | bicycle-built-for-two, tandem bicycle, tandem
446 | bikini, two-piece
447 | binder, ring-binder
448 | binoculars, field glasses, opera glasses
449 | birdhouse
450 | boathouse
451 | bobsled, bobsleigh, bob
452 | bolo tie, bolo, bola tie, bola
453 | bonnet, poke bonnet
454 | bookcase
455 | bookshop, bookstore, bookstall
456 | bottlecap
457 | bow
458 | bow tie, bow-tie, bowtie
459 | brass, memorial tablet, plaque
460 | brassiere, bra, bandeau
461 | breakwater, groin, groyne, mole, bulwark, seawall, jetty
462 | breastplate, aegis, egis
463 | broom
464 | bucket, pail
465 | buckle
466 | bulletproof vest
467 | bullet train, bullet
468 | butcher shop, meat market
469 | cab, hack, taxi, taxicab
470 | caldron, cauldron
471 | candle, taper, wax light
472 | cannon
473 | canoe
474 | can opener, tin opener
475 | cardigan
476 | car mirror
477 | carousel, carrousel, merry-go-round, roundabout, whirligig
478 | carpenter's kit, tool kit
479 | carton
480 | car wheel
481 | cash machine, cash dispenser, automated teller machine, automatic teller machine, automated teller, automatic teller, ATM
482 | cassette
483 | cassette player
484 | castle
485 | catamaran
486 | CD player
487 | cello, violoncello
488 | cellular telephone, cellular phone, cellphone, cell, mobile phone
489 | chain
490 | chainlink fence
491 | chain mail, ring mail, mail, chain armor, chain armour, ring armor, ring armour
492 | chain saw, chainsaw
493 | chest
494 | chiffonier, commode
495 | chime, bell, gong
496 | china cabinet, china closet
497 | Christmas stocking
498 | church, church building
499 | cinema, movie theater, movie theatre, movie house, picture palace
500 | cleaver, meat cleaver, chopper
501 | cliff dwelling
502 | cloak
503 | clog, geta, patten, sabot
504 | cocktail shaker
505 | coffee mug
506 | coffeepot
507 | coil, spiral, volute, whorl, helix
508 | combination lock
509 | computer keyboard, keypad
510 | confectionery, confectionary, candy store
511 | container ship, containership, container vessel
512 | convertible
513 | corkscrew, bottle screw
514 | cornet, horn, trumpet, trump
515 | cowboy boot
516 | cowboy hat, ten-gallon hat
517 | cradle
518 | crane
519 | crash helmet
520 | crate
521 | crib, cot
522 | Crock Pot
523 | croquet ball
524 | crutch
525 | cuirass
526 | dam, dike, dyke
527 | desk
528 | desktop computer
529 | dial telephone, dial phone
530 | diaper, nappy, napkin
531 | digital clock
532 | digital watch
533 | dining table, board
534 | dishrag, dishcloth
535 | dishwasher, dish washer, dishwashing machine
536 | disk brake, disc brake
537 | dock, dockage, docking facility
538 | dogsled, dog sled, dog sleigh
539 | dome
540 | doormat, welcome mat
541 | drilling platform, offshore rig
542 | drum, membranophone, tympan
543 | drumstick
544 | dumbbell
545 | Dutch oven
546 | electric fan, blower
547 | electric guitar
548 | electric locomotive
549 | entertainment center
550 | envelope
551 | espresso maker
552 | face powder
553 | feather boa, boa
554 | file, file cabinet, filing cabinet
555 | fireboat
556 | fire engine, fire truck
557 | fire screen, fireguard
558 | flagpole, flagstaff
559 | flute, transverse flute
560 | folding chair
561 | football helmet
562 | forklift
563 | fountain
564 | fountain pen
565 | four-poster
566 | freight car
567 | French horn, horn
568 | frying pan, frypan, skillet
569 | fur coat
570 | garbage truck, dustcart
571 | gasmask, respirator, gas helmet
572 | gas pump, gasoline pump, petrol pump, island dispenser
573 | goblet
574 | go-kart
575 | golf ball
576 | golfcart, golf cart
577 | gondola
578 | gong, tam-tam
579 | gown
580 | grand piano, grand
581 | greenhouse, nursery, glasshouse
582 | grille, radiator grille
583 | grocery store, grocery, food market, market
584 | guillotine
585 | hair slide
586 | hair spray
587 | half track
588 | hammer
589 | hamper
590 | hand blower, blow dryer, blow drier, hair dryer, hair drier
591 | hand-held computer, hand-held microcomputer
592 | handkerchief, hankie, hanky, hankey
593 | hard disc, hard disk, fixed disk
594 | harmonica, mouth organ, harp, mouth harp
595 | harp
596 | harvester, reaper
597 | hatchet
598 | holster
599 | home theater, home theatre
600 | honeycomb
601 | hook, claw
602 | hoopskirt, crinoline
603 | horizontal bar, high bar
604 | horse cart, horse-cart
605 | hourglass
606 | iPod
607 | iron, smoothing iron
608 | jack-o'-lantern
609 | jean, blue jean, denim
610 | jeep, landrover
611 | jersey, T-shirt, tee shirt
612 | jigsaw puzzle
613 | jinrikisha, ricksha, rickshaw
614 | joystick
615 | kimono
616 | knee pad
617 | knot
618 | lab coat, laboratory coat
619 | ladle
620 | lampshade, lamp shade
621 | laptop, laptop computer
622 | lawn mower, mower
623 | lens cap, lens cover
624 | letter opener, paper knife, paperknife
625 | library
626 | lifeboat
627 | lighter, light, igniter, ignitor
628 | limousine, limo
629 | liner, ocean liner
630 | lipstick, lip rouge
631 | Loafer
632 | lotion
633 | loudspeaker, speaker, speaker unit, loudspeaker system, speaker system
634 | loupe, jeweler's loupe
635 | lumbermill, sawmill
636 | magnetic compass
637 | mailbag, postbag
638 | mailbox, letter box
639 | maillot
640 | maillot, tank suit
641 | manhole cover
642 | maraca
643 | marimba, xylophone
644 | mask
645 | matchstick
646 | maypole
647 | maze, labyrinth
648 | measuring cup
649 | medicine chest, medicine cabinet
650 | megalith, megalithic structure
651 | microphone, mike
652 | microwave, microwave oven
653 | military uniform
654 | milk can
655 | minibus
656 | miniskirt, mini
657 | minivan
658 | missile
659 | mitten
660 | mixing bowl
661 | mobile home, manufactured home
662 | Model T
663 | modem
664 | monastery
665 | monitor
666 | moped
667 | mortar
668 | mortarboard
669 | mosque
670 | mosquito net
671 | motor scooter, scooter
672 | mountain bike, all-terrain bike, off-roader
673 | mountain tent
674 | mouse, computer mouse
675 | mousetrap
676 | moving van
677 | muzzle
678 | nail
679 | neck brace
680 | necklace
681 | nipple
682 | notebook, notebook computer
683 | obelisk
684 | oboe, hautboy, hautbois
685 | ocarina, sweet potato
686 | odometer, hodometer, mileometer, milometer
687 | oil filter
688 | organ, pipe organ
689 | oscilloscope, scope, cathode-ray oscilloscope, CRO
690 | overskirt
691 | oxcart
692 | oxygen mask
693 | packet
694 | paddle, boat paddle
695 | paddlewheel, paddle wheel
696 | padlock
697 | paintbrush
698 | pajama, pyjama, pj's, jammies
699 | palace
700 | panpipe, pandean pipe, syrinx
701 | paper towel
702 | parachute, chute
703 | parallel bars, bars
704 | park bench
705 | parking meter
706 | passenger car, coach, carriage
707 | patio, terrace
708 | pay-phone, pay-station
709 | pedestal, plinth, footstall
710 | pencil box, pencil case
711 | pencil sharpener
712 | perfume, essence
713 | Petri dish
714 | photocopier
715 | pick, plectrum, plectron
716 | pickelhaube
717 | picket fence, paling
718 | pickup, pickup truck
719 | pier
720 | piggy bank, penny bank
721 | pill bottle
722 | pillow
723 | ping-pong ball
724 | pinwheel
725 | pirate, pirate ship
726 | pitcher, ewer
727 | plane, carpenter's plane, woodworking plane
728 | planetarium
729 | plastic bag
730 | plate rack
731 | plow, plough
732 | plunger, plumber's helper
733 | Polaroid camera, Polaroid Land camera
734 | pole
735 | police van, police wagon, paddy wagon, patrol wagon, wagon, black Maria
736 | poncho
737 | pool table, billiard table, snooker table
738 | pop bottle, soda bottle
739 | pot, flowerpot
740 | potter's wheel
741 | power drill
742 | prayer rug, prayer mat
743 | printer
744 | prison, prison house
745 | projectile, missile
746 | projector
747 | puck, hockey puck
748 | punching bag, punch bag, punching ball, punchball
749 | purse
750 | quill, quill pen
751 | quilt, comforter, comfort, puff
752 | racer, race car, racing car
753 | racket, racquet
754 | radiator
755 | radio, wireless
756 | radio telescope, radio reflector
757 | rain barrel
758 | recreational vehicle, RV, R.V.
759 | reel
760 | reflex camera
761 | refrigerator, icebox
762 | remote control, remote
763 | restaurant, eating house, eating place, eatery
764 | revolver, six-gun, six-shooter
765 | rifle
766 | rocking chair, rocker
767 | rotisserie
768 | rubber eraser, rubber, pencil eraser
769 | rugby ball
770 | rule, ruler
771 | running shoe
772 | safe
773 | safety pin
774 | saltshaker, salt shaker
775 | sandal
776 | sarong
777 | sax, saxophone
778 | scabbard
779 | scale, weighing machine
780 | school bus
781 | schooner
782 | scoreboard
783 | screen, CRT screen
784 | screw
785 | screwdriver
786 | seat belt, seatbelt
787 | sewing machine
788 | shield, buckler
789 | shoe shop, shoe-shop, shoe store
790 | shoji
791 | shopping basket
792 | shopping cart
793 | shovel
794 | shower cap
795 | shower curtain
796 | ski
797 | ski mask
798 | sleeping bag
799 | slide rule, slipstick
800 | sliding door
801 | slot, one-armed bandit
802 | snorkel
803 | snowmobile
804 | snowplow, snowplough
805 | soap dispenser
806 | soccer ball
807 | sock
808 | solar dish, solar collector, solar furnace
809 | sombrero
810 | soup bowl
811 | space bar
812 | space heater
813 | space shuttle
814 | spatula
815 | speedboat
816 | spider web, spider's web
817 | spindle
818 | sports car, sport car
819 | spotlight, spot
820 | stage
821 | steam locomotive
822 | steel arch bridge
823 | steel drum
824 | stethoscope
825 | stole
826 | stone wall
827 | stopwatch, stop watch
828 | stove
829 | strainer
830 | streetcar, tram, tramcar, trolley, trolley car
831 | stretcher
832 | studio couch, day bed
833 | stupa, tope
834 | submarine, pigboat, sub, U-boat
835 | suit, suit of clothes
836 | sundial
837 | sunglass
838 | sunglasses, dark glasses, shades
839 | sunscreen, sunblock, sun blocker
840 | suspension bridge
841 | swab, swob, mop
842 | sweatshirt
843 | swimming trunks, bathing trunks
844 | swing
845 | switch, electric switch, electrical switch
846 | syringe
847 | table lamp
848 | tank, army tank, armored combat vehicle, armoured combat vehicle
849 | tape player
850 | teapot
851 | teddy, teddy bear
852 | television, television system
853 | tennis ball
854 | thatch, thatched roof
855 | theater curtain, theatre curtain
856 | thimble
857 | thresher, thrasher, threshing machine
858 | throne
859 | tile roof
860 | toaster
861 | tobacco shop, tobacconist shop, tobacconist
862 | toilet seat
863 | torch
864 | totem pole
865 | tow truck, tow car, wrecker
866 | toyshop
867 | tractor
868 | trailer truck, tractor trailer, trucking rig, rig, articulated lorry, semi
869 | tray
870 | trench coat
871 | tricycle, trike, velocipede
872 | trimaran
873 | tripod
874 | triumphal arch
875 | trolleybus, trolley coach, trackless trolley
876 | trombone
877 | tub, vat
878 | turnstile
879 | typewriter keyboard
880 | umbrella
881 | unicycle, monocycle
882 | upright, upright piano
883 | vacuum, vacuum cleaner
884 | vase
885 | vault
886 | velvet
887 | vending machine
888 | vestment
889 | viaduct
890 | violin, fiddle
891 | volleyball
892 | waffle iron
893 | wall clock
894 | wallet, billfold, notecase, pocketbook
895 | wardrobe, closet, press
896 | warplane, military plane
897 | washbasin, handbasin, washbowl, lavabo, wash-hand basin
898 | washer, automatic washer, washing machine
899 | water bottle
900 | water jug
901 | water tower
902 | whiskey jug
903 | whistle
904 | wig
905 | window screen
906 | window shade
907 | Windsor tie
908 | wine bottle
909 | wing
910 | wok
911 | wooden spoon
912 | wool, woolen, woollen
913 | worm fence, snake fence, snake-rail fence, Virginia fence
914 | wreck
915 | yawl
916 | yurt
917 | web site, website, internet site, site
918 | comic book
919 | crossword puzzle, crossword
920 | street sign
921 | traffic light, traffic signal, stoplight
922 | book jacket, dust cover, dust jacket, dust wrapper
923 | menu
924 | plate
925 | guacamole
926 | consomme
927 | hot pot, hotpot
928 | trifle
929 | ice cream, icecream
930 | ice lolly, lolly, lollipop, popsicle
931 | French loaf
932 | bagel, beigel
933 | pretzel
934 | cheeseburger
935 | hotdog, hot dog, red hot
936 | mashed potato
937 | head cabbage
938 | broccoli
939 | cauliflower
940 | zucchini, courgette
941 | spaghetti squash
942 | acorn squash
943 | butternut squash
944 | cucumber, cuke
945 | artichoke, globe artichoke
946 | bell pepper
947 | cardoon
948 | mushroom
949 | Granny Smith
950 | strawberry
951 | orange
952 | lemon
953 | fig
954 | pineapple, ananas
955 | banana
956 | jackfruit, jak, jack
957 | custard apple
958 | pomegranate
959 | hay
960 | carbonara
961 | chocolate sauce, chocolate syrup
962 | dough
963 | meat loaf, meatloaf
964 | pizza, pizza pie
965 | potpie
966 | burrito
967 | red wine
968 | espresso
969 | cup
970 | eggnog
971 | alp
972 | bubble
973 | cliff, drop, drop-off
974 | coral reef
975 | geyser
976 | lakeside, lakeshore
977 | promontory, headland, head, foreland
978 | sandbar, sand bar
979 | seashore, coast, seacoast, sea-coast
980 | valley, vale
981 | volcano
982 | ballplayer, baseball player
983 | groom, bridegroom
984 | scuba diver
985 | rapeseed
986 | daisy
987 | yellow lady's slipper, yellow lady-slipper, Cypripedium calceolus, Cypripedium parviflorum
988 | corn
989 | acorn
990 | hip, rose hip, rosehip
991 | buckeye, horse chestnut, conker
992 | coral fungus
993 | agaric
994 | gyromitra
995 | stinkhorn, carrion fungus
996 | earthstar
997 | hen-of-the-woods, hen of the woods, Polyporus frondosus, Grifola frondosa
998 | bolete
999 | ear, spike, capitulum
1000 | toilet tissue, toilet paper, bathroom tissue
1001 |
--------------------------------------------------------------------------------
/examples/classification/data/imagenet_labels_1001.txt:
--------------------------------------------------------------------------------
1 | background
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 |
--------------------------------------------------------------------------------
/examples/detection/data/huskies.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIA-AI-IOT/tf_trt_models/9ce6130c9b7a2aae6f71aa76165d1c594994e621/examples/detection/data/huskies.jpg
--------------------------------------------------------------------------------
/install.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | INSTALL_PROTOC=$PWD/scripts/install_protoc.sh
4 | MODELS_DIR=$PWD/third_party/models
5 |
6 | PYTHON=python
7 |
8 | if [ $# -eq 1 ]; then
9 | PYTHON=$1
10 | fi
11 |
12 | echo $PYTHON
13 |
14 | # install protoc
15 | echo "Downloading protoc"
16 | source $INSTALL_PROTOC
17 | PROTOC=$PWD/data/protoc/bin/protoc
18 |
19 | # install tensorflow models
20 | git submodule update --init
21 |
22 | pushd $MODELS_DIR/research
23 | echo $PWD
24 | echo "Installing object detection library"
25 | echo $PROTOC
26 | $PROTOC object_detection/protos/*.proto --python_out=.
27 | $PYTHON setup.py install --user
28 | popd
29 |
30 | pushd $MODELS_DIR/research/slim
31 | echo $PWD
32 | echo "Installing slim library"
33 | $PYTHON setup.py install --user
34 | popd
35 |
36 | echo "Installing tf_trt_models"
37 | echo $PWD
38 | $PYTHON setup.py install --user
39 |
--------------------------------------------------------------------------------
/scripts/install_protoc.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | BASE_URL="https://github.com/google/protobuf/releases/download/v3.5.1/"
4 | PROTOC_DIR=data/protoc
5 |
6 | mkdir -p $PROTOC_DIR
7 | pushd $PROTOC_DIR
8 | ARCH=$(uname -m)
9 | if [ "$ARCH" == "aarch64" ] ; then
10 | filename="protoc-3.5.1-linux-aarch_64.zip"
11 | elif [ "$ARCH" == "x86_64" ] ; then
12 | filename="protoc-3.5.1-linux-x86_64.zip"
13 | else
14 | echo ERROR: $ARCH not supported.
15 | exit 1;
16 | fi
17 | wget --no-check-certificate ${BASE_URL}${filename}
18 | unzip ${filename}
19 | popd
20 |
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | from setuptools import find_packages, setup
2 |
3 | setup(
4 | name='tf_trt_models',
5 | version='0.0',
6 | description='TensorFlow models accelerated with NVIDIA TensorRT',
7 | author='',
8 | author_email='',
9 | url='https://github.com/NVIDIA-Jetson/tf_trt_models',
10 | packages=find_packages(),
11 | )
12 |
--------------------------------------------------------------------------------
/tf_trt_models/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NVIDIA-AI-IOT/tf_trt_models/9ce6130c9b7a2aae6f71aa76165d1c594994e621/tf_trt_models/__init__.py
--------------------------------------------------------------------------------
/tf_trt_models/classification.py:
--------------------------------------------------------------------------------
1 | from collections import namedtuple
2 |
3 | from .graph_utils import convert_relu6
4 |
5 | import nets
6 | import nets.inception
7 | import nets.mobilenet_v1
8 | import nets.resnet_v1
9 | import nets.resnet_v2
10 | import nets.vgg
11 |
12 | import os
13 | import subprocess
14 | import tarfile
15 |
16 | import tensorflow as tf
17 | import tensorflow.contrib.slim as slim
18 |
19 | NetDef = namedtuple('NetDef', ['model', 'arg_scope', 'input_width',
20 | 'input_height', 'preprocess', 'postprocess', 'url', 'checkpoint_name',
21 | 'num_classes'])
22 |
23 |
24 | def _mobilenet_v1_1p0_224(*args, **kwargs):
25 | kwargs['depth_multiplier'] = 1.0
26 | return nets.mobilenet_v1.mobilenet_v1(*args, **kwargs)
27 |
28 |
29 | def _mobilenet_v1_0p5_160(*args, **kwargs):
30 | kwargs['depth_multiplier'] = 0.5
31 | return nets.mobilenet_v1.mobilenet_v1(*args, **kwargs)
32 |
33 |
34 | def _mobilenet_v1_0p25_128(*args, **kwargs):
35 | kwargs['depth_multiplier'] = 0.25
36 | return nets.mobilenet_v1.mobilenet_v1(*args, **kwargs)
37 |
38 |
39 | def _preprocess_vgg(x):
40 | tf_x_float = tf.cast(x, tf.float32)
41 | tf_mean = tf.constant([123.68, 116.78, 103.94], tf.float32)
42 | return tf.subtract(tf_x_float, tf_mean)
43 |
44 |
45 | def _preprocess_inception(x):
46 | tf_x_float = tf.cast(x, tf.float32)
47 | return 2.0 * (tf_x_float / 255.0 - 0.5)
48 |
49 |
50 | input_name = 'input'
51 | output_name = 'scores'
52 | NETS = {
53 | 'mobilenet_v1_0p25_128':
54 | NetDef(_mobilenet_v1_0p25_128,
55 | nets.mobilenet_v1.mobilenet_v1_arg_scope, 128, 128,
56 | _preprocess_inception, tf.nn.softmax,
57 | 'http://download.tensorflow.org/models/mobilenet_v1_2018_02_22/mobilenet_v1_0.25_128.tgz',
58 | 'mobilenet_v1_0.25_128.ckpt', 1001),
59 | 'mobilenet_v1_0p5_160':
60 | NetDef(_mobilenet_v1_0p5_160, nets.mobilenet_v1.mobilenet_v1_arg_scope,
61 | 160, 160, _preprocess_inception, tf.nn.softmax,
62 | 'http://download.tensorflow.org/models/mobilenet_v1_2018_02_22/mobilenet_v1_0.5_160.tgz',
63 | 'mobilenet_v1_0.5_160.ckpt', 1001),
64 | 'mobilenet_v1_1p0_224':
65 | NetDef(_mobilenet_v1_1p0_224, nets.mobilenet_v1.mobilenet_v1_arg_scope,
66 | 224, 224, _preprocess_inception, tf.nn.softmax,
67 | 'http://download.tensorflow.org/models/mobilenet_v1_2018_02_22/mobilenet_v1_1.0_224.tgz',
68 | 'mobilenet_v1_1.0_224.ckpt', 1001),
69 | 'vgg_16':
70 | NetDef(nets.vgg.vgg_16, nets.vgg.vgg_arg_scope, 224, 224,
71 | _preprocess_vgg, tf.nn.softmax,
72 | 'http://download.tensorflow.org/models/vgg_16_2016_08_28.tar.gz',
73 | 'vgg_16.ckpt', 1000),
74 | 'vgg_19':
75 | NetDef(nets.vgg.vgg_19, nets.vgg.vgg_arg_scope, 224, 224,
76 | _preprocess_vgg, tf.nn.softmax,
77 | 'http://download.tensorflow.org/models/vgg_19_2016_08_28.tar.gz',
78 | 'vgg_19.ckpt', 1000),
79 | 'inception_v1':
80 | NetDef(nets.inception.inception_v1, nets.inception.inception_v1_arg_scope,
81 | 224, 224, _preprocess_inception, tf.nn.softmax,
82 | 'http://download.tensorflow.org/models/inception_v1_2016_08_28.tar.gz',
83 | 'inception_v1.ckpt', 1001),
84 | 'inception_v2':
85 | NetDef(nets.inception.inception_v2, nets.inception.inception_v2_arg_scope,
86 | 224, 224, _preprocess_inception, tf.nn.softmax,
87 | 'http://download.tensorflow.org/models/inception_v2_2016_08_28.tar.gz',
88 | 'inception_v2.ckpt', 1001),
89 | 'inception_v3':
90 | NetDef(nets.inception.inception_v3, nets.inception.inception_v3_arg_scope,
91 | 299, 299, _preprocess_inception, tf.nn.softmax,
92 | 'http://download.tensorflow.org/models/inception_v3_2016_08_28.tar.gz',
93 | 'inception_v3.ckpt', 1001),
94 | 'inception_v4':
95 | NetDef(nets.inception.inception_v4, nets.inception.inception_v4_arg_scope,
96 | 299, 299, _preprocess_inception, tf.nn.softmax,
97 | 'http://download.tensorflow.org/models/inception_v4_2016_09_09.tar.gz',
98 | 'inception_v4.ckpt', 1001),
99 | 'inception_resnet_v2':
100 | NetDef(nets.inception.inception_resnet_v2,
101 | nets.inception.inception_resnet_v2_arg_scope, 299, 299,
102 | _preprocess_inception, tf.nn.softmax,
103 | 'http://download.tensorflow.org/models/inception_resnet_v2_2016_08_30.tar.gz',
104 | 'inception_resnet_v2_2016_08_30.ckpt', 1001),
105 | 'resnet_v1_50':
106 | NetDef(nets.resnet_v1.resnet_v1_50, nets.resnet_v1.resnet_arg_scope,
107 | 224, 224, _preprocess_vgg, tf.nn.softmax,
108 | 'http://download.tensorflow.org/models/resnet_v1_50_2016_08_28.tar.gz',
109 | 'resnet_v1_50.ckpt', 1000),
110 | 'resnet_v1_101':
111 | NetDef(nets.resnet_v1.resnet_v1_101, nets.resnet_v1.resnet_arg_scope,
112 | 224, 224, _preprocess_vgg, tf.nn.softmax,
113 | 'http://download.tensorflow.org/models/resnet_v1_101_2016_08_28.tar.gz',
114 | 'resnet_v1_101.ckpt', 1000),
115 | 'resnet_v1_152':
116 | NetDef(nets.resnet_v1.resnet_v1_152, nets.resnet_v1.resnet_arg_scope,
117 | 224, 224, _preprocess_vgg, tf.nn.softmax,
118 | 'http://download.tensorflow.org/models/resnet_v1_152_2016_08_28.tar.gz',
119 | 'resnet_v1_152.ckpt', 1000),
120 | 'resnet_v2_50':
121 | NetDef(nets.resnet_v2.resnet_v2_50, nets.resnet_v2.resnet_arg_scope,
122 | 299, 299, _preprocess_inception, tf.nn.softmax,
123 | 'http://download.tensorflow.org/models/resnet_v2_50_2017_04_14.tar.gz',
124 | 'resnet_v2_50.ckpt', 1001),
125 | 'resnet_v2_101':
126 | NetDef(nets.resnet_v2.resnet_v2_101, nets.resnet_v2.resnet_arg_scope,
127 | 299, 299, _preprocess_inception, tf.nn.softmax,
128 | 'http://download.tensorflow.org/models/resnet_v2_101_2017_04_14.tar.gz',
129 | 'resnet_v2_101.ckpt', 1001),
130 | 'resnet_v2_152':
131 | NetDef(nets.resnet_v2.resnet_v2_152, nets.resnet_v2.resnet_arg_scope,
132 | 299, 299, _preprocess_inception, tf.nn.softmax,
133 | 'http://download.tensorflow.org/models/resnet_v2_152_2017_04_14.tar.gz',
134 | 'resnet_v2_152.ckpt', 1001),
135 | }
136 |
137 |
138 | def download_classification_checkpoint(model, output_dir='.'):
139 | """Downloads an image classification model pretrained checkpoint by name
140 |
141 | :param model: the model name (see table)
142 | :type model: string
143 | :param output_dir: the directory where files are downloaded to
144 | :type output_dir: string
145 | :return checkpoint_path: path to the checkpoint file containing trained model params
146 | :rtype string
147 | """
148 | global NETS, input_name, output_name
149 | checkpoint_path = ''
150 |
151 | if not os.path.exists(output_dir):
152 | os.makedirs(output_dir)
153 |
154 | modeldir_path = os.path.join(output_dir, model)
155 | if not os.path.exists(modeldir_path):
156 | os.makedirs(modeldir_path)
157 |
158 | modeltar_path = os.path.join(output_dir, os.path.basename(NETS[model].url))
159 | if not os.path.isfile(modeltar_path):
160 | subprocess.call(['wget', '--no-check-certificate', NETS[model].url, '-O', modeltar_path])
161 |
162 | checkpoint_path = os.path.join(modeldir_path, NETS[model].checkpoint_name)
163 | if not os.path.isfile(checkpoint_path):
164 | subprocess.call(['tar', '-xzf', modeltar_path, '-C', modeldir_path])
165 |
166 | return checkpoint_path
167 |
168 |
169 | def build_classification_graph(model, checkpoint, num_classes):
170 | """Builds an image classification model by name
171 |
172 | This function builds an image classification model given a model
173 | name, parameter checkpoint file path, and number of classes. This
174 | function performs some graph processing (such as replacing relu6(x)
175 | operations with relu(x) - relu(x-6)) to produce a graph that is
176 | well optimized by the TensorRT package in TensorFlow 1.7+.
177 |
178 | :param model: the model name (see table)
179 | :type model: string
180 | :param checkpoint: the checkpoint file path
181 | :type checkpoint: string
182 | :param num_classes: the number of output classes
183 | :type num_classes: integer
184 |
185 | :returns: the TensorRT compatible frozen graph
186 | :rtype: a tensorflow.GraphDef
187 | """
188 | global NETS, input_name, output_name
189 |
190 | net = NETS[model]
191 | tf_config = tf.ConfigProto()
192 | tf_config.gpu_options.allow_growth = True
193 |
194 | with tf.Graph().as_default() as tf_graph:
195 | with tf.Session(config=tf_config) as tf_sess:
196 |
197 | tf_input = tf.placeholder(tf.float32, [None, net.input_height, net.input_width, 3],
198 | name=input_name)
199 | tf_preprocessed = net.preprocess(tf_input)
200 |
201 | with slim.arg_scope(net.arg_scope()):
202 | tf_net, tf_end_points = net.model(tf_preprocessed, is_training=False,
203 | num_classes=num_classes)
204 |
205 | tf_output = net.postprocess(tf_net, name=output_name)
206 |
207 | # load checkpoint
208 | tf_saver = tf.train.Saver()
209 | tf_saver.restore(save_path=checkpoint, sess=tf_sess)
210 |
211 | # freeze graph
212 | frozen_graph = tf.graph_util.convert_variables_to_constants(
213 | tf_sess,
214 | tf_sess.graph_def,
215 | output_node_names=[output_name]
216 | )
217 |
218 | # remove relu 6
219 | frozen_graph = convert_relu6(frozen_graph)
220 |
221 | return frozen_graph, [input_name], [output_name]
222 |
--------------------------------------------------------------------------------
/tf_trt_models/detection.py:
--------------------------------------------------------------------------------
1 | from object_detection.protos import pipeline_pb2
2 | from object_detection.protos import image_resizer_pb2
3 | from object_detection import exporter
4 |
5 | import os
6 | import subprocess
7 |
8 | from collections import namedtuple
9 | from google.protobuf import text_format
10 |
11 | import tensorflow as tf
12 |
13 | from .graph_utils import force_nms_cpu as f_force_nms_cpu
14 | from .graph_utils import replace_relu6 as f_replace_relu6
15 | from .graph_utils import remove_assert as f_remove_assert
16 |
17 | DetectionModel = namedtuple('DetectionModel', ['name', 'url', 'extract_dir'])
18 |
19 | INPUT_NAME='image_tensor'
20 | BOXES_NAME='detection_boxes'
21 | CLASSES_NAME='detection_classes'
22 | SCORES_NAME='detection_scores'
23 | MASKS_NAME='detection_masks'
24 | NUM_DETECTIONS_NAME='num_detections'
25 | FROZEN_GRAPH_NAME='frozen_inference_graph.pb'
26 | PIPELINE_CONFIG_NAME='pipeline.config'
27 | CHECKPOINT_PREFIX='model.ckpt'
28 |
29 |
30 | MODELS = {
31 | 'ssd_mobilenet_v1_coco': DetectionModel(
32 | 'ssd_mobilenet_v1_coco',
33 | 'http://download.tensorflow.org/models/object_detection/ssd_mobilenet_v1_coco_2018_01_28.tar.gz',
34 | 'ssd_mobilenet_v1_coco_2018_01_28',
35 | ),
36 | 'ssd_mobilenet_v2_coco': DetectionModel(
37 | 'ssd_mobilenet_v2_coco',
38 | 'http://download.tensorflow.org/models/object_detection/ssd_mobilenet_v2_coco_2018_03_29.tar.gz',
39 | 'ssd_mobilenet_v2_coco_2018_03_29',
40 | ),
41 | 'ssd_inception_v2_coco': DetectionModel(
42 | 'ssd_inception_v2_coco',
43 | 'http://download.tensorflow.org/models/object_detection/ssd_inception_v2_coco_2018_01_28.tar.gz',
44 | 'ssd_inception_v2_coco_2018_01_28',
45 | ),
46 | 'ssd_resnet_50_fpn_coco': DetectionModel(
47 | 'ssd_resnet_50_fpn_coco',
48 | 'http://download.tensorflow.org/models/object_detection/ssd_resnet50_v1_fpn_shared_box_predictor_640x640_coco14_sync_2018_07_03.tar.gz',
49 | 'ssd_resnet50_v1_fpn_shared_box_predictor_640x640_coco14_sync_2018_07_03',
50 | ),
51 | 'faster_rcnn_resnet50_coco': DetectionModel(
52 | 'faster_rcnn_resnet50_coco',
53 | 'http://download.tensorflow.org/models/object_detection/faster_rcnn_resnet50_coco_2018_01_28.tar.gz',
54 | 'faster_rcnn_resnet50_coco_2018_01_28',
55 | ),
56 | 'faster_rcnn_nas': DetectionModel(
57 | 'faster_rcnn_nas',
58 | 'http://download.tensorflow.org/models/object_detection/faster_rcnn_nas_coco_2018_01_28.tar.gz',
59 | 'faster_rcnn_nas_coco_2018_01_28',
60 | ),
61 | 'mask_rcnn_resnet50_atrous_coco': DetectionModel(
62 | 'mask_rcnn_resnet50_atrous_coco',
63 | 'http://download.tensorflow.org/models/object_detection/mask_rcnn_resnet50_atrous_coco_2018_01_28.tar.gz',
64 | 'mask_rcnn_resnet50_atrous_coco_2018_01_28',
65 | )
66 | }
67 |
68 |
69 | def get_input_names(model):
70 | return [INPUT_NAME]
71 |
72 |
73 | def get_output_names(model):
74 | output_names = [BOXES_NAME, CLASSES_NAME, SCORES_NAME, NUM_DETECTIONS_NAME]
75 | if model == 'mask_rcnn_resnet50_atrous_coco':
76 | output_names.append(MASKS_NAME)
77 | return output_names
78 |
79 |
80 | def download_detection_model(model, output_dir='.'):
81 | """Downloads a pre-trained object detection model"""
82 | global MODELS
83 |
84 | model_name = model
85 |
86 | model = MODELS[model_name]
87 | subprocess.call(['mkdir', '-p', output_dir])
88 | tar_file = os.path.join(output_dir, os.path.basename(model.url))
89 |
90 | config_path = os.path.join(output_dir, model.extract_dir, PIPELINE_CONFIG_NAME)
91 | checkpoint_path = os.path.join(output_dir, model.extract_dir, CHECKPOINT_PREFIX)
92 |
93 | if not os.path.exists(os.path.join(output_dir, model.extract_dir)):
94 | subprocess.call(['wget', model.url, '-O', tar_file])
95 | subprocess.call(['tar', '-xzf', tar_file, '-C', output_dir])
96 |
97 | # hack fix to handle mobilenet_v2 config bug
98 | subprocess.call(['sed', '-i', '/batch_norm_trainable/d', config_path])
99 |
100 | return config_path, checkpoint_path
101 |
102 |
103 | def build_detection_graph(config, checkpoint,
104 | batch_size=1,
105 | score_threshold=None,
106 | force_nms_cpu=True,
107 | replace_relu6=True,
108 | remove_assert=True,
109 | input_shape=None,
110 | output_dir='.generated_model'):
111 | """Builds a frozen graph for a pre-trained object detection model"""
112 |
113 | config_path = config
114 | checkpoint_path = checkpoint
115 |
116 | # parse config from file
117 | config = pipeline_pb2.TrainEvalPipelineConfig()
118 | with open(config_path, 'r') as f:
119 | text_format.Merge(f.read(), config, allow_unknown_extension=True)
120 |
121 | # override some config parameters
122 | if config.model.HasField('ssd'):
123 | config.model.ssd.feature_extractor.override_base_feature_extractor_hyperparams = True
124 | if score_threshold is not None:
125 | config.model.ssd.post_processing.batch_non_max_suppression.score_threshold = score_threshold
126 | if input_shape is not None:
127 | config.model.ssd.image_resizer.fixed_shape_resizer.height = input_shape[0]
128 | config.model.ssd.image_resizer.fixed_shape_resizer.width = input_shape[1]
129 | elif config.model.HasField('faster_rcnn'):
130 | if score_threshold is not None:
131 | config.model.faster_rcnn.second_stage_post_processing.score_threshold = score_threshold
132 | if input_shape is not None:
133 | config.model.faster_rcnn.image_resizer.fixed_shape_resizer.height = input_shape[0]
134 | config.model.faster_rcnn.image_resizer.fixed_shape_resizer.width = input_shape[1]
135 |
136 | if os.path.isdir(output_dir):
137 | subprocess.call(['rm', '-rf', output_dir])
138 |
139 | tf_config = tf.ConfigProto()
140 | tf_config.gpu_options.allow_growth = True
141 |
142 | # export inference graph to file (initial)
143 | with tf.Session(config=tf_config) as tf_sess:
144 | with tf.Graph().as_default() as tf_graph:
145 | exporter.export_inference_graph(
146 | 'image_tensor',
147 | config,
148 | checkpoint_path,
149 | output_dir,
150 | input_shape=[batch_size, None, None, 3]
151 | )
152 |
153 | # read frozen graph from file
154 | frozen_graph = tf.GraphDef()
155 | with open(os.path.join(output_dir, FROZEN_GRAPH_NAME), 'rb') as f:
156 | frozen_graph.ParseFromString(f.read())
157 |
158 | # apply graph modifications
159 | if force_nms_cpu:
160 | frozen_graph = f_force_nms_cpu(frozen_graph)
161 | if replace_relu6:
162 | frozen_graph = f_replace_relu6(frozen_graph)
163 | if remove_assert:
164 | frozen_graph = f_remove_assert(frozen_graph)
165 |
166 | # get input names
167 | # TODO: handle mask_rcnn
168 | input_names = [INPUT_NAME]
169 | output_names = [BOXES_NAME, CLASSES_NAME, SCORES_NAME, NUM_DETECTIONS_NAME]
170 |
171 | # remove temporary directory
172 | subprocess.call(['rm', '-rf', output_dir])
173 |
174 | return frozen_graph, input_names, output_names
175 |
--------------------------------------------------------------------------------
/tf_trt_models/graph_utils.py:
--------------------------------------------------------------------------------
1 | import tensorflow as tf
2 |
3 |
4 | def make_const6(const6_name='const6'):
5 | graph = tf.Graph()
6 | with graph.as_default():
7 | tf_6 = tf.constant(dtype=tf.float32, value=6.0, name=const6_name)
8 | return graph.as_graph_def()
9 |
10 |
11 | def make_relu6(output_name, input_name, const6_name='const6'):
12 | graph = tf.Graph()
13 | with graph.as_default():
14 | tf_x = tf.placeholder(tf.float32, [10, 10], name=input_name)
15 | tf_6 = tf.constant(dtype=tf.float32, value=6.0, name=const6_name)
16 | with tf.name_scope(output_name):
17 | tf_y1 = tf.nn.relu(tf_x, name='relu1')
18 | tf_y2 = tf.nn.relu(tf.subtract(tf_x, tf_6, name='sub1'), name='relu2')
19 |
20 | #tf_y = tf.nn.relu(tf.subtract(tf_6, tf.nn.relu(tf_x, name='relu1'), name='sub'), name='relu2')
21 | #tf_y = tf.subtract(tf_6, tf_y, name=output_name)
22 | tf_y = tf.subtract(tf_y1, tf_y2, name=output_name)
23 |
24 | graph_def = graph.as_graph_def()
25 | graph_def.node[-1].name = output_name
26 |
27 | # remove unused nodes
28 | for node in graph_def.node:
29 | if node.name == input_name:
30 | graph_def.node.remove(node)
31 | for node in graph_def.node:
32 | if node.name == const6_name:
33 | graph_def.node.remove(node)
34 | for node in graph_def.node:
35 | if node.op == '_Neg':
36 | node.op = 'Neg'
37 |
38 | return graph_def
39 |
40 |
41 | def convert_relu6(graph_def, const6_name='const6'):
42 | # add constant 6
43 | has_const6 = False
44 | for node in graph_def.node:
45 | if node.name == const6_name:
46 | has_const6 = True
47 | if not has_const6:
48 | const6_graph_def = make_const6(const6_name=const6_name)
49 | graph_def.node.extend(const6_graph_def.node)
50 |
51 | for node in graph_def.node:
52 | if node.op == 'Relu6':
53 | input_name = node.input[0]
54 | output_name = node.name
55 | relu6_graph_def = make_relu6(output_name, input_name, const6_name=const6_name)
56 | graph_def.node.remove(node)
57 | graph_def.node.extend(relu6_graph_def.node)
58 |
59 | return graph_def
60 |
61 |
62 | def remove_node(graph_def, node):
63 | for n in graph_def.node:
64 | if node.name in n.input:
65 | n.input.remove(node.name)
66 | ctrl_name = '^' + node.name
67 | if ctrl_name in n.input:
68 | n.input.remove(ctrl_name)
69 | graph_def.node.remove(node)
70 |
71 |
72 | def remove_op(graph_def, op_name):
73 | matches = [node for node in graph_def.node if node.op == op_name]
74 | for match in matches:
75 | remove_node(graph_def, match)
76 |
77 |
78 | def force_nms_cpu(frozen_graph):
79 | for node in frozen_graph.node:
80 | if 'NonMaxSuppression' in node.name:
81 | node.device = '/device:CPU:0'
82 | return frozen_graph
83 |
84 |
85 | def replace_relu6(frozen_graph):
86 | return convert_relu6(frozen_graph)
87 |
88 |
89 | def remove_assert(frozen_graph):
90 | remove_op(frozen_graph, 'Assert')
91 | return frozen_graph
92 |
--------------------------------------------------------------------------------