Skip to content

Commit

Permalink
Merge pull request #27 from byarbrough/maker
Browse files Browse the repository at this point in the history
Maker
  • Loading branch information
byarbrough authored Nov 11, 2019
2 parents c163c61 + 8fe2edf commit 4fdd5f6
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 9 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.md
!README.md
data/*
models/*
infer/*
.git
16 changes: 11 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
FROM tensorflow/tensorflow:1.15.0-py3
# this is based on https://github.com/IntelAI/OpenVINO-model-server/blob/master/Dockerfile

WORKDIR /app

# basic install
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
libsm6 \
libxext6 \
libxrender-dev \
libgtk-3-0 \
lsb-core \
sudo

# additional python dependencies
copy requirements.txt /app
RUN pip --no-cache-dir install -r requirements.txt

# download OpenVINO
RUN curl -o GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB
RUN apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB
RUN echo "deb https://apt.repos.intel.com/openvino/2019/ all main" > /etc/apt/sources.list.d/intel-openvino-2019.list
# install OpenVINO
RUN apt-get update && apt-get install -y intel-openvino-dev-ubuntu18-2019.3.376
RUN cd /opt/intel/openvino/deployment_tools/model_optimizer/install_prerequisites/ && ./install_prerequisites_tf.sh
RUN /opt/intel/openvino/bin/setupvars.sh

# additional python dependencies
copy requirements.txt /app
RUN pip --no-cache-dir install -r requirements.txt
# enviornment setup
RUN echo source /opt/intel/openvino/bin/setupvars.sh >> /root/.bashrc
CMD ["/bin/bash", "-l"]
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ help:
@echo ' run run docker $(IMG) as $(APP) for current user: $(HOST_USER)(uid=$(HOST_UID))'
@echo ' shell open interactive shell to stopped container $(APP) for current user'
@echo ' stop stop $(APP)'
@echo ' start start $(APP)'
@echo ' test test the model with tensorflow on data in data/test'
@echo ' train train a model on data in the data/train directory'
@echo ''

all: | build run train convert_32
all: | build run train convert_32 infer

build:
sudo docker build -t $(IMG) .
Expand All @@ -63,7 +64,8 @@ convert_32:
sudo docker exec -w /app/models/openvino $(APP) python $(MO_TF) --input_model /app/models/$(MOD).pb -b $(BATCH_SIZE) --data_type FP32 --scale 255 --reverse_input_channels;

infer:
sudo docker exec $(APP) python infer/classification_sample.py -m /app/models/openvino/$(MOD).xml -nt 5 -i /app/data/infer/ -d CPU
sudo docker exec $(APP) /bin/bash -c \
". /opt/intel/openvino/bin/setupvars.sh && python infer/classification_sample.py -m /app/models/openvino/$(MOD).xml -nt 5 -i /app/data/infer/* -d CPU"

prune:
sudo docker system prune -af
Expand All @@ -74,9 +76,15 @@ rebuild:
run:
sudo docker run -u $(HOST_UID):$(HOST_GID) -it -d --mount type=bind,source=${CURDIR},destination=/app,consistency=cached --name $(APP) $(IMG);

run_root:
sudo docker run -it -d --mount type=bind,source=${CURDIR},destination=/app,consistency=cached --name $(APP) $(IMG);

shell:
sudo docker start -i $(APP)

start:
sudo docker start $(APP)

stop:
sudo docker stop $(APP)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ data
Makefile does not yet implement automated testing, so it is fine if `data/test` is empty.

### Run
To build the Docker image, train a model, and convert that model to a 32-bit OpenVINO format, simply call
To build the Docker image, train a model, and convert that model to a 32-bit OpenVINO format and run a sample inference on `infer/*`, simply call
```
make all
```
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
networkx==2.3
Pillow
SciPy
SciPy
opencv-python-headless

0 comments on commit 4fdd5f6

Please sign in to comment.