Skip to content

Commit c112464

Browse files
Feature/setup script (#25)
* add model download script * actuall install dependencies * add script to docs
1 parent d8ca2e6 commit c112464

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed

docs/closed_set.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
## Setting up
44

5+
We have a new script that will handle installing the required dependencies and downloading some useful model weights. You can run this with
6+
```shell
7+
bash install/setup.sh
8+
```
9+
after cloning the repository.
10+
It *mostly* follows the minimal depedency setup instructions below.
11+
512
### Getting Dependencies
613

714
Using dense 2D (closed-set) semantic-segmentation models requires CUDA and TensorRT.

install/setup.sh

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/bin/bash
2+
3+
# Installs dependencies for building and running closed-set models
4+
# Usage: ./setup.sh [--no-models] [--no-closed-set] [--no-cuda]"
5+
#
6+
# This installs a minimal set of dependencies that *should* work, but YMMV.
7+
# Note: CUDA is hard-coded to install the 24.04 keyring and repos.
8+
#
9+
# Options:
10+
# --no-models: Do not download model weights
11+
# --no-closed-set: Do not install closed-set dependencies
12+
# --no-cuda: Do not install the CUDA keyring (if you already have CUDA set up)
13+
# -h/--help: Show brief usage information
14+
15+
function download_model() {
16+
if [[ ! -e $HOME/.semantic_inference/$1 ]]; then
17+
echo "Downloading '$1'..."
18+
pipx run gdown -q --fuzzy "$2" --output "$HOME"/.semantic_inference/"$1"
19+
fi
20+
}
21+
22+
MODELS=true # Download models
23+
CLOSED_SET=true # Install closed-set deps
24+
CUDA=true # Install cuda key
25+
while [[ $# -gt 0 ]]; do
26+
case $1 in
27+
--no-models)
28+
MODELS=false
29+
;;
30+
--no-closed-set)
31+
CLOSED_SET=false
32+
;;
33+
--no-cuda)
34+
CUDA=false
35+
;;
36+
--help|-h)
37+
echo "Usage: ./setup.sh [--no-models] [--no-closed-set] [--no-cuda]"
38+
exit 0
39+
esac
40+
shift
41+
done
42+
43+
if [ "$CLOSED_SET" = true ]; then
44+
if [ "$CUDA" = true ]; then
45+
# TODO(nathan) grab actual release info to pick correct platform
46+
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-keyring_1.1-1_all.deb -O /tmp/cuda-keyring_1.1-1_all.deb
47+
sudo dpkg -i /tmp/cuda-keyring_1.1-1_all.deb
48+
fi
49+
50+
sudo apt update
51+
version_info=$(apt-cache policy libnvinfer-dev)
52+
regex=" +Candidate: +[0-9.\-]+\+cuda([0-9]+)\.([0-9]+)"
53+
if [[ $version_info =~ $regex ]]; then
54+
version="${BASH_REMATCH[1]}"
55+
minor_version="${BASH_REMATCH[2]}"
56+
else
57+
echo "Could not find CUDA version!"
58+
exit 1
59+
fi
60+
61+
sudo apt install libnvinfer-dev libnvonnxparsers-dev libnvinfer-plugin-dev "cuda-nvcc-${version}-${minor_version}" -y
62+
fi
63+
64+
if [ "$MODELS" = true ]; then
65+
mkdir -p "$HOME"/.semantic_inference/
66+
download_model ade20k-efficientvit_seg_l2.onnx https://drive.google.com/file/d/1XRcsyLSvqqhqNIaOI_vmqpUpmBT6gk9-/view?usp=drive_link
67+
download_model ade20k-hrnetv2-c1.onnx https://drive.google.com/file/d/1vwTKs5g-xrY_2z_V3_TFnmqF0QYd24OM/view?usp=drive_link
68+
download_model ade20k-mobilenetv2dilated-c1_deepsup.onnx https://drive.google.com/file/d/1siTG4Pce9o6iRKtKYZDEPWsru4LwNclo/view?usp=drive_link
69+
fi

0 commit comments

Comments
 (0)