Skip to content

Commit

Permalink
added TinyYolo
Browse files Browse the repository at this point in the history
  • Loading branch information
nealvis committed Oct 31, 2017
1 parent e68fd07 commit 293d4c8
Show file tree
Hide file tree
Showing 3 changed files with 441 additions and 0 deletions.
126 changes: 126 additions & 0 deletions caffe/TinyYolo/Makefile
@@ -0,0 +1,126 @@

ifneq ($(findstring movidius, $(PYTHONPATH)), movidius)
export PYTHONPATH:=/opt/movidius/caffe/python:/opt/movidius/mvnc/python:$(PYTHONPATH)
endif

NCCOMPILE = mvNCCompile
NCPROFILE = mvNCProfile
NCCHECK = mvNCCheck

GRAPH_FILENAME = yolo_tiny.graph
GET_GRAPH = wget --no-cache -P . http://ncs-forum-uploads.s3.amazonaws.com/ncappzoo/tiny_yolo/${GRAPH_FILENAME}

PROTOTXT_FILENAME= tiny-yolo-v1.prototxt
GET_PROTOTXT = wget --no-cache -P . http://ncs-forum-uploads.s3.amazonaws.com/ncappzoo/tiny_yolo/${PROTOTXT_FILENAME}

CAFFEMODEL_FILENAME = tiny-yolo-v1_53000.caffemodel
GET_CAFFEMODEL = wget --no-cache -P . -N http://ncs-forum-uploads.s3.amazonaws.com/ncappzoo/tiny_yolo/${CAFFEMODEL_FILENAME}


.PHONY: all
all: profile compile

.PHONY: prototxt
prototxt:
@echo "\nmaking prototxt"
@if [ -e ${PROTOTXT_FILENAME} ] ; \
then \
echo "Prototxt file already exists"; \
else \
echo "Downloading Prototxt file"; \
${GET_PROTOTXT}; \
if [ -e ${PROTOTXT_FILENAME} ] ; \
then \
echo "got prototext file." ; \
else \
echo "***\nError - Could not download prototxt file. Check network and proxy settings \n***\n"; \
exit 1; \
fi ; \
fi

.PHONY: caffemodel
caffemodel:
@echo "\nmaking caffemodel"
@if [ -e ${CAFFEMODEL_FILENAME} ] ; \
then \
echo "caffemodel file already exists"; \
else \
echo "Downloading caffemodel file"; \
${GET_CAFFEMODEL}; \
if ! [ -e ${CAFFEMODEL_FILENAME} ] ; \
then \
echo "***\nError - Could not download caffemodel file. Check network and proxy settings \n***\n"; \
exit 1; \
fi ; \
fi

.PHONY: profile
profile: prototxt
@echo "\nmaking profile"
${NCPROFILE} ${PROTOTXT_FILENAME} -s 12

.PHONY: browse_profile
browse_profile: profile
@echo "\nmaking browse_profile"
@if [ -e output_report.html ] ; \
then \
firefox output_report.html & \
else \
@echo "***\nError - output_report.html not found" ; \
fi ;

.PHONY: compile
compile: prototxt caffemodel
@echo "\nmaking compile"
${NCCOMPILE} -o ${GRAPH_FILENAME} -w ${CAFFEMODEL_FILENAME} -s 12 ${PROTOTXT_FILENAME}

.PHONY: graph
graph:
@echo "\nmaking (downloading) graph"
@if [ -e ${GRAPH_FILENAME} ] ; \
then \
echo "graph file already exists"; \
else \
${GET_GRAPH}; \
if ! [ -e ${GRAPH_FILENAME} ] ; \
then \
echo "***\nError - Could not download graph file. Check network and proxy settings \n***\n"; \
exit 1; \
fi ; \
fi ;

.PHONY: run_py
run_py: compile
@echo "\nmaking run_py"
python3 ./run.py

.PHONY: help
help:
@echo "possible make targets: ";
@echo " make help - shows this message";
@echo " make all - makes the following: prototxt, profile, compile, check, cpp, run_py, run_cpp";
@echo " make prototxt - downloads and adds input shape to Caffe prototxt file";
@echo " make caffemodel - downloads the caffemodel for the network"
@echo " make compile - runs SDK compiler tool to compile the NCS graph file for the network";
@echo " make profile - runs the SDK profiler tool to profile the network creating output_report.html";
@echo " make browse_profile - runs the SDK profiler tool and brings up report in browser.";
@echo " make run_py - runs the run.py python example program";
@echo " make clean - removes all created content"

clean_caffe_model:
@echo "\nmaking clean_caffe_model"
rm -f ${PROTOTXT_FILENAME}
rm -f ${CAFFEMODEL_FILENAME}

clean: clean_caffe_model
@echo "\nmaking clean"
rm -f ${GRAPH_FILENAME}
rm -f graph
rm -f output.gv
rm -f output.gv.svg
rm -f output_report.html
rm -f output_expected.npy
rm -f zero_weights.caffemodel
rm -f output_result.npy
rm -f output_val.csv

28 changes: 28 additions & 0 deletions caffe/TinyYolo/README.md
@@ -0,0 +1,28 @@
# Introduction
The TinyYolo network can be used for object recognition and classification. See [https://pjreddie.com/darknet/yolov1/](https://pjreddie.com/darknet/yolov1/) for more information on this network.
The provided Makefile does the following
1. Downloads the Caffe prototxt file
3. Downloads the .caffemodel file which was trained.
3. Profiles and Compiles the network using the Neural Compute SDK.
4. Runs the provided run.py program that does a single inference on a provided image as an example on how to use the network using the Neural Compute API

# Makefile
Provided Makefile has various targets that help with the above mentioned tasks.

## make help
Shows available targets

## make all
Runs profile, compile.

## make profile
Runs the provided network on the NCS and generates per layer statistics that are helpful for understanding the performance of the network on the Neural Compute Stick.

## make compile
Uses the network description and the trained weights files to generate a Movidius internal 'graph' format file. This file is later used for loading the network on to the Neural Compute Stick and executing the network.

## make run_py
Runs the provided run.py python program which sends a single image to the Neural Compute Stick and receives and displays the inference results along with a GUI window showing the identified objects in the image.

## make clean
Removes all the temporary files that are created by the Makefile

0 comments on commit 293d4c8

Please sign in to comment.