42aeb7614a7f38e18d8f5fafd4a4a667b6af0cc2
[platform/adaptation/npu/intel-libmvnc.git] / examples / tensorflow / inception_v3 / Makefile
1
2 ifneq ($(findstring movidius, $(PYTHONPATH)), movidius)
3         export PYTHONPATH:=/opt/movidius/caffe/python:$(PYTHONPATH)
4 endif
5
6 NCCOMPILE = mvNCCompile
7 NCPROFILE = mvNCProfile
8 NCCHECK   = mvNCCheck
9
10 .IGNORE: profile check compile
11
12 WEIGHTS_FILENAME = inception_v3_2016_08_28.tar.gz
13 GET_WEIGHTS = (wget http://download.tensorflow.org/models/${WEIGHTS_FILENAME} && tar zxf ${WEIGHTS_FILENAME} && rm ${WEIGHTS_FILENAME})
14
15 MODEL_FILENAME = output/inception-v3.meta
16 CONV_SCRIPT = ./inception-v3.py
17
18 INPUT_NODE_FLAG = -in=input
19 OUTPUT_NODE_FLAG = -on=InceptionV3/Predictions/Reshape_1
20
21 .PHONY: all
22 all: profile check compile
23
24 .PHONY: prereqs
25 prereqs:
26         (cd ../../data/ilsvrc12; make)
27         @sed -i 's/\r//' run.py
28         @chmod +x run.py
29
30 .PHONY: profile
31 profile: weights
32         ${NCPROFILE} -s 12 ${MODEL_FILENAME} ${INPUT_NODE_FLAG} ${OUTPUT_NODE_FLAG}
33
34 .PHONY: browse_profile
35 browse_profile: weights
36         ${NCPROFILE} -s 12 ${MODEL_FILENAME} ${INPUT_NODE_FLAG} ${OUTPUT_NODE_FLAG}
37         firefox output_report.html &
38
39 .PHONY: weights
40 weights:
41         @sed -i 's/\r//' ${CONV_SCRIPT}
42         @chmod +x ${CONV_SCRIPT}
43         test -f ${MODEL_FILENAME} || (${GET_WEIGHTS} && ${CONV_SCRIPT})
44
45 .PHONY: compile
46 compile: weights
47         test -f graph || ${NCCOMPILE} -s 12 ${MODEL_FILENAME} ${INPUT_NODE_FLAG} ${OUTPUT_NODE_FLAG}
48
49 .PHONY: check
50 check: weights
51         -${NCCHECK} -s 12 ${MODEL_FILENAME} ${INPUT_NODE_FLAG} ${OUTPUT_NODE_FLAG} -i ../../data/images/cat.jpg -id 917 -M 128 -S 2 -cs 0,1,2
52
53 .PHONY: run
54 run: compile
55         ./run.py
56
57 .PHONY: run_py
58 run_py: compile
59         ./run.py
60
61 .PHONY: help
62 help:
63         @echo "possible make targets: ";
64         @echo "  make help - shows this message";
65         @echo "  make all - makes the following: prototxt, profile, compile, check, cpp, run_py, run_cpp";
66         @echo "  make weights - downloads the trained model";
67         @echo "  make compile - runs SDK compiler tool to compile the NCS graph file for the network";
68         @echo "  make check - runs SDK checker tool to verify an NCS graph file";
69         @echo "  make profile - runs the SDK profiler tool to profile the network creating output_report.html";
70         @echo "  make browse_profile - runs the SDK profiler tool and brings up report in browser.";
71         @echo "  make run_py - runs the run.py python example program";
72         @echo "  make clean - removes all created content"
73
74 clean: 
75         rm -f output.gv
76         rm -f output.gv.svg
77         rm -f output_report.html
78         rm -f output_expected.npy
79         rm -f *.ckpt
80         rm -f output_result.npy
81         rm -f output_val.csv
82         rm -rf output
83