Skip to content

Commit

Permalink
Made deployment script
Browse files Browse the repository at this point in the history
  • Loading branch information
lext committed Nov 20, 2019
1 parent d80f3bb commit 499e8de
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
snapshots_knee_grading/*
*.egg-info
*.egg-info
snapshots_release_kneel/*
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ __pycache__/
# C extensions
*.so
.idea/*
./snapshots_knee_grading/*
./snapshots_release_kneel/*
# Distribution / packaging
.Python
env/
Expand Down
14 changes: 14 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

if [ ! -d "snapshots_release_kneel" ]; then
wget http://mipt-ml.oulu.fi/models/KNEEL/snapshots_release.tar.xz
tar -xvf snapshots_release.tar.xz
rm snapshots_release.tar.xz
mv snapshots_release snapshots_release_kneel
fi

if [ ! -d "snapshots_knee_grading" ]; then
sh ./fetch_snapshots.sh
fi

docker-compose -f ./docker/docker-compose-$1.yml up
1 change: 1 addition & 0 deletions Dockerfile.cpu → docker/Dockerfile.cpu
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# KNEEL and DeepKnee inference packages share the same docker image.
FROM miptmloulu/kneel:cpu

MAINTAINER Aleksei Tiulpin, University of Oulu, Version 1.0
Expand Down
File renamed without changes.
Empty file added docker/docker-compose-cpu.yml
Empty file.
36 changes: 36 additions & 0 deletions docker/docker-compose-gpu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: "2.3"
services:
kneel:
runtime: nvidia
image: "miptmloulu/kneel:gpu"
ports:
- "5000:5000"
volumes:
- type: bind
source: ../snapshots_release_kneel # The snapshots are stored in the root directory
target: /snapshots/
read_only: true
entrypoint: ["python", "-u", "-m", "kneel.inference.app",
"--lc_snapshot_path", "/snapshots/lext-devbox_2019_07_14_16_04_41",
"--hc_snapshot_path", "/snapshots/lext-devbox_2019_07_14_19_25_40",
"--refine", "True", "--mean_std_path", "/snapshots/mean_std.npy",
"--deploy", "True", "--device", "cuda"]
deepknee-backend:
runtime: nvidia
depends_on:
- kneel
build:
context: ../
dockerfile: ./docker/Dockerfile.gpu
ports:
- "5001:5001"
volumes:
- type: bind
source: ../snapshots_knee_grading/ # The snapshots are stored in the root directory
target: /snapshots/
read_only: true
environment:
- KNEEL_ADDR=http://127.0.0.1:5000
entrypoint: ["python", "-m", "ouludeepknee.inference.app",
"--snapshots_path", "/snapshots/",
"--device", "cuda", "--deploy", "True"]
5 changes: 3 additions & 2 deletions ouludeepknee/inference/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def analyze_single_knee():
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--snapshots_path', default='')
parser.add_argument('--deploy_addr', default='0.0.0.0')
parser.add_argument('--device', default='cuda')
parser.add_argument('--sizemm', type=int, default=140)
parser.add_argument('--pad', type=int, default=300)
Expand All @@ -74,7 +75,7 @@ def analyze_single_knee():
device=args.device)

if args.deploy:
http_server = WSGIServer(('', 5001), app)
http_server = WSGIServer((args.deploy_addr, 5001), app)
http_server.serve_forever()
else:
app.run(host='', port=5001, debug=True)
app.run(host=args.deploy_addr, port=5001, debug=True)

0 comments on commit 499e8de

Please sign in to comment.