Changes for 1.12 release
[platform/adaptation/npu/intel-libmvnc.git] / examples / tensorflow / inception_v1 / 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_v1_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-v1.meta
16 CONV_SCRIPT = ./inception-v1.py
17
18 INPUT_NODE_FLAG = -in=input
19 OUTPUT_NODE_FLAG = -on=InceptionV1/Logits/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 profile
36         @if [ -e output_report.html ] ; \
37         then \
38                 firefox output_report.html & \
39         else \
40                 @echo "***\nError - output_report.html not found" ; \
41         fi ; 
42
43 .PHONY: weights
44 weights:
45         @sed -i 's/\r//' ${CONV_SCRIPT}
46         @chmod +x ${CONV_SCRIPT}
47         test -f ${MODEL_FILENAME} || (${GET_WEIGHTS} && ${CONV_SCRIPT})
48
49 .PHONY: compile
50 compile: weights
51         test -f graph || ${NCCOMPILE} -s 12 ${MODEL_FILENAME} ${INPUT_NODE_FLAG} ${OUTPUT_NODE_FLAG}
52
53 .PHONY: check
54 check: weights
55         -${NCCHECK} -s 12 ${MODEL_FILENAME} ${INPUT_NODE_FLAG} ${OUTPUT_NODE_FLAG} -i ../../data/images/cat.jpg -id 829 -S 2 -M 128 -cs 0,1,2 -metric top1
56
57 .PHONY: run
58 run: compile
59         ./run.py
60
61 .PHONY: run_py
62 run_py: compile
63         ./run.py
64
65 .PHONY: help
66 help:
67         @echo "possible make targets: ";
68         @echo "  make help - shows this message";
69         @echo "  make all - makes the following: prototxt, profile, compile, check, cpp, run_py, run_cpp";
70         @echo "  make weights - downloads the trained model";
71         @echo "  make compile - runs SDK compiler tool to compile the NCS graph file for the network";
72         @echo "  make check - runs SDK checker tool to verify an NCS graph file";
73         @echo "  make profile - runs the SDK profiler tool to profile the network creating output_report.html";
74         @echo "  make browse_profile - runs the SDK profiler tool and brings up report in browser.";
75         @echo "  make run_py - runs the run.py python example program";
76         @echo "  make clean - removes all created content"
77
78
79 clean: 
80         rm -f output.gv
81         rm -f output.gv.svg
82         rm -f output_report.html
83         rm -f output_expected.npy
84         rm -f *.ckpt
85         rm -f output_result.npy
86         rm -f output_val.csv
87         rm -rf output
88