Skip to content

Commit 9358615

Browse files
committed
Dockerized posenet-python.
1 parent 97c6f6a commit 9358615

File tree

9 files changed

+64
-3
lines changed

9 files changed

+64
-3
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ output/*
33
.idea/*
44
.idea
55
_models/*
6+
_posenet_weights/*
67

78
# Byte-compiled / optimized / DLL files
89
__pycache__/
@@ -174,6 +175,7 @@ cmake-build-*/
174175

175176
# IntelliJ
176177
out/
178+
output.txt
177179

178180
# mpeltonen/sbt-idea plugin
179181
.idea_modules/

Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM tensorflow/tensorflow:1.15.0-gpu-py3-jupyter
2+
# see: https://www.tensorflow.org/install/docker
3+
# see: https://hub.docker.com/r/tensorflow/tensorflow/
4+
5+
# Install system packages
6+
RUN apt-get update && apt-get install -y --no-install-recommends \
7+
bzip2 \
8+
git \
9+
wget && \
10+
rm -rf /var/lib/apt/lists/*
11+
12+
COPY requirements.txt /work/
13+
14+
WORKDIR /work
15+
16+
RUN pip install -r requirements.txt
17+
18+
ENV PYTHONPATH='/work/:$PYTHONPATH'
19+
20+
CMD ["bash"]

NOTICE.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@ Modified (c) 2018 Ross Wightman
77

88
tfjs PoseNet weights and original JS code
99
Copyright 2018 Google LLC. All Rights Reserved.
10-
11-
10+
(https://github.com/tensorflow/tfjs-models | Apache License 2.0)

README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,26 @@ pip install opencv-python==3.4.5.20
2828
2929
```
3030

31+
### Using Docker
32+
33+
A convenient way to run this project is by building and running the docker image, because it has all the requirements built-in. The main
34+
requirement is that you have a Linux machine with a GPU set up with docker, the nvidia host driver and the nvidia-docker toolkit. Once set
35+
up, you can make as many images as you want with different depencencies without touching your host OS (or fiddling with conda).
36+
37+
```bash
38+
./docker_img_build.sh
39+
./get_test_images_run.sh
40+
./image_demo_run.sh
41+
```
42+
43+
Some pointers to get you going on the Linux machine setup. Most links are based on Ubuntu, but other distributions should work fine as well.
44+
* [Install docker](https://docs.docker.com/install/linux/docker-ce/ubuntu/ )
45+
* [Install the NVIDIA host driver](https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#ubuntu-installation)
46+
* remember to reboot here
47+
* [Install the NVIDIA Container Toolkit](https://github.com/NVIDIA/nvidia-docker)
48+
* check your installation: `docker run --gpus all nvidia/cuda nvidia-smi`
49+
50+
3151
### Usage
3252

3353
There are three demo apps in the root that utilize the PoseNet model. They are very basic and could definitely be improved.
@@ -56,7 +76,7 @@ The webcam demo uses OpenCV to capture images from a connected webcam. The resul
5676

5777
The original model, weights, code, etc. was created by Google and can be found at https://github.com/tensorflow/tfjs-models/tree/master/posenet
5878

59-
This port and my work is in no way related to Google.
79+
This port is initially created by Ross Wightman and is in no way related to Google.
6080

6181
The Python conversion code that started me on my way was adapted from the CoreML port at https://github.com/infocom-tpo/PoseNet-CoreML
6282

docker_img_build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
docker build -t posenet-python -f Dockerfile .

docker_run.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
WORK=$(pwd)
4+
5+
docker run --gpus all -it -v $WORK:/work posenet-python python "$@"

get_test_images_run.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
./docker_run.sh get_test_images.py

image_demo_run.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
./docker_run.sh image_demo.py --model 101 --image_dir ./images --output_dir ./output

requirements.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# scipy==1.4.1
2+
scipy==1.1.*
3+
# pyyaml==5.2
4+
pyyaml==3.*
5+
opencv-python-headless==3.4.5.20
6+
# opencv-python==3.4.5.20

0 commit comments

Comments
 (0)