-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathMakefile
103 lines (81 loc) · 3.08 KB
/
Makefile
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# include .env file
include .env
# this is usefull with most python apps in dev mode because if stdout is
# buffered logs do not shows in realtime
PYTHONUNBUFFERED=1
export
# compose command to merge production file and and dev/tools overrides
COMPOSE?=docker-compose -f docker-compose.yml
.env:
cp .env.sample .env
config.yml:
cp config.yml.sample config.yml
venv:
@echo "Installing dependencies for $(PLATFORM)"
@if [ "${PLATFORM}" = 'pi' ]; then \
sudo apt install -y python3-dotenv python3-pandas python3-picamera python3-flask python3-redis python3-pip; \
sudo pip3 install -e .; \
mkdir venv; \
elif [ "${PLATFORM}" = 'jetson' ]; then \
sudo apt install -y python3-dotenv python3-redis python3-pip; \
sudo pip3 install pandas flask; \
sudo pip3 install Cython; \
sudo apt-get install -y protobuf-compiler libprotobuf-dev protobuf-compiler; \
export PATH="/usr/local/cuda/bin:$PATH"; \
export CUDA_INC_DIR="/usr/local/cuda/include"; \
pip3 install pycuda; \
sudo pip3 install -e .; \
mkdir venv; \
else \
python3 -m venv venv; \
venv/bin/pip install -U -r requirements.txt; \
venv/bin/pip install -e .; \
fi
dist:
git clone --single-branch --depth=1 --branch builds https://github.com/cristianpb/object-detection-frontend dist
push:
rsync -avz --exclude 'backend.egg-info' --exclude 'dist' --exclude '.env' --exclude 'git' --exclude 'imgs' --exclude 'models' --exclude '.mypy_cache' --exclude '.pytest_cache' --exclude 'venv' * jetson:~/object-detection/
models/ssd_mobilenet/frozen_inference_graph.pb:
curl -o ssd_mobilenet.tar.gz http://download.tensorflow.org/models/object_detection/ssd_mobilenet_v2_coco_2018_03_29.tar.gz
tar xvzf ssd_mobilenet.tar.gz -C models/ssd_mobilenet --strip-components=1
rm -rf ssd_mobilenet.tar.gz
models/yolo/yolov3-tiny.weights:
curl -o models/yolo/yolov3-tiny.weights https://pjreddie.com/media/files/yolov3-tiny.weights
models/yolo/yolov3.weights:
curl -o models/yolo/yolov3.weights https://pjreddie.com/media/files/yolov3.weights
build: venv models/ssd_mobilenet/frozen_inference_graph.pb
dev: .env config.yml dist build
@echo "Debug mode $(PLATFORM) $(PORT)"
@if [ "${PLATFORM}" = 'pi' ]; then \
DEBUG=1 FLASK_APP=backend/app.py flask run; \
elif [ "${PLATFORM}" = 'jetson' ]; then \
DEBUG=1 FLASK_APP=backend/app.py FLASK_DEBUG=1 flask run; \
else \
DEBUG=1 FLASK_APP=backend/app.py FLASK_DEBUG=1 venv/bin/flask run; \
fi
up: .env config.yml dist build
@echo "Up mode $(PLATFORM) $(PORT)"
@if [ "${PLATFORM}" = 'pi' ]; then \
DEBUG="" FLASK_APP=backend/app.py flask run; \
elif [ "${PLATFORM}" = 'jetson' ]; then \
DEBUG="" FLASK_APP=backend/app.py flask run; \
else \
DEBUG="" FLASK_APP=backend/app.py venv/bin/flask run; \
fi
heroku: dist models/ssd_mobilenet/frozen_inference_graph.pb config.yml
DEBUG="" FLASK_APP=backend/app.py flask run
nginx-dev:
$(COMPOSE) -f docker-compose-dev.yml up -d nginx
nginx-up:
$(COMPOSE) up -d nginx
nginx-down:
$(COMPOSE) stop nginx
redis-up:
$(COMPOSE) up -d redis
redis-down:
$(COMPOSE) stop redis
docker-up: nginx-up redis-up
docker-down:
$(COMPOSE) down
clean:
rm -rf venv dist