#!/bin/bash # Some utilities function _create_if_not_exists () { path=$1 if [ ! -d $path ]; echo "${path} does not exist, creating it." then mkdir -p $path fi } # Installing processes function install_mask_rcnn () { INSTALLING_PATH="${TMP_DIRECTORY}/maskrcnn" _create_if_not_exists $INSTALLING_PATH cd $INSTALLING_PATH || exit wget -P $INSTALLING_PATH https://github.com/zimmerrol/mask-rcnn-edge-agreement-loss/archive/master.zip unzip $INSTALLING_PATH/master.zip -d $INSTALLING_PATH # Solution to reduce working load sed -i -E "s/ workers=workers/ workers=1/g" $INSTALLING_PATH/mask-rcnn-edge-agreement-loss-master/mrcnn/model.py cd $INSTALLING_PATH/mask-rcnn-edge-agreement-loss-master &&\ echo """from distutils.core import setup setup(name='mrcnn', version='99.9', description='Faster Training of Mask {R-CNN} by Focusing on Instance Boundaries', author='Roland S. Zimmermann and Julien N. Siems', url='rzimmermann.com', packages=['mrcnn'], )""" >> setup.py &&\ pip3 install . } function install_gsconfig (){ pip3 install --upgrade gsconfig-py3 [[ $(pip3 show gsconfig-py3) =~ Location:' '(.*)$'\n' ]] && geoserver_py_install=${BASH_REMATCH[1]} sed -i '715i \ params={}' $geoserver_py_install/geoserver/catalog.py # Solution to H3_creation #sed -e '715i \ if params not in locals():' $geoserver_py_install/geoserver/catalog.py #sed -e '716i \ params={}' $geoserver_py_install/geoserver/catalog.py } function install_orfeo (){ INSTALLING_PATH="${TMP_DIRECTORY}/orfeo_toolbox" _create_if_not_exists $INSTALLING_PATH cd "$INSTALLING_PATH" || exit wget https://www.orfeo-toolbox.org/packages/archives/OTB/OTB-7.0.0-rc2-Linux64.run ORFEO_TOOLBOX_PATH="$INSTALLING_PATH/OTB-7.0.0-rc2-Linux64.run" chmod +x "$ORFEO_TOOLBOX_PATH" "$ORFEO_TOOLBOX_PATH" --target /usr/local/OTB ln -s /usr/lib/x86_64-linux-gnu/libpython3.5m.so /usr/lib/x86_64-linux-gnu/libpython3.5m.so.rh-python35-1.0 || echo "Linked" echo "export OTB_APPLICATION_PATH=/usr/local/OTB/lib/otb/applications" >> /root/.bashrc echo "export PATH=$PATH:/usr/local/OTB/bin:" >> /root/.bashrc echo "export LC_NUMERIC=C" >> /root/.bashrc echo "export PYTHONPATH=/usr/local/OTB/lib/python:$PYTHONPATH" >> /root/.bashrc echo "export GEOTIFF_CSV=/usr/local/OTB/share/epsg_csv" >> /root/.bashrc echo "export GDAL_DRIVER_PATH=disable" >> /root/.bashrc } function install_ffmpeg (){ apt install ffmpeg -y } function install_unrar (){ INSTALLING_PATH="${TMP_DIRECTORY}/unrar" _create_if_not_exists $INSTALLING_PATH cd "$INSTALLING_PATH" || exit wget https://www.rarlab.com/rar/unrarsrc-6.0.3.tar.gz tar -xf unrarsrc-6.0.3.tar.gz cd unrar make lib make install-lib echo "export UNRAR_LIB_PATH=/usr/lib/libunrar.so" >> /root/.bashrc } function install_aie (){ INSTALLING_PATH="${TMP_DIRECTORY}/aie" _create_if_not_exists $INSTALLING_PATH apt-get update && apt-get install git -y # Hay que meterlo en el entorno git clone "https://deployment_ops:4rGdZ42sg4JaTt5uxMbp@bitbucket.org/srm-consulting/aie.git" $INSTALLING_PATH cd $INSTALLING_PATH || exit git checkout develop pip3 install --upgrade . } function install_aie_unet_model (){ INSTALLING_PATH="${TMP_DIRECTORY}/aie_unet_model" _create_if_not_exists $INSTALLING_PATH git clone "https://deployment_ops:4rGdZ42sg4JaTt5uxMbp@bitbucket.org/srm-consulting/aie-model-unet.git" $INSTALLING_PATH cd $INSTALLING_PATH || exit git checkout feature/resunet apt-get install libhdf5-dev -y pip3 install --upgrade aie_model_unet/nets/darkNet53 pip3 install --upgrade aie_model_unet/nets/simpleCcnn pip3 install --upgrade aie_model_unet/nets/unet pip3 install --upgrade . } function install_keras_unet_collections (){ INSTALLING_PATH="${TMP_DIRECTORY}/keras-unet-collection" _create_if_not_exists $INSTALLING_PATH git clone -b 'v0.0.18' https://github.com/yingkaisha/keras-unet-collection.git $INSTALLING_PATH cd $INSTALLING_PATH || exit echo "import setuptools with open(\"README.md\", \"r\", encoding=\"utf-8\") as fh: long_description = fh.read() setuptools.setup( name = \"keras-unet-collection\", version = \"0.0.18\", author = \"Yingkai (Kyle) Sha\", author_email = \"yingkaisha@gmail.com\", description = \"The Tensorflow, Keras implementation of U-net, V-net, U-net++, R2U-net, Attention U-net, ResUnet-a, U^2-Net, and UNET 3+ with optional ImageNet-trained backbones.\", long_description = long_description, long_description_content_type = \"text/markdown\", url = \"https://github.com/yingkaisha/keras-unet-collection\", packages = setuptools.find_packages(), classifiers=[ \"Programming Language :: Python :: 3\", \"License :: OSI Approved :: MIT License\", \"Operating System :: OS Independent\",], python_requires='>=3.5',)" &> "$INSTALLING_PATH/setup.py" pip3 install --upgrade . } # Creating tmp diretory for installation files TMP_DIRECTORY=$(mktemp -d -p "$(pwd)" -t XXXXXXXXX) # Installing files install_mask_rcnn install_gsconfig install_orfeo install_ffmpeg install_unrar install_aie install_aie_unet_model install_keras_unet_collections # Encodings echo "export PYTHONIOENCODING=utf8" >> /root/.bashrc echo "export LC_ALL=en_US.UTF-8" >> /root/.bashrc echo "export LANG=en_US.UTF-8" >> /root/.bashrc echo "export LANGUAGE=en_US.UTF-8" >> /root/.bashrc echo "export PYTHONUNBUFFERED=True" >> /root/.bashrc # Removing tmp rm -r "$TMP_DIRECTORY"