@@ -10,6 +10,7 @@ MODEL="all"
1010CPU=" False"
1111SCRIPT_DIR=$( cd -- " $( dirname -- " ${BASH_SOURCE[0]} " ) " & > /dev/null && pwd )
1212MODELS_ROOT_DIR=" ${SCRIPT_DIR} /.."
13+ DOWNLOAD_WEIGHTS=" True"
1314
1415# Constrain DNNL to avoid AVX512, which leads to non-deterministic operation across different CPUs...
1516export DNNL_MAX_CPU_ISA=AVX2
@@ -37,6 +38,7 @@ RUN OPTIONS:
3738 not required for regular versions derived from cuda and torch versions above.
3839 default:"https://dl.fbaipublicfiles.com/detectron2/wheels/cu102/torch1.9/index.html"]
3940 [--models_dir directory to install vision models to, default: compressai_vision_root]
41+ [--no-weights) prevents the installation script from downloading vision model parameters]
4042
4143
4244EXAMPLE [bash install_models.sh -m detectron2 -t "1.9.1" --cuda "11.8" --compressai /path/to/compressai]
5557 --cuda) shift ; CUDA_VERSION=" $1 " ; shift ; ;;
5658 --detectron2_url) shift ; DETECTRON2=" $1 " ; shift ; ;;
5759 --models_dir) shift ; MODELS_ROOT_DIR=" $1 " ; shift ; ;;
60+ --no-weights) DOWNLOAD_WEIGHTS=" False" ; shift ; ;;
5861 * ) echo " [ERROR] Unknown parameter $1 " ; exit ; ;;
5962 esac ;
6063done ;
@@ -110,36 +113,37 @@ if [ "${MODEL,,}" == "detectron2" ] || [ ${MODEL} == "all" ]; then
110113 # back to project root
111114 cd ${SCRIPT_DIR} /..
112115
113-
114- if [ -z " $( ls -A ${MODELS_WEIGHT_DIR} /detectron2) " ]; then
115- echo
116- echo " Downloading model weights"
117- echo
118-
119- # FASTER R-CNN X-101 32x8d FPN
120- WEIGHT_DIR=" ${MODELS_WEIGHT_DIR} /detectron2/COCO-Detection/faster_rcnn_X_101_32x8d_FPN_3x/139173657"
121- mkdir -p ${WEIGHT_DIR}
122- wget -nc https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/faster_rcnn_X_101_32x8d_FPN_3x/139173657/model_final_68b088.pkl -P ${WEIGHT_DIR}
123-
124- # FASTER R-CNN R-50 FPN
125- WEIGHT_DIR=" ${MODELS_WEIGHT_DIR} /detectron2/COCO-Detection/faster_rcnn_R_50_FPN_3x/137849458"
126- mkdir -p ${WEIGHT_DIR}
127- wget -nc https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/faster_rcnn_R_50_FPN_3x/137849458/model_final_280758.pkl -P ${WEIGHT_DIR}
128-
129- # MASK R-CNN X-101 32x8d FPN
130- WEIGHT_DIR=" ${MODELS_WEIGHT_DIR} /detectron2/COCO-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_3x/139653917"
131- mkdir -p ${WEIGHT_DIR}
132- wget -nc https://dl.fbaipublicfiles.com/detectron2/COCO-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_3x/139653917/model_final_2d9806.pkl -P ${WEIGHT_DIR}
133-
134- # MASK R-CNN R-50 FPN
135- WEIGHT_DIR=" ${MODELS_WEIGHT_DIR} /detectron2/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600"
136- mkdir -p ${WEIGHT_DIR}
137- wget -nc https://dl.fbaipublicfiles.com/detectron2/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl -P ${WEIGHT_DIR}
138-
139- else
140- echo
141- echo " Detectron2 Weights directory not empty, using existing models"
142- echo
116+ if [ " ${DOWNLOAD_WEIGHTS} " == " True" ]
117+ if [ -z " $( ls -A ${MODELS_WEIGHT_DIR} /detectron2) " ]; then
118+ echo
119+ echo " Downloading model weights"
120+ echo
121+
122+ # FASTER R-CNN X-101 32x8d FPN
123+ WEIGHT_DIR=" ${MODELS_WEIGHT_DIR} /detectron2/COCO-Detection/faster_rcnn_X_101_32x8d_FPN_3x/139173657"
124+ mkdir -p ${WEIGHT_DIR}
125+ wget -nc https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/faster_rcnn_X_101_32x8d_FPN_3x/139173657/model_final_68b088.pkl -P ${WEIGHT_DIR}
126+
127+ # FASTER R-CNN R-50 FPN
128+ WEIGHT_DIR=" ${MODELS_WEIGHT_DIR} /detectron2/COCO-Detection/faster_rcnn_R_50_FPN_3x/137849458"
129+ mkdir -p ${WEIGHT_DIR}
130+ wget -nc https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/faster_rcnn_R_50_FPN_3x/137849458/model_final_280758.pkl -P ${WEIGHT_DIR}
131+
132+ # MASK R-CNN X-101 32x8d FPN
133+ WEIGHT_DIR=" ${MODELS_WEIGHT_DIR} /detectron2/COCO-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_3x/139653917"
134+ mkdir -p ${WEIGHT_DIR}
135+ wget -nc https://dl.fbaipublicfiles.com/detectron2/COCO-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_3x/139653917/model_final_2d9806.pkl -P ${WEIGHT_DIR}
136+
137+ # MASK R-CNN R-50 FPN
138+ WEIGHT_DIR=" ${MODELS_WEIGHT_DIR} /detectron2/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600"
139+ mkdir -p ${WEIGHT_DIR}
140+ wget -nc https://dl.fbaipublicfiles.com/detectron2/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl -P ${WEIGHT_DIR}
141+
142+ else
143+ echo
144+ echo " Detectron2 Weights directory not empty, using existing models"
145+ echo
146+ fi
143147 fi
144148fi
145149
@@ -200,8 +204,9 @@ if [ "${MODEL,,}" == "jde" ] || [ ${MODEL} == "all" ]; then
200204 cd ${SCRIPT_DIR} /..
201205
202206 # download weights
203- # NOTE commmented out for now as downloading via wget is blocked by provider
204- # if [ -z "$(ls -A ${MODELS_WEIGHT_DIR}/jde)"]; then
207+ if [ " ${DOWNLOAD_WEIGHTS} " == " True" ]; then
208+ # NOTE commmented out for now as downloading via wget is blocked by provider
209+ # if [ -z "$(ls -A ${MODELS_WEIGHT_DIR}/jde)"]; then
205210
206211 # echo
207212 # echo "Downloading weights..."
@@ -213,11 +218,21 @@ if [ "${MODEL,,}" == "jde" ] || [ ${MODEL} == "all" ]; then
213218 # FILEID='1nlnuYfGNuHWZztQHXwVZSL_FvfE551pA'
214219 # OUTFILE='jde.1088x608.uncertainty.pt'
215220 # wget -nc --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id='${FILEID} -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=${FILEID}" -O ${WEIGHT_DIR}/${OUTFILE} && rm -rf /tmp/cookies.txt
216- # else
221+ # else
217222 # echo
218223 # echo "JDE Weights directory not empty, using existing model"
219224 # echo
220- # fi
225+ # fi
226+ #
227+
228+ echo
229+ echo " NOTE: JDE pretrained weights can't be downloaded automatically"
230+ echo " The file can be downloaded from the following link:"
231+ echo " https://docs.google.com/uc?export=download&id=1nlnuYfGNuHWZztQHXwVZSL_FvfE551pA"
232+ echo " and placed in the corresponding directory: ${MODELS_WEIGHT_DIR} /jde/jde.1088x608.uncertainty.pt"
233+ echo
234+ fi
235+
221236fi
222237
223238if [ " ${MODEL,,} " == " yolox" ] || [ ${MODEL} == " all" ]; then
@@ -240,20 +255,21 @@ if [ "${MODEL,,}" == "yolox" ] || [ ${MODEL} == "all" ]; then
240255 cp ${SCRIPT_DIR} /yolox_requirements.txt requirements.txt
241256
242257 pip3 install -e .
243-
244- if [ -z " $( ls -A ${MODELS_WEIGHT_DIR} /yolox) " ]; then
245- echo
246- echo " Downloading model weights"
247- echo
248-
249- # YOLOX-Darkent53
250- WEIGHT_DIR=" ${MODELS_WEIGHT_DIR} /yolox/darknet53"
251- mkdir -p ${WEIGHT_DIR}
252- wget -nc https://github.com/Megvii-BaseDetection/YOLOX/releases/download/0.1.1rc0/yolox_darknet.pth -P ${WEIGHT_DIR}
253- else
254- echo
255- echo " YOLOX Weights directory not empty, using existing models"
256- echo
258+ if [ " ${DOWNLOAD_WEIGHTS} " == " True" ]; then
259+ if [ -z " $( ls -A ${MODELS_WEIGHT_DIR} /yolox) " ]; then
260+ echo
261+ echo " Downloading model weights"
262+ echo
263+
264+ # YOLOX-Darkent53
265+ WEIGHT_DIR=" ${MODELS_WEIGHT_DIR} /yolox/darknet53"
266+ mkdir -p ${WEIGHT_DIR}
267+ wget -nc https://github.com/Megvii-BaseDetection/YOLOX/releases/download/0.1.1rc0/yolox_darknet.pth -P ${WEIGHT_DIR}
268+ else
269+ echo
270+ echo " YOLOX Weights directory not empty, using existing models"
271+ echo
272+ fi
257273 fi
258274fi
259275
268284
269285pip3 install -e " ${SCRIPT_DIR} /.."
270286pip3 install ptflops
271- echo
272- echo " NOTE: JDE pretrained weights can't be downloaded automatically"
273- echo " The file can be downloaded from the following link:"
274- echo " https://docs.google.com/uc?export=download&id=1nlnuYfGNuHWZztQHXwVZSL_FvfE551pA"
275- echo " and placed in the corresponding directory: ${MODELS_WEIGHT_DIR} /jde/jde.1088x608.uncertainty.pt"
276- echo
0 commit comments