v1.09.00 release files
[platform/adaptation/npu/intel-libmvnc.git] / examples / caffe / GoogLeNet / Makefile
1
2 ifneq ($(findstring movidius, $(PYTHONPATH)), movidius)
3         export PYTHONPATH:=/opt/movidius/caffe/python:/opt/movidius/mvnc/python:$(PYTHONPATH)
4 endif
5
6 NCCOMPILE = mvNCCompile
7 NCPROFILE = mvNCProfile
8 NCCHECK   = mvNCCheck
9
10
11 PROTOTXT_FILENAME= deploy.prototxt
12 GET_PROTOTXT = wget -P . https://raw.githubusercontent.com/BVLC/caffe/master/models/bvlc_googlenet/deploy.prototxt
13
14 CAFFEMODEL_FILENAME = bvlc_googlenet.caffemodel
15 GET_CAFFEMODEL = wget -P . -N http://dl.caffe.berkeleyvision.org/${CAFFEMODEL_FILENAME}
16
17
18 .PHONY: all
19 all: profile check compile cpp 
20
21 .PHONY: prereqs
22 prereqs:
23         @echo "\nmaking prereqs"
24         (cd ../../data/ilsvrc12; make)
25         @sed -i 's/\r//' run.py
26         @chmod +x run.py
27
28 .PHONY: prototxt
29 prototxt: prereqs
30         @echo "\nmaking prototxt"
31         @if [ -e ${PROTOTXT_FILENAME} ] ; \
32         then \
33                 echo "Prototxt file already exists"; \
34         else \
35                 echo "Downloading Prototxt file"; \
36                 ${GET_PROTOTXT}; \
37                 if [ -e ${PROTOTXT_FILENAME} ] ; \
38                 then \
39                         echo "Adding input shape to prototxt file."; \
40                         awk 'NR <2 {print}' < ${PROTOTXT_FILENAME} > temp; cat input_shape.prototxt >> temp; awk 'NR > 7 {print}' < ${PROTOTXT_FILENAME} >> temp; mv temp ${PROTOTXT_FILENAME}; \
41                 else \
42                         echo "***\nError - Could not download prototxt file. Check network and proxy settings \n***\n"; \
43                         exit 1; \
44                 fi ; \
45         fi  
46
47 .PHONY: caffemodel
48 caffemodel: 
49         @echo "\nmaking caffemodel"
50         @if [ -e ${CAFFEMODEL_FILENAME} ] ; \
51         then \
52                 echo "caffemodel file already exists"; \
53         else \
54                 echo "Downloading caffemodel file"; \
55                 ${GET_CAFFEMODEL}; \
56                 if ! [ -e ${CAFFEMODEL_FILENAME} ] ; \
57                 then \
58                         echo "***\nError - Could not download caffemodel file. Check network and proxy settings \n***\n"; \
59                         exit 1; \
60                 fi ; \
61         fi  
62
63 .PHONY: profile
64 profile: prototxt
65         @echo "\nmaking profile"
66         ${NCPROFILE} ${PROTOTXT_FILENAME} -s 12
67
68 .PHONY: browse_profile
69 browse_profile: profile
70         @echo "\nmaking browse_profile"
71         @if [ -e output_report.html ] ; \
72         then \
73                 firefox output_report.html & \
74         else \
75                 @echo "***\nError - output_report.html not found" ; \
76         fi ; 
77
78 .PHONY: compile
79 compile: prototxt caffemodel
80         @echo "\nmaking compile"
81         ${NCCOMPILE} -w ${CAFFEMODEL_FILENAME} -s 12 ${PROTOTXT_FILENAME}
82
83 .PHONY: check
84 check: prototxt caffemodel
85         @echo "\nmaking check"
86 #-${NCCHECK} -w ${CAFFEMODEL_FILENAME} -i ../../data/images/cat.jpg -s 12 -id 281 ${PROTOTXT_FILENAME} -S 255 -M ../../data/ilsvrc12/ilsvrc_2012_mean.npy
87         ${NCCHECK} -w ${CAFFEMODEL_FILENAME} -i ../../data/images/nps_electric_guitar.png -s 12 -id 546  ${PROTOTXT_FILENAME} -S 255 -M 110
88
89 .PHONY: run
90 run: compile
91         @echo "\nmaking run"
92         ./run.py
93
94 .PHONY: run_py
95 run_py: compile
96         @echo "\nmaking run_py"
97         ./run.py
98
99 .PHONY: cpp
100 cpp: cpp/run.cpp cpp/fp16.c
101         @echo "\nmaking cpp"
102         g++ cpp/run.cpp cpp/fp16.c -o cpp/run_cpp -lmvnc
103
104 .PHONY: run_cpp
105 run_cpp: compile cpp
106         @echo "\nmaking run_cpp"
107         cd cpp; ./run_cpp; cd ..
108
109 .PHONY: help
110 help:
111         @echo "possible make targets: ";
112         @echo "  make help - shows this message";
113         @echo "  make all - makes the following: prototxt, profile, compile, check, cpp, run_py, run_cpp";
114         @echo "  make prototxt - downloads and adds input shape to Caffe prototxt file";
115         @echo "  make caffemodel - downloads the caffemodel for the network"
116         @echo "  make compile - runs SDK compiler tool to compile the NCS graph file for the network";
117         @echo "  make check - runs SDK checker tool to verify an NCS graph file";
118         @echo "  make profile - runs the SDK profiler tool to profile the network creating output_report.html";
119         @echo "  make browse_profile - runs the SDK profiler tool and brings up report in browser.";
120         @echo "  make cpp - builds the run_cpp executable example";
121         @echo "  make run_cpp - runs the run_cpp executable example program";
122         @echo "  make run_py - runs the run.py python example program";
123         @echo "  make clean - removes all created content"
124
125 clean_caffe_model:
126         @echo "\nmaking clean_caffe_model"
127         rm -f ${PROTOTXT_FILENAME}
128         rm -f ${CAFFEMODEL_FILENAME}
129
130 clean: clean_caffe_model
131         @echo "\nmaking clean"
132         rm -f graph
133         rm -f output.gv
134         rm -f output.gv.svg
135         rm -f output_report.html
136         rm -f output_expected.npy
137         rm -f zero_weights.caffemodel
138         rm -f output_result.npy
139         rm -f output_val.csv
140         rm -f cpp/run_cpp