aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuan Zhao2019-10-30 22:02:26 -0500
committerYuan Zhao2019-10-30 22:02:26 -0500
commitcc826f3237dd2764226c2240f03dc5bfb90586aa (patch)
treef3a65f391fe143fc153625f4512085c1b391cc04
parentc1ed48fa12caedf24a5e83177c343852fdbf7ac9 (diff)
downloadtidl-api-cc826f3237dd2764226c2240f03dc5bfb90586aa.tar.gz
tidl-api-cc826f3237dd2764226c2240f03dc5bfb90586aa.tar.xz
tidl-api-cc826f3237dd2764226c2240f03dc5bfb90586aa.zip
Subgraph: add a mobilenet v1 example
- Using the TidlRunSubgraph() interface
-rw-r--r--examples/mobilenet_subgraph/Makefile43
-rw-r--r--examples/mobilenet_subgraph/imagenet_objects.json1005
-rw-r--r--examples/mobilenet_subgraph/main.cpp307
-rw-r--r--examples/mobilenet_subgraph/subgraph0.cfg9
4 files changed, 1364 insertions, 0 deletions
diff --git a/examples/mobilenet_subgraph/Makefile b/examples/mobilenet_subgraph/Makefile
new file mode 100644
index 0000000..aed396c
--- /dev/null
+++ b/examples/mobilenet_subgraph/Makefile
@@ -0,0 +1,43 @@
1# Copyright (c) 2018 Texas Instruments Incorporated - http://www.ti.com/
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions 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 Texas Instruments Incorporated nor the
12# names of its contributors may be used to endorse or promote products
13# derived from this software without specific prior written permission.
14#
15# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
25# THE POSSIBILITY OF SUCH DAMAGE.
26
27EXE = imagenet
28
29include ../make.common
30
31LIBS += -lopencv_highgui -lopencv_imgcodecs -lopencv_videoio\
32 -lopencv_imgproc -lopencv_core
33LIBS += -ljson-c
34
35LIBS += -L$(TIDL_API_DIR) -ltidl_api -ltidl_imgutil
36
37SOURCES = main.cpp ../common/object_classes.cpp ../common/utils.cpp \
38 ../common/video_utils.cpp
39
40$(EXE): $(HEADERS) $(SOURCES)
41 $(CXX) $(CXXFLAGS) $(SOURCES) \
42 $(LDFLAGS) $(LIBS) -o $@
43
diff --git a/examples/mobilenet_subgraph/imagenet_objects.json b/examples/mobilenet_subgraph/imagenet_objects.json
new file mode 100644
index 0000000..7a5289b
--- /dev/null
+++ b/examples/mobilenet_subgraph/imagenet_objects.json
@@ -0,0 +1,1005 @@
1{
2 "network": "imagenet",
3 "objects": [
4 { "label": "tench" },
5 { "label": "goldfish" },
6 { "label": "great_white_shark" },
7 { "label": "tiger_shark" },
8 { "label": "hammerhead" },
9 { "label": "electric_ray" },
10 { "label": "stingray" },
11 { "label": "cock" },
12 { "label": "hen" },
13 { "label": "ostrich" },
14 { "label": "brambling" },
15 { "label": "goldfinch" },
16 { "label": "house_finch" },
17 { "label": "junco" },
18 { "label": "indigo_bunting" },
19 { "label": "robin" },
20 { "label": "bulbul" },
21 { "label": "jay" },
22 { "label": "magpie" },
23 { "label": "chickadee" },
24 { "label": "water_ouzel" },
25 { "label": "kite" },
26 { "label": "bald_eagle" },
27 { "label": "vulture" },
28 { "label": "great_grey_owl" },
29 { "label": "European_fire_salamander" },
30 { "label": "common_newt" },
31 { "label": "eft" },
32 { "label": "spotted_salamander" },
33 { "label": "axolotl" },
34 { "label": "bullfrog" },
35 { "label": "tree_frog" },
36 { "label": "tailed_frog" },
37 { "label": "loggerhead" },
38 { "label": "leatherback_turtle" },
39 { "label": "mud_turtle" },
40 { "label": "terrapin" },
41 { "label": "box_turtle" },
42 { "label": "banded_gecko" },
43 { "label": "common_iguana" },
44 { "label": "American_chameleon" },
45 { "label": "whiptail" },
46 { "label": "agama" },
47 { "label": "frilled_lizard" },
48 { "label": "alligator_lizard" },
49 { "label": "Gila_monster" },
50 { "label": "green_lizard" },
51 { "label": "African_chameleon" },
52 { "label": "Komodo_dragon" },
53 { "label": "African_crocodile" },
54 { "label": "American_alligator" },
55 { "label": "triceratops" },
56 { "label": "thunder_snake" },
57 { "label": "ringneck_snake" },
58 { "label": "hognose_snake" },
59 { "label": "green_snake" },
60 { "label": "king_snake" },
61 { "label": "garter_snake" },
62 { "label": "water_snake" },
63 { "label": "vine_snake" },
64 { "label": "night_snake" },
65 { "label": "boa_constrictor" },
66 { "label": "rock_python" },
67 { "label": "Indian_cobra" },
68 { "label": "green_mamba" },
69 { "label": "sea_snake" },
70 { "label": "horned_viper" },
71 { "label": "diamondback" },
72 { "label": "sidewinder" },
73 { "label": "trilobite" },
74 { "label": "harvestman" },
75 { "label": "scorpion" },
76 { "label": "black_and_gold_garden_spider" },
77 { "label": "barn_spider" },
78 { "label": "garden_spider" },
79 { "label": "black_widow" },
80 { "label": "tarantula" },
81 { "label": "wolf_spider" },
82 { "label": "tick" },
83 { "label": "centipede" },
84 { "label": "black_grouse" },
85 { "label": "ptarmigan" },
86 { "label": "ruffed_grouse" },
87 { "label": "prairie_chicken" },
88 { "label": "peacock" },
89 { "label": "quail" },
90 { "label": "partridge" },
91 { "label": "African_grey" },
92 { "label": "macaw" },
93 { "label": "sulphur-crested_cockatoo" },
94 { "label": "lorikeet" },
95 { "label": "coucal" },
96 { "label": "bee_eater" },
97 { "label": "hornbill" },
98 { "label": "hummingbird" },
99 { "label": "jacamar" },
100 { "label": "toucan" },
101 { "label": "drake" },
102 { "label": "red-breasted_merganser" },
103 { "label": "goose" },
104 { "label": "black_swan" },
105 { "label": "tusker" },
106 { "label": "echidna" },
107 { "label": "platypus" },
108 { "label": "wallaby" },
109 { "label": "koala" },
110 { "label": "wombat" },
111 { "label": "jellyfish" },
112 { "label": "sea_anemone" },
113 { "label": "brain_coral" },
114 { "label": "flatworm" },
115 { "label": "nematode" },
116 { "label": "conch" },
117 { "label": "snail" },
118 { "label": "slug" },
119 { "label": "sea_slug" },
120 { "label": "chiton" },
121 { "label": "chambered_nautilus" },
122 { "label": "Dungeness_crab" },
123 { "label": "rock_crab" },
124 { "label": "fiddler_crab" },
125 { "label": "king_crab" },
126 { "label": "American_lobster" },
127 { "label": "spiny_lobster" },
128 { "label": "crayfish" },
129 { "label": "hermit_crab" },
130 { "label": "isopod" },
131 { "label": "white_stork" },
132 { "label": "black_stork" },
133 { "label": "spoonbill" },
134 { "label": "flamingo" },
135 { "label": "little_blue_heron" },
136 { "label": "American_egret" },
137 { "label": "bittern" },
138 { "label": "crane" },
139 { "label": "limpkin" },
140 { "label": "European_gallinule" },
141 { "label": "American_coot" },
142 { "label": "bustard" },
143 { "label": "ruddy_turnstone" },
144 { "label": "red-backed_sandpiper" },
145 { "label": "redshank" },
146 { "label": "dowitcher" },
147 { "label": "oystercatcher" },
148 { "label": "pelican" },
149 { "label": "king_penguin" },
150 { "label": "albatross" },
151 { "label": "grey_whale" },
152 { "label": "killer_whale" },
153 { "label": "dugong" },
154 { "label": "sea_lion" },
155 { "label": "Chihuahua" },
156 { "label": "Japanese_spaniel" },
157 { "label": "Maltese_dog" },
158 { "label": "Pekinese" },
159 { "label": "Shih-Tzu" },
160 { "label": "Blenheim_spaniel" },
161 { "label": "papillon" },
162 { "label": "toy_terrier" },
163 { "label": "Rhodesian_ridgeback" },
164 { "label": "Afghan_hound" },
165 { "label": "basset" },
166 { "label": "beagle" },
167 { "label": "bloodhound" },
168 { "label": "bluetick" },
169 { "label": "black-and-tan_coonhound" },
170 { "label": "Walker_hound" },
171 { "label": "English_foxhound" },
172 { "label": "redbone" },
173 { "label": "borzoi" },
174 { "label": "Irish_wolfhound" },
175 { "label": "Italian_greyhound" },
176 { "label": "whippet" },
177 { "label": "Ibizan_hound" },
178 { "label": "Norwegian_elkhound" },
179 { "label": "otterhound" },
180 { "label": "Saluki" },
181 { "label": "Scottish_deerhound" },
182 { "label": "Weimaraner" },
183 { "label": "Staffordshire_bullterrier" },
184 { "label": "American_Staffordshire_terrier" },
185 { "label": "Bedlington_terrier" },
186 { "label": "Border_terrier" },
187 { "label": "Kerry_blue_terrier" },
188 { "label": "Irish_terrier" },
189 { "label": "Norfolk_terrier" },
190 { "label": "Norwich_terrier" },
191 { "label": "Yorkshire_terrier" },
192 { "label": "wire-haired_fox_terrier" },
193 { "label": "Lakeland_terrier" },
194 { "label": "Sealyham_terrier" },
195 { "label": "Airedale" },
196 { "label": "cairn" },
197 { "label": "Australian_terrier" },
198 { "label": "Dandie_Dinmont" },
199 { "label": "Boston_bull" },
200 { "label": "miniature_schnauzer" },
201 { "label": "giant_schnauzer" },
202 { "label": "standard_schnauzer" },
203 { "label": "Scotch_terrier" },
204 { "label": "Tibetan_terrier" },
205 { "label": "silky_terrier" },
206 { "label": "soft-coated_wheaten_terrier" },
207 { "label": "West_Highland_white_terrier" },
208 { "label": "Lhasa" },
209 { "label": "flat-coated_retriever" },
210 { "label": "curly-coated_retriever" },
211 { "label": "golden_retriever" },
212 { "label": "Labrador_retriever" },
213 { "label": "Chesapeake_Bay_retriever" },
214 { "label": "German_short-haired_pointer" },
215 { "label": "vizsla" },
216 { "label": "English_setter" },
217 { "label": "Irish_setter" },
218 { "label": "Gordon_setter" },
219 { "label": "Brittany_spaniel" },
220 { "label": "clumber" },
221 { "label": "English_springer" },
222 { "label": "Welsh_springer_spaniel" },
223 { "label": "cocker_spaniel" },
224 { "label": "Sussex_spaniel" },
225 { "label": "Irish_water_spaniel" },
226 { "label": "kuvasz" },
227 { "label": "schipperke" },
228 { "label": "groenendael" },
229 { "label": "malinois" },
230 { "label": "briard" },
231 { "label": "kelpie" },
232 { "label": "komondor" },
233 { "label": "Old_English_sheepdog" },
234 { "label": "Shetland_sheepdog" },
235 { "label": "collie" },
236 { "label": "Border_collie" },
237 { "label": "Bouvier_des_Flandres" },
238 { "label": "Rottweiler" },
239 { "label": "German_shepherd" },
240 { "label": "Doberman" },
241 { "label": "miniature_pinscher" },
242 { "label": "Greater_Swiss_Mountain_dog" },
243 { "label": "Bernese_mountain_dog" },
244 { "label": "Appenzeller" },
245 { "label": "EntleBucher" },
246 { "label": "boxer" },
247 { "label": "bull_mastiff" },
248 { "label": "Tibetan_mastiff" },
249 { "label": "French_bulldog" },
250 { "label": "Great_Dane" },
251 { "label": "Saint_Bernard" },
252 { "label": "Eskimo_dog" },
253 { "label": "malamute" },
254 { "label": "Siberian_husky" },
255 { "label": "dalmatian" },
256 { "label": "affenpinscher" },
257 { "label": "basenji" },
258 { "label": "pug" },
259 { "label": "Leonberg" },
260 { "label": "Newfoundland" },
261 { "label": "Great_Pyrenees" },
262 { "label": "Samoyed" },
263 { "label": "Pomeranian" },
264 { "label": "chow" },
265 { "label": "keeshond" },
266 { "label": "Brabancon_griffon" },
267 { "label": "Pembroke" },
268 { "label": "Cardigan" },
269 { "label": "toy_poodle" },
270 { "label": "miniature_poodle" },
271 { "label": "standard_poodle" },
272 { "label": "Mexican_hairless" },
273 { "label": "timber_wolf" },
274 { "label": "white_wolf" },
275 { "label": "red_wolf" },
276 { "label": "coyote" },
277 { "label": "dingo" },
278 { "label": "dhole" },
279 { "label": "African_hunting_dog" },
280 { "label": "hyena" },
281 { "label": "red_fox" },
282 { "label": "kit_fox" },
283 { "label": "Arctic_fox" },
284 { "label": "grey_fox" },
285 { "label": "tabby" },
286 { "label": "tiger_cat" },
287 { "label": "Persian_cat" },
288 { "label": "Siamese_cat" },
289 { "label": "Egyptian_cat" },
290 { "label": "cougar" },
291 { "label": "lynx" },
292 { "label": "leopard" },
293 { "label": "snow_leopard" },
294 { "label": "jaguar" },
295 { "label": "lion" },
296 { "label": "tiger" },
297 { "label": "cheetah" },
298 { "label": "brown_bear" },
299 { "label": "American_black_bear" },
300 { "label": "ice_bear" },
301 { "label": "sloth_bear" },
302 { "label": "mongoose" },
303 { "label": "meerkat" },
304 { "label": "tiger_beetle" },
305 { "label": "ladybug" },
306 { "label": "ground_beetle" },
307 { "label": "long-horned_beetle" },
308 { "label": "leaf_beetle" },
309 { "label": "dung_beetle" },
310 { "label": "rhinoceros_beetle" },
311 { "label": "weevil" },
312 { "label": "fly" },
313 { "label": "bee" },
314 { "label": "ant" },
315 { "label": "grasshopper" },
316 { "label": "cricket" },
317 { "label": "walking_stick" },
318 { "label": "cockroach" },
319 { "label": "mantis" },
320 { "label": "cicada" },
321 { "label": "leafhopper" },
322 { "label": "lacewing" },
323 { "label": "dragonfly" },
324 { "label": "damselfly" },
325 { "label": "admiral" },
326 { "label": "ringlet" },
327 { "label": "monarch" },
328 { "label": "cabbage_butterfly" },
329 { "label": "sulphur_butterfly" },
330 { "label": "lycaenid" },
331 { "label": "starfish" },
332 { "label": "sea_urchin" },
333 { "label": "sea_cucumber" },
334 { "label": "wood_rabbit" },
335 { "label": "hare" },
336 { "label": "Angora" },
337 { "label": "hamster" },
338 { "label": "porcupine" },
339 { "label": "fox_squirrel" },
340 { "label": "marmot" },
341 { "label": "beaver" },
342 { "label": "guinea_pig" },
343 { "label": "sorrel" },
344 { "label": "zebra" },
345 { "label": "hog" },
346 { "label": "wild_boar" },
347 { "label": "warthog" },
348 { "label": "hippopotamus" },
349 { "label": "ox" },
350 { "label": "water_buffalo" },
351 { "label": "bison" },
352 { "label": "ram" },
353 { "label": "bighorn" },
354 { "label": "ibex" },
355 { "label": "hartebeest" },
356 { "label": "impala" },
357 { "label": "gazelle" },
358 { "label": "Arabian_camel" },
359 { "label": "llama" },
360 { "label": "weasel" },
361 { "label": "mink" },
362 { "label": "polecat" },
363 { "label": "black-footed_ferret" },
364 { "label": "otter" },
365 { "label": "skunk" },
366 { "label": "badger" },
367 { "label": "armadillo" },
368 { "label": "three-toed_sloth" },
369 { "label": "orangutan" },
370 { "label": "gorilla" },
371 { "label": "chimpanzee" },
372 { "label": "gibbon" },
373 { "label": "siamang" },
374 { "label": "guenon" },
375 { "label": "patas" },
376 { "label": "baboon" },
377 { "label": "macaque" },
378 { "label": "langur" },
379 { "label": "colobus" },
380 { "label": "proboscis_monkey" },
381 { "label": "marmoset" },
382 { "label": "capuchin" },
383 { "label": "howler_monkey" },
384 { "label": "titi" },
385 { "label": "spider_monkey" },
386 { "label": "squirrel_monkey" },
387 { "label": "Madagascar_cat" },
388 { "label": "indri" },
389 { "label": "Indian_elephant" },
390 { "label": "African_elephant" },
391 { "label": "lesser_panda" },
392 { "label": "giant_panda" },
393 { "label": "barracouta" },
394 { "label": "eel" },
395 { "label": "coho" },
396 { "label": "rock_beauty" },
397 { "label": "anemone_fish" },
398 { "label": "sturgeon" },
399 { "label": "gar" },
400 { "label": "lionfish" },
401 { "label": "puffer" },
402 { "label": "abacus" },
403 { "label": "abaya" },
404 { "label": "academic_gown" },
405 { "label": "accordion" },
406 { "label": "acoustic_guitar" },
407 { "label": "aircraft_carrier" },
408 { "label": "airliner" },
409 { "label": "airship" },
410 { "label": "altar" },
411 { "label": "ambulance" },
412 { "label": "amphibian" },
413 { "label": "analog_clock" },
414 { "label": "apiary" },
415 { "label": "apron" },
416 { "label": "ashcan" },
417 { "label": "assault_rifle" },
418 { "label": "backpack" },
419 { "label": "bakery" },
420 { "label": "balance_beam" },
421 { "label": "balloon" },
422 { "label": "ballpoint" },
423 { "label": "Band_Aid" },
424 { "label": "banjo" },
425 { "label": "bannister" },
426 { "label": "barbell" },
427 { "label": "barber_chair" },
428 { "label": "barbershop" },
429 { "label": "barn" },
430 { "label": "barometer" },
431 { "label": "barrel" },
432 { "label": "barrow" },
433 { "label": "baseball" },
434 { "label": "basketball" },
435 { "label": "bassinet" },
436 { "label": "bassoon" },
437 { "label": "bathing_cap" },
438 { "label": "bath_towel" },
439 { "label": "bathtub" },
440 { "label": "beach_wagon" },
441 { "label": "beacon" },
442 { "label": "beaker" },
443 { "label": "bearskin" },
444 { "label": "beer_bottle" },
445 { "label": "beer_glass" },
446 { "label": "bell_cote" },
447 { "label": "bib" },
448 { "label": "bicycle-built-for-two" },
449 { "label": "bikini" },
450 { "label": "binder" },
451 { "label": "binoculars" },
452 { "label": "birdhouse" },
453 { "label": "boathouse" },
454 { "label": "bobsled" },
455 { "label": "bolo_tie" },
456 { "label": "bonnet" },
457 { "label": "bookcase" },
458 { "label": "bookshop" },
459 { "label": "bottlecap" },
460 { "label": "bow" },
461 { "label": "bow_tie" },
462 { "label": "brass" },
463 { "label": "brassiere" },
464 { "label": "breakwater" },
465 { "label": "breastplate" },
466 { "label": "broom" },
467 { "label": "bucket" },
468 { "label": "buckle" },
469 { "label": "bulletproof_vest" },
470 { "label": "bullet_train" },
471 { "label": "butcher_shop" },
472 { "label": "cab" },
473 { "label": "caldron" },
474 { "label": "candle" },
475 { "label": "cannon" },
476 { "label": "canoe" },
477 { "label": "can_opener" },
478 { "label": "cardigan" },
479 { "label": "car_mirror" },
480 { "label": "carousel" },
481 { "label": "carpenter's_kit" },
482 { "label": "carton" },
483 { "label": "car_wheel" },
484 { "label": "cash_machine" },
485 { "label": "cassette" },
486 { "label": "cassette_player" },
487 { "label": "castle" },
488 { "label": "catamaran" },
489 { "label": "CD_player" },
490 { "label": "cello" },
491 { "label": "cellular_telephone" },
492 { "label": "chain" },
493 { "label": "chainlink_fence" },
494 { "label": "chain_mail" },
495 { "label": "chain_saw" },
496 { "label": "chest" },
497 { "label": "chiffonier" },
498 { "label": "chime" },
499 { "label": "china_cabinet" },
500 { "label": "Christmas_stocking" },
501 { "label": "church" },
502 { "label": "cinema" },
503 { "label": "cleaver" },
504 { "label": "cliff_dwelling" },
505 { "label": "cloak" },
506 { "label": "clog" },
507 { "label": "cocktail_shaker" },
508 { "label": "coffee_mug" },
509 { "label": "coffeepot" },
510 { "label": "coil" },
511 { "label": "combination_lock" },
512 { "label": "computer_keyboard" },
513 { "label": "confectionery" },
514 { "label": "container_ship" },
515 { "label": "convertible" },
516 { "label": "corkscrew" },
517 { "label": "cornet" },
518 { "label": "cowboy_boot" },
519 { "label": "cowboy_hat" },
520 { "label": "cradle" },
521 { "label": "crane" },
522 { "label": "crash_helmet" },
523 { "label": "crate" },
524 { "label": "crib" },
525 { "label": "Crock_Pot" },
526 { "label": "croquet_ball" },
527 { "label": "crutch" },
528 { "label": "cuirass" },
529 { "label": "dam" },
530 { "label": "desk" },
531 { "label": "desktop_computer" },
532 { "label": "dial_telephone" },
533 { "label": "diaper" },
534 { "label": "digital_clock" },
535 { "label": "digital_watch" },
536 { "label": "dining_table" },
537 { "label": "dishrag" },
538 { "label": "dishwasher" },
539 { "label": "disk_brake" },
540 { "label": "dock" },
541 { "label": "dogsled" },
542 { "label": "dome" },
543 { "label": "doormat" },
544 { "label": "drilling_platform" },
545 { "label": "drum" },
546 { "label": "drumstick" },
547 { "label": "dumbbell" },
548 { "label": "Dutch_oven" },
549 { "label": "electric_fan" },
550 { "label": "electric_guitar" },
551 { "label": "electric_locomotive" },
552 { "label": "entertainment_center" },
553 { "label": "envelope" },
554 { "label": "espresso_maker" },
555 { "label": "face_powder" },
556 { "label": "feather_boa" },
557 { "label": "file" },
558 { "label": "fireboat" },
559 { "label": "fire_engine" },
560 { "label": "fire_screen" },
561 { "label": "flagpole" },
562 { "label": "flute" },
563 { "label": "folding_chair" },
564 { "label": "football_helmet" },
565 { "label": "forklift" },
566 { "label": "fountain" },
567 { "label": "fountain_pen" },
568 { "label": "four-poster" },
569 { "label": "freight_car" },
570 { "label": "French_horn" },
571 { "label": "frying_pan" },
572 { "label": "fur_coat" },
573 { "label": "garbage_truck" },
574 { "label": "gasmask" },
575 { "label": "gas_pump" },
576 { "label": "goblet" },
577 { "label": "go-kart" },
578 { "label": "golf_ball" },
579 { "label": "golfcart" },
580 { "label": "gondola" },
581 { "label": "gong" },
582 { "label": "gown" },
583 { "label": "grand_piano" },
584 { "label": "greenhouse" },
585 { "label": "grille" },
586 { "label": "grocery_store" },
587 { "label": "guillotine" },
588 { "label": "hair_slide" },
589 { "label": "hair_spray" },
590 { "label": "half_track" },
591 { "label": "hammer" },
592 { "label": "hamper" },
593 { "label": "hand_blower" },
594 { "label": "hand-held_computer" },
595 { "label": "handkerchief" },
596 { "label": "hard_disc" },
597 { "label": "harmonica" },
598 { "label": "harp" },
599 { "label": "harvester" },
600 { "label": "hatchet" },
601 { "label": "holster" },
602 { "label": "home_theater" },
603 { "label": "honeycomb" },
604 { "label": "hook" },
605 { "label": "hoopskirt" },
606 { "label": "horizontal_bar" },
607 { "label": "horse_cart" },
608 { "label": "hourglass" },
609 { "label": "iPod" },
610 { "label": "iron" },
611 { "label": "jack-o'-lantern" },
612 { "label": "jean" },
613 { "label": "jeep" },
614 { "label": "jersey" },
615 { "label": "jigsaw_puzzle" },
616 { "label": "jinrikisha" },
617 { "label": "joystick" },
618 { "label": "kimono" },
619 { "label": "knee_pad" },
620 { "label": "knot" },
621 { "label": "lab_coat" },
622 { "label": "ladle" },
623 { "label": "lampshade" },
624 { "label": "laptop" },
625 { "label": "lawn_mower" },
626 { "label": "lens_cap" },
627 { "label": "letter_opener" },
628 { "label": "library" },
629 { "label": "lifeboat" },
630 { "label": "lighter" },
631 { "label": "limousine" },
632 { "label": "liner" },
633 { "label": "lipstick" },
634 { "label": "Loafer" },
635 { "label": "lotion" },
636 { "label": "loudspeaker" },
637 { "label": "loupe" },
638 { "label": "lumbermill" },
639 { "label": "magnetic_compass" },
640 { "label": "mailbag" },
641 { "label": "mailbox" },
642 { "label": "maillot" },
643 { "label": "maillot" },
644 { "label": "manhole_cover" },
645 { "label": "maraca" },
646 { "label": "marimba" },
647 { "label": "mask" },
648 { "label": "matchstick" },
649 { "label": "maypole" },
650 { "label": "maze" },
651 { "label": "measuring_cup" },
652 { "label": "medicine_chest" },
653 { "label": "megalith" },
654 { "label": "microphone" },
655 { "label": "microwave" },
656 { "label": "military_uniform" },
657 { "label": "milk_can" },
658 { "label": "minibus" },
659 { "label": "miniskirt" },
660 { "label": "minivan" },
661 { "label": "missile" },
662 { "label": "mitten" },
663 { "label": "mixing_bowl" },
664 { "label": "mobile_home" },
665 { "label": "Model_T" },
666 { "label": "modem" },
667 { "label": "monastery" },
668 { "label": "monitor" },
669 { "label": "moped" },
670 { "label": "mortar" },
671 { "label": "mortarboard" },
672 { "label": "mosque" },
673 { "label": "mosquito_net" },
674 { "label": "motor_scooter" },
675 { "label": "mountain_bike" },
676 { "label": "mountain_tent" },
677 { "label": "mouse" },
678 { "label": "mousetrap" },
679 { "label": "moving_van" },
680 { "label": "muzzle" },
681 { "label": "nail" },
682 { "label": "neck_brace" },
683 { "label": "necklace" },
684 { "label": "nipple" },
685 { "label": "notebook" },
686 { "label": "obelisk" },
687 { "label": "oboe" },
688 { "label": "ocarina" },
689 { "label": "odometer" },
690 { "label": "oil_filter" },
691 { "label": "organ" },
692 { "label": "oscilloscope" },
693 { "label": "overskirt" },
694 { "label": "oxcart" },
695 { "label": "oxygen_mask" },
696 { "label": "packet" },
697 { "label": "paddle" },
698 { "label": "paddlewheel" },
699 { "label": "padlock" },
700 { "label": "paintbrush" },
701 { "label": "pajama" },
702 { "label": "palace" },
703 { "label": "panpipe" },
704 { "label": "paper_towel" },
705 { "label": "parachute" },
706 { "label": "parallel_bars" },
707 { "label": "park_bench" },
708 { "label": "parking_meter" },
709 { "label": "passenger_car" },
710 { "label": "patio" },
711 { "label": "pay-phone" },
712 { "label": "pedestal" },
713 { "label": "pencil_box" },
714 { "label": "pencil_sharpener" },
715 { "label": "perfume" },
716 { "label": "Petri_dish" },
717 { "label": "photocopier" },
718 { "label": "pick" },
719 { "label": "pickelhaube" },
720 { "label": "picket_fence" },
721 { "label": "pickup" },
722 { "label": "pier" },
723 { "label": "piggy_bank" },
724 { "label": "pill_bottle" },
725 { "label": "pillow" },
726 { "label": "ping-pong_ball" },
727 { "label": "pinwheel" },
728 { "label": "pirate" },
729 { "label": "pitcher" },
730 { "label": "plane" },
731 { "label": "planetarium" },
732 { "label": "plastic_bag" },
733 { "label": "plate_rack" },
734 { "label": "plow" },
735 { "label": "plunger" },
736 { "label": "Polaroid_camera" },
737 { "label": "pole" },
738 { "label": "police_van" },
739 { "label": "poncho" },
740 { "label": "pool_table" },
741 { "label": "pop_bottle" },
742 { "label": "pot" },
743 { "label": "potter's_wheel" },
744 { "label": "power_drill" },
745 { "label": "prayer_rug" },
746 { "label": "printer" },
747 { "label": "prison" },
748 { "label": "projectile" },
749 { "label": "projector" },
750 { "label": "puck" },
751 { "label": "punching_bag" },
752 { "label": "purse" },
753 { "label": "quill" },
754 { "label": "quilt" },
755 { "label": "racer" },
756 { "label": "racket" },
757 { "label": "radiator" },
758 { "label": "radio" },
759 { "label": "radio_telescope" },
760 { "label": "rain_barrel" },
761 { "label": "recreational_vehicle" },
762 { "label": "reel" },
763 { "label": "reflex_camera" },
764 { "label": "refrigerator" },
765 { "label": "remote_control" },
766 { "label": "restaurant" },
767 { "label": "revolver" },
768 { "label": "rifle" },
769 { "label": "rocking_chair" },
770 { "label": "rotisserie" },
771 { "label": "rubber_eraser" },
772 { "label": "rugby_ball" },
773 { "label": "rule" },
774 { "label": "running_shoe" },
775 { "label": "safe" },
776 { "label": "safety_pin" },
777 { "label": "saltshaker" },
778 { "label": "sandal" },
779 { "label": "sarong" },
780 { "label": "sax" },
781 { "label": "scabbard" },
782 { "label": "scale" },
783 { "label": "school_bus" },
784 { "label": "schooner" },
785 { "label": "scoreboard" },
786 { "label": "screen" },
787 { "label": "screw" },
788 { "label": "screwdriver" },
789 { "label": "seat_belt" },
790 { "label": "sewing_machine" },
791 { "label": "shield" },
792 { "label": "shoe_shop" },
793 { "label": "shoji" },
794 { "label": "shopping_basket" },
795 { "label": "shopping_cart" },
796 { "label": "shovel" },
797 { "label": "shower_cap" },
798 { "label": "shower_curtain" },
799 { "label": "ski" },
800 { "label": "ski_mask" },
801 { "label": "sleeping_bag" },
802 { "label": "slide_rule" },
803 { "label": "sliding_door" },
804 { "label": "slot" },
805 { "label": "snorkel" },
806 { "label": "snowmobile" },
807 { "label": "snowplow" },
808 { "label": "soap_dispenser" },
809 { "label": "soccer_ball" },
810 { "label": "sock" },
811 { "label": "solar_dish" },
812 { "label": "sombrero" },
813 { "label": "soup_bowl" },
814 { "label": "space_bar" },
815 { "label": "space_heater" },
816 { "label": "space_shuttle" },
817 { "label": "spatula" },
818 { "label": "speedboat" },
819 { "label": "spider_web" },
820 { "label": "spindle" },
821 { "label": "sports_car" },
822 { "label": "spotlight" },
823 { "label": "stage" },
824 { "label": "steam_locomotive" },
825 { "label": "steel_arch_bridge" },
826 { "label": "steel_drum" },
827 { "label": "stethoscope" },
828 { "label": "stole" },
829 { "label": "stone_wall" },
830 { "label": "stopwatch" },
831 { "label": "stove" },
832 { "label": "strainer" },
833 { "label": "streetcar" },
834 { "label": "stretcher" },
835 { "label": "studio_couch" },
836 { "label": "stupa" },
837 { "label": "submarine" },
838 { "label": "suit" },
839 { "label": "sundial" },
840 { "label": "sunglass" },
841 { "label": "sunglasses" },
842 { "label": "sunscreen" },
843 { "label": "suspension_bridge" },
844 { "label": "swab" },
845 { "label": "sweatshirt" },
846 { "label": "swimming_trunks" },
847 { "label": "swing" },
848 { "label": "switch" },
849 { "label": "syringe" },
850 { "label": "table_lamp" },
851 { "label": "tank" },
852 { "label": "tape_player" },
853 { "label": "teapot" },
854 { "label": "teddy" },
855 { "label": "television" },
856 { "label": "tennis_ball" },
857 { "label": "thatch" },
858 { "label": "theater_curtain" },
859 { "label": "thimble" },
860 { "label": "thresher" },
861 { "label": "throne" },
862 { "label": "tile_roof" },
863 { "label": "toaster" },
864 { "label": "tobacco_shop" },
865 { "label": "toilet_seat" },
866 { "label": "torch" },
867 { "label": "totem_pole" },
868 { "label": "tow_truck" },
869 { "label": "toyshop" },
870 { "label": "tractor" },
871 { "label": "trailer_truck" },
872 { "label": "tray" },
873 { "label": "trench_coat" },
874 { "label": "tricycle" },
875 { "label": "trimaran" },
876 { "label": "tripod" },
877 { "label": "triumphal_arch" },
878 { "label": "trolleybus" },
879 { "label": "trombone" },
880 { "label": "tub" },
881 { "label": "turnstile" },
882 { "label": "typewriter_keyboard" },
883 { "label": "umbrella" },
884 { "label": "unicycle" },
885 { "label": "upright" },
886 { "label": "vacuum" },
887 { "label": "vase" },
888 { "label": "vault" },
889 { "label": "velvet" },
890 { "label": "vending_machine" },
891 { "label": "vestment" },
892 { "label": "viaduct" },
893 { "label": "violin" },
894 { "label": "volleyball" },
895 { "label": "waffle_iron" },
896 { "label": "wall_clock" },
897 { "label": "wallet" },
898 { "label": "wardrobe" },
899 { "label": "warplane" },
900 { "label": "washbasin" },
901 { "label": "washer" },
902 { "label": "water_bottle" },
903 { "label": "water_jug" },
904 { "label": "water_tower" },
905 { "label": "whiskey_jug" },
906 { "label": "whistle" },
907 { "label": "wig" },
908 { "label": "window_screen" },
909 { "label": "window_shade" },
910 { "label": "Windsor_tie" },
911 { "label": "wine_bottle" },
912 { "label": "wing" },
913 { "label": "wok" },
914 { "label": "wooden_spoon" },
915 { "label": "wool" },
916 { "label": "worm_fence" },
917 { "label": "wreck" },
918 { "label": "yawl" },
919 { "label": "yurt" },
920 { "label": "web_site" },
921 { "label": "comic_book" },
922 { "label": "crossword_puzzle" },
923 { "label": "street_sign" },
924 { "label": "traffic_light" },
925 { "label": "book_jacket" },
926 { "label": "menu" },
927 { "label": "plate" },
928 { "label": "guacamole" },
929 { "label": "consomme" },
930 { "label": "hot_pot" },
931 { "label": "trifle" },
932 { "label": "ice_cream" },
933 { "label": "ice_lolly" },
934 { "label": "French_loaf" },
935 { "label": "bagel" },
936 { "label": "pretzel" },
937 { "label": "cheeseburger" },
938 { "label": "hotdog" },
939 { "label": "mashed_potato" },
940 { "label": "head_cabbage" },
941 { "label": "broccoli" },
942 { "label": "cauliflower" },
943 { "label": "zucchini" },
944 { "label": "spaghetti_squash" },
945 { "label": "acorn_squash" },
946 { "label": "butternut_squash" },
947 { "label": "cucumber" },
948 { "label": "artichoke" },
949 { "label": "bell_pepper" },
950 { "label": "cardoon" },
951 { "label": "mushroom" },
952 { "label": "Granny_Smith" },
953 { "label": "strawberry" },
954 { "label": "orange" },
955 { "label": "lemon" },
956 { "label": "fig" },
957 { "label": "pineapple" },
958 { "label": "banana" },
959 { "label": "jackfruit" },
960 { "label": "custard_apple" },
961 { "label": "pomegranate" },
962 { "label": "hay" },
963 { "label": "carbonara" },
964 { "label": "chocolate_sauce" },
965 { "label": "dough" },
966 { "label": "meat_loaf" },
967 { "label": "pizza" },
968 { "label": "potpie" },
969 { "label": "burrito" },
970 { "label": "red_wine" },
971 { "label": "espresso" },
972 { "label": "cup" },
973 { "label": "eggnog" },
974 { "label": "alp" },
975 { "label": "bubble" },
976 { "label": "cliff" },
977 { "label": "coral_reef" },
978 { "label": "geyser" },
979 { "label": "lakeside" },
980 { "label": "promontory" },
981 { "label": "sandbar" },
982 { "label": "seashore" },
983 { "label": "valley" },
984 { "label": "volcano" },
985 { "label": "ballplayer" },
986 { "label": "groom" },
987 { "label": "scuba_diver" },
988 { "label": "rapeseed" },
989 { "label": "daisy" },
990 { "label": "yellow_lady's_slipper" },
991 { "label": "corn" },
992 { "label": "acorn" },
993 { "label": "hip" },
994 { "label": "buckeye" },
995 { "label": "coral_fungus" },
996 { "label": "agaric" },
997 { "label": "gyromitra" },
998 { "label": "stinkhorn" },
999 { "label": "earthstar" },
1000 { "label": "hen-of-the-woods" },
1001 { "label": "bolete" },
1002 { "label": "ear" },
1003 { "label": "toilet_tissue" }
1004 ]
1005}
diff --git a/examples/mobilenet_subgraph/main.cpp b/examples/mobilenet_subgraph/main.cpp
new file mode 100644
index 0000000..c5da647
--- /dev/null
+++ b/examples/mobilenet_subgraph/main.cpp
@@ -0,0 +1,307 @@
1/******************************************************************************
2 * Copyright (c) 2018, Texas Instruments Incorporated - http://www.ti.com/
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of Texas Instruments Incorporated nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
26 * THE POSSIBILITY OF SUCH DAMAGE.
27 *****************************************************************************/
28#include <signal.h>
29#include <iostream>
30#include <iomanip>
31#include <fstream>
32#include <cassert>
33#include <string>
34#include <functional>
35#include <algorithm>
36#include <time.h>
37#include <unistd.h>
38
39#include <queue>
40#include <vector>
41#include <chrono>
42
43#include "executor.h"
44#include "execution_object.h"
45#include "execution_object_pipeline.h"
46#include "subgraph_runtime.h"
47#include "configuration.h"
48#include "../common/object_classes.h"
49#include "imgutil.h"
50#include "../common/video_utils.h"
51
52#include "opencv2/core.hpp"
53#include "opencv2/imgproc.hpp"
54#include "opencv2/highgui.hpp"
55#include "opencv2/videoio.hpp"
56
57using namespace std;
58using namespace tidl;
59using namespace cv;
60
61#define NUM_VIDEO_FRAMES 300
62#define DEFAULT_CONFIG "j11_v2"
63#define NUM_DEFAULT_INPUTS 1
64#define DEFAULT_OBJECT_CLASSES_LIST_FILE "imagenet_objects.json"
65#define DEFAULT_OUTPUT_PROB_THRESHOLD 5
66const char *default_inputs[NUM_DEFAULT_INPUTS] =
67{
68 "../test/testvecs/input/objects/cat-pet-animal-domestic-104827.jpeg"
69};
70std::unique_ptr<ObjectClasses> object_classes;
71
72bool RunConfiguration(cmdline_opts_t& opts);
73bool ReadFrame(const cmdline_opts_t& opts, VideoCapture &cap, float** inputs);
74bool WriteFrameOutput(float *out, const cmdline_opts_t& opts);
75void DisplayHelp();
76
77
78int main(int argc, char *argv[])
79{
80 // Catch ctrl-c to ensure a clean exit
81 signal(SIGABRT, exit);
82 signal(SIGTERM, exit);
83
84 // If there are no devices capable of offloading TIDL on the SoC, exit
85 uint32_t num_eves = Executor::GetNumDevices(DeviceType::EVE);
86 uint32_t num_dsps = Executor::GetNumDevices(DeviceType::DSP);
87 if (num_eves == 0 && num_dsps == 0)
88 {
89 cout << "TI DL not supported on this SoC." << endl;
90 return EXIT_SUCCESS;
91 }
92
93 // Process arguments
94 cmdline_opts_t opts;
95 opts.config = DEFAULT_CONFIG;
96 opts.object_classes_list_file = DEFAULT_OBJECT_CLASSES_LIST_FILE;
97 opts.output_prob_threshold = DEFAULT_OUTPUT_PROB_THRESHOLD;
98 if (num_eves != 0) { opts.num_eves = 1; opts.num_dsps = 0; }
99 else { opts.num_eves = 0; opts.num_dsps = 1; }
100 if (! ProcessArgs(argc, argv, opts))
101 {
102 DisplayHelp();
103 exit(EXIT_SUCCESS);
104 }
105 assert(opts.num_dsps != 0 || opts.num_eves != 0);
106 if (opts.num_frames == 0)
107 opts.num_frames = (opts.is_camera_input || opts.is_video_input) ?
108 NUM_VIDEO_FRAMES : 1;
109 if (opts.input_file.empty())
110 cout << "Input: " << default_inputs[0] << endl;
111 else
112 cout << "Input: " << opts.input_file << endl;
113
114 // Get object classes list
115 object_classes = std::unique_ptr<ObjectClasses>(
116 new ObjectClasses(opts.object_classes_list_file));
117 if (object_classes->GetNumClasses() == 0)
118 {
119 cout << "No object classes defined for this config." << endl;
120 return EXIT_FAILURE;
121 }
122
123 // Run network
124 bool status = RunConfiguration(opts);
125 if (!status)
126 {
127 cout << "imagenet FAILED" << endl;
128 return EXIT_FAILURE;
129 }
130
131 cout << "imagenet PASSED" << endl;
132 return EXIT_SUCCESS;
133}
134
135bool RunConfiguration(cmdline_opts_t& opts)
136{
137 bool status = true;
138
139 // setup camera/video input/output
140 VideoCapture cap;
141 if (! SetVideoInputOutput(cap, opts, "ImageNet")) return false;
142
143 try
144 {
145 float **inputs = new float *[1];
146 inputs[0] = new float[1*3*224*224];
147 float **outputs = new float *[1];
148 outputs[0] = new float[1001];
149
150 for (int i = 0; i < 5; i ++)
151 {
152 chrono::time_point<chrono::steady_clock> tloop0, tloop1;
153 tloop0 = chrono::steady_clock::now();
154
155 ReadFrame(opts, cap, inputs);
156 TidlRunSubgraph(1, 0, 1, 1, inputs, outputs);
157 WriteFrameOutput(outputs[0], opts);
158
159 tloop1 = chrono::steady_clock::now();
160 chrono::duration<float> elapsed = tloop1 - tloop0;
161 cout << "Frame " << i
162 << " time (including read/write/opencv/print/etc): "
163 << setw(6) << setprecision(4)
164 << (elapsed.count() * 1000) << "ms" << endl;
165 }
166
167 delete [] inputs[0];
168 delete [] inputs;
169 delete [] outputs[0];
170 delete [] outputs;
171 }
172 catch (tidl::Exception &e)
173 {
174 cerr << e.what() << endl;
175 status = false;
176 }
177
178 return status;
179}
180
181
182bool ReadFrame(const cmdline_opts_t& opts, VideoCapture &cap, float** inputs)
183{
184 Configuration c;
185 c.inNumChannels = 3;;
186 c.inWidth = 224;
187 c.inHeight = 224;
188 c.preProcType = 2;
189 SubgraphDataConv in_conv{{true}, {128.0f}, {false}, {1,3,224,224}};
190
191 char* frame_buffer = new char[3*224*224];
192 assert (frame_buffer != nullptr);
193
194 Mat image;
195 if (! opts.is_camera_input && ! opts.is_video_input)
196 {
197 if (opts.input_file.empty())
198 image = cv::imread(default_inputs[0],
199 CV_LOAD_IMAGE_COLOR);
200 else
201 image = cv::imread(opts.input_file, CV_LOAD_IMAGE_COLOR);
202 if (image.empty())
203 {
204 cerr << "Unable to read input image" << endl;
205 return false;
206 }
207 }
208 else
209 {
210 Mat v_image;
211 if (! cap.grab()) return false;
212 if (! cap.retrieve(v_image)) return false;
213 int orig_width = v_image.cols;
214 int orig_height = v_image.rows;
215 // Crop camera/video input to center 256x256 input
216 if (orig_width > 256 && orig_height > 256)
217 {
218 image = Mat(v_image, Rect((orig_width-256)/2, (orig_height-256)/2,
219 256, 256));
220 }
221 else
222 image = v_image;
223 cv::imshow("ImageNet", image);
224 waitKey(2);
225 }
226
227 // TI DL image preprocessing, into frame_buffer
228 bool status = imgutil::PreprocessImage(image, frame_buffer, c);
229 std::vector<float *> in_data_v{inputs[0]};
230 in_conv.ScaleDequant((const uint8_t *)frame_buffer, in_data_v);
231 delete [] frame_buffer;
232 return status;
233}
234
235// Display top 5 classified imagenet classes with probabilities 5% or higher
236bool WriteFrameOutput(float *out, const cmdline_opts_t& opts)
237{
238 const int k = 5;
239 int out_size = 1001;
240 // Tensorflow trained network outputs 1001 probabilities,
241 // with 0-index being background, thus we need to subtract 1 when
242 // reporting classified object from 1000 categories
243 int background_offset = out_size == 1001 ? 1 : 0;
244
245 // sort and get k largest values and corresponding indices
246 typedef pair<float, int> val_index;
247 auto cmp = [](val_index &left, val_index &right)
248 { return left.first > right.first; };
249 priority_queue<val_index, vector<val_index>, decltype(cmp)> queue(cmp);
250 // initialize priority queue with smallest value on top
251 for (int i = 0; i < k; i++)
252 queue.push(val_index(out[i], i));
253
254 // for rest output, if larger than current min, pop min, push new val
255 for (int i = k; i < out_size; i++)
256 {
257 if (out[i] > queue.top().first)
258 {
259 queue.pop();
260 queue.push(val_index(out[i], i));
261 }
262 }
263
264 // output top k values in reverse order: largest val first
265 vector<val_index> sorted;
266 while (! queue.empty())
267 {
268 sorted.push_back(queue.top());
269 queue.pop();
270 }
271
272 for (int i = k - 1; i >= 0; i--)
273 {
274 if (sorted[i].first * 100 < opts.output_prob_threshold) break;
275 int imagenet_index = sorted[i].second - background_offset;
276 cout << k-i << ": [" << imagenet_index << "] "
277 << object_classes->At(imagenet_index).label
278 << ", prob = " << setprecision(4)
279 << (sorted[i].first * 100) << "%" << endl;
280 }
281
282 return true;
283}
284
285void DisplayHelp()
286{
287 cout <<
288 "Usage: imagenet\n"
289 " Will run imagenet network to predict top 5 object"
290 " classes for the input.\n Use -c to run a"
291 " different imagenet network. Default is j11_v2.\n"
292 "Optional arguments:\n"
293 " -c <config> Valid configs: j11_bn, j11_prelu, j11_v2\n"
294 " -d <number> Number of dsp cores to use\n"
295 " -e <number> Number of eve cores to use\n"
296 " -i <image> Path to the image file as input\n"
297 " -i camera<number> Use camera as input\n"
298 " video input port: /dev/video<number>\n"
299 " -i <name>.{mp4,mov,avi} Use video file as input\n"
300 " -l <objects_list> Path to the object classes list file\n"
301 " -f <number> Number of frames to process\n"
302 " -p <number> Output probablity threshold in percentage\n"
303 " Default is 5 percent or higher.\n"
304 " -v Verbose output during execution\n"
305 " -h Help\n";
306}
307
diff --git a/examples/mobilenet_subgraph/subgraph0.cfg b/examples/mobilenet_subgraph/subgraph0.cfg
new file mode 100644
index 0000000..17c20bf
--- /dev/null
+++ b/examples/mobilenet_subgraph/subgraph0.cfg
@@ -0,0 +1,9 @@
1numFrames = 1
2preProcType = 2
3inData = "../test/testvecs/input/preproc_2_224x224.y"
4outData = "./stats_tool_out.bin"
5netBinFile = "../test/testvecs/config/tidl_models/tidl_net_mobilenet_1_224.bin"
6paramsBinFile = "../test/testvecs/config/tidl_models/tidl_param_mobilenet_1_224.bin"
7inWidth = 224
8inHeight = 224
9inNumChannels = 3