File tree Expand file tree Collapse file tree 8 files changed +114
-4
lines changed Expand file tree Collapse file tree 8 files changed +114
-4
lines changed Original file line number Diff line number Diff line change 4
4
.idea
5
5
_models /*
6
6
_posenet_weights /*
7
+ env.sh
7
8
8
9
# Byte-compiled / optimized / DLL files
9
10
__pycache__ /
Original file line number Diff line number Diff line change 1
- FROM tensorflow/tensorflow:2.0.0-gpu-py3-jupyter
1
+ FROM tensorflow/tensorflow:nightly-py3-jupyter
2
+ # This is the CPU version!
2
3
# see: https://www.tensorflow.org/install/docker
3
4
# see: https://hub.docker.com/r/tensorflow/tensorflow/
4
5
@@ -7,6 +8,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
7
8
bzip2 \
8
9
git \
9
10
wget && \
11
+ pip install --upgrade pip && \
10
12
rm -rf /var/lib/apt/lists/*
11
13
12
14
COPY requirements.txt /work/
@@ -15,6 +17,12 @@ WORKDIR /work
15
17
16
18
RUN pip install -r requirements.txt
17
19
20
+ RUN git clone https://github.com/patlevin/tfjs-to-tf.git && \
21
+ cd tfjs-to-tf && \
22
+ pip install . && \
23
+ cd .. && \
24
+ rm -r tfjs-to-tf
25
+
18
26
ENV PYTHONPATH='/work/:$PYTHONPATH'
19
27
20
28
CMD ["bash" ]
Original file line number Diff line number Diff line change
1
+ FROM tensorflow/tensorflow:2.0.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
+ pip install --upgrade pip && \
11
+ rm -rf /var/lib/apt/lists/*
12
+
13
+ COPY requirements.txt /work/
14
+
15
+ WORKDIR /work
16
+
17
+ RUN pip install -r requirements.txt
18
+
19
+ RUN git clone https://github.com/patlevin/tfjs-to-tf.git && \
20
+ cd tfjs-to-tf && \
21
+ pip install . && \
22
+ cd .. && \
23
+ rm -r tfjs-to-tf
24
+
25
+ ENV PYTHONPATH='/work/:$PYTHONPATH'
26
+
27
+ CMD ["bash"]
Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env bash
2
2
3
- docker rmi -f posenet-python
3
+ if [ -z " $1 " ]; then
4
+ echo " pass CPU or GPU as argument"
5
+ echo " Docker image build failed..."
6
+ exit 1
7
+ fi
4
8
5
- docker build -t posenet-python -f Dockerfile .
9
+ if [ " $1 " = " GPU" ]; then
10
+ image=" posenet-python-gpu"
11
+ dockerfile=" Dockerfile-gpu"
12
+ else
13
+ image=" posenet-python-cpu"
14
+ dockerfile=" Dockerfile"
15
+ fi
16
+
17
+ docker rmi -f " $image "
18
+
19
+ docker build -t " $image " -f " $dockerfile " .
Original file line number Diff line number Diff line change 2
2
3
3
WORK=$( pwd)
4
4
5
- docker run --gpus all -it -v $WORK :/work posenet-python python " $@ "
5
+ if [ -z " $POSENET_PYTHON_DEVICE " ]; then
6
+ echo " set the environment variable POSENET_PYTHON_DEVICE to CPU or GPU, or enter your choice below:"
7
+ read -p " Enter your device (CPU or GPU): " device
8
+ if [ " $device " = " GPU" ]; then
9
+ source <( echo " export POSENET_PYTHON_DEVICE=GPU" ) ;
10
+ elif [ " $device " = " CPU" ]; then
11
+ source <( echo " export POSENET_PYTHON_DEVICE=CPU" ) ;
12
+ else
13
+ echo " Device configuration failed..."
14
+ exit 1
15
+ fi
16
+ fi
17
+
18
+
19
+ echo " device is: $POSENET_PYTHON_DEVICE "
20
+
21
+ if [ " $POSENET_PYTHON_DEVICE " = " GPU" ]; then
22
+ image=" posenet-python-gpu"
23
+ else
24
+ image=" posenet-python-cpu"
25
+ fi
26
+
27
+ docker run --gpus all -it --rm -v $WORK :/work " $image " python " $@ "
Original file line number Diff line number Diff line change
1
+ import tfjs_graph_converter as tfjs
2
+ import os
3
+
4
+
5
+ def convert (model_id , model_dir , check = False ):
6
+ tfjsdir = os .path .join ('/opt/project/_posenet_weights' , 'mobilenet_v1_101' )
7
+ tfdir = os .path .join ('/opt/project/_models' , 'model-mobilenet_v1_101_test' )
8
+ tfjs .api .graph_model_to_saved_model (tfjsdir , tfdir , ['serve' ])
Original file line number Diff line number Diff line change @@ -4,3 +4,5 @@ scipy==1.1.*
4
4
pyyaml == 3.*
5
5
opencv-python-headless == 3.4.5.20
6
6
# opencv-python==3.4.5.20
7
+ # tensorflowjs==1.3.2
8
+ tensorflowjs == 1.4.0
Original file line number Diff line number Diff line change
1
+ import posenet .converter .tfjs2tf as converter
2
+
3
+
4
+ def main ():
5
+ converter .convert ()
6
+
7
+ # have a look at: https://github.com/tensorflow/tfjs/tree/master/tfjs-converter
8
+
9
+ # see: https://stackoverflow.com/questions/58841355/bodypix-real-time-person-segmentation/59509874#59509874
10
+ # https://github.com/patlevin/tfjs-to-tf
11
+ # https://storage.googleapis.com/tfjs-models/savedmodel/bodypix/resnet50/float/model-stride16.json
12
+ # see weightsManifest.paths for the shard names:
13
+ # https://storage.googleapis.com/tfjs-models/savedmodel/bodypix/resnet50/float/group1-shard1of23.bin
14
+ # ...
15
+ # https://storage.googleapis.com/tfjs-models/savedmodel/bodypix/resnet50/float/group1-shard23of23.bin
16
+
17
+
18
+ # https://storage.googleapis.com/tfjs-models/savedmodel/bodypix/mobilenet/float/100/model-stride16.json
19
+ # see weightsManifest.paths
20
+ # "group1-shard1of4.bin",
21
+ # "group1-shard2of4.bin",
22
+ # "group1-shard3of4.bin",
23
+ # "group1-shard4of4.bin"
24
+
25
+
26
+ # https://storage.googleapis.com/tfjs-models/weights/posenet/mobilenet_v1_101/manifest.json
27
+
28
+
You can’t perform that action at this time.
0 commit comments