-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathrun
executable file
·140 lines (117 loc) · 3.1 KB
/
run
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/bin/bash
set -e
docker=podman
export OMP_NUM_THREADS=1
image=ocropus4
remimage=tmbdev/ocropus4
die() {
echo "ERROR: $*"
exit 1
}
cmd_clean() { # remove temporary files
rm -f *-info.txt
rm -f *.pth *.pth.tar
rm -f *.log
}
cmd_cleanlogs() { # clean up log files
source venv/bin/activate
mkdir -p ./JUNK
mv -v $(python3 -m ocropus.slog findempty *.sqlite3) ./JUNK/.
}
cmd_build() {
git commit -a || true
(cd docker && $docker build - -t ocropus4-base "$@" < Dockerfile-base)
git archive --format=tar -o docker/ocropus4.tar HEAD
(cd docker && $docker build --no-cache . -t ocropus4)
}
cmd_docropus() {
$docker run --rm -it --ipc=host --network=host -v "$PWD":/ocropus4 -w /ocropus4 -v "$PWD/_cache:/ocropus4/_cache" ocropus4 ocropus4 "$@"
}
cmd_download_uw3() {
mkdir -p uw3
gsutil -m rsync -r gs://lpr-uw3/* uw3/.
}
cmd_download() {
mkdir -p trained
gsutil -m rsync -r gs://ocropus4-trained/ ./models/
}
cmd_upload() {
gsutil -m rsync -r ./models/ gs://ocropus4-trained/
}
cmd_info() {
test -d venv || python3 -m venv venv
source venv/bin/activate
python3 -m ocropus.slog info *.sqlite3
}
cmd_getbest() {
test -d venv || python3 -m venv venv
source venv/bin/activate
python3 -m ocropus.slog getbest "$@"
}
cmd_val2model() {
test -d venv || python3 -m venv venv
source venv/bin/activate
python3 -m ocropus.slog val2model $1
}
cmd_venv() { # set up a virtualenv
test -d venv || python3 -m venv venv
source venv/bin/activate
pip3 install -U pip
pip3 install numpy
pip3 install --pre torch torchvision -f https://download.pytorch.org/whl/nightly/cu102/torch_nightly.html
pip3 install -U -r requirements.txt
pip3 install -U -r requirements.dev.txt
# python3 -m bash_kernel.install
pip3 install -U neovim
pip3 install -U jupyterlab
pip3 install -U pytest
pip3 install -U tabulate
python3 -m bash_kernel.install
if false; then
pip3 install sos-python
pip3 install sos-notebook
pip3 install jupyterlab-sos
python -m sos_notebook.install
pip3 install papermill
pip3 install sos-papermill
fi
if false; then
pip3 install -e git://github.com/vatlab/transient-display-data#egg=transient-display-data
jupyter labextension install transient-display-data
jupyter labextension install jupyterlab-sos
fi
jupyter kernelspec list
}
cmd_lab() { # run jupyter lab in the environment
set -e
cmd_venv > venv.log
source venv/bin/activate
jupyter lab "$@"
}
cmd_help() { # help message
echo
echo available commands:
echo
grep '^cmd_[_0-9a-z]*() {' $0 | sed 's/cmd_//;s/\(.*\)() *{* *#* */\1 -- /'
}
cmd=${1:-help}
shift
case $cmd in
help)
echo; echo available commands:; echo
grep '^cmd_[_0-9a-z]*() {' "$0" | sed 's/cmd_//;s/\(.*\)() *{* *#* */\1 -- /'
;;
*.py)
# cmd_versions
set -e
# hg status grep -v '^M ' > /dev/null
cmd_venv > venv.log
source venv/bin/activate
export OMP_NUM_THREADS=1
python3 "$cmd" "$@"
;;
*)
set -e
"cmd_$cmd" "$@"
;;
esac