-
Notifications
You must be signed in to change notification settings - Fork 7
/
Dockerfile
64 lines (52 loc) · 2.28 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#
# Louis Mamakos <[email protected]>
# Philipp Hellmich <[email protected]>
#
# Build a container to run the edgetpu flask daemon
#
# docker build -t coral .
#
# Run it something like:
#
# docker run --restart=always --detach --name coral \
# -p 5000:5000 --device /dev/bus/usb:/dev/bus/usb coral:latest
#
# It's necessary to pass in the /dev/bus/usb device to communicate with the USB stick.
#
# You can use alternative models by putting them into a directory
# that's mounted in the container, and then starting the container,
# passing in environment variables MODEL and LABELS referring to
# the files.
FROM ubuntu:18.04
WORKDIR /tmp
RUN apt-get update && apt-get install -y python3 wget curl unzip python3-pip
# downloading library file for edgetpu and install it
RUN wget --trust-server-names -O edgetpu_api.tar.gz https://dl.google.com/coral/edgetpu_api/edgetpu_api_latest.tar.gz && \
tar xzfz edgetpu_api.tar.gz && rm edgetpu_api.tar.gz && \
cd edgetpu_api && \
sed -i.orig \
-e 's/^read USE_MAX_FREQ/USE_MAX_FREQ=y/' \
-e 's/apt-get install/apt-get install --no-install-recommends/' \
-e '/^UDEV_RULE_PATH=/,/udevadm trigger/d' \
-e 's/^OS_VERSION=.*/OS_VERSION=Ubuntu/' \
install.sh && \
apt-get update && apt-get install sudo && \
bash ./install.sh
# fetch the models. maybe figure a way to conditionalize this?
# create models subdirectory for volume mount of custom models
RUN mkdir /models && \
chdir /models && \
curl -q -O https://dl.google.com/coral/canned_models/mobilenet_ssd_v2_coco_quant_postprocess_edgetpu.tflite && \
curl -q -O https://dl.google.com/coral/canned_models/coco_labels.txt && \
curl -q -O https://dl.google.com/coral/canned_models/mobilenet_ssd_v2_face_quant_postprocess_edgetpu.tflite
RUN cd /tmp && \
wget "https://github.com/robmarkcole/coral-pi-rest-server/archive/v0.9.zip" -O /tmp/server.zip && \
unzip /tmp/server.zip && \
mv coral-pi-rest-server-0.9 /app
WORKDIR /app
RUN pip3 install --no-cache-dir -r requirements.txt
ENV MODEL=mobilenet_ssd_v2_coco_quant_postprocess_edgetpu.tflite \
LABELS=coco_labels.txt \
MODELS_DIRECTORY=/models/
EXPOSE 5000
CMD exec python3 coral-app.py --model "${MODEL}" --labels "${LABELS}" --models_directory "${MODELS_DIRECTORY}"