Spaces:
Sleeping
Sleeping
File size: 3,892 Bytes
a3290d1 |
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 140 141 142 143 144 145 146 |
#!/bin/bash
# ==============================================================================
# Auto-installation for abCTSeg for Linux and Mac machines.
# This setup script is adapted from DOSMA:
# https://github.com/ad12/DOSMA
# ==============================================================================
BIN_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
ANACONDA_KEYWORD="anaconda"
ANACONDA_DOWNLOAD_URL="https://www.anaconda.com/distribution/"
MINICONDA_KEYWORD="miniconda"
# FIXME: Update the name.
ABCT_ENV_NAME="c2c_env"
hasAnaconda=0
updateEnv=0
updatePath=1
pythonVersion="3.9"
cudaVersion=""
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-h|--help)
echo "Batch evaluation with ss_recon"
echo ""
echo "Usage:"
echo " --python <string> Python version"
echo " -f, --force Force environment update"
exit
;;
--python)
pythonVersion=$2
shift # past argument
shift # past value
;;
--cuda)
cudaVersion=$2
shift # past argument
shift # past value
;;
-f|--force)
updateEnv=1
shift # past argument
;;
*)
echo "Unknown option: $key"
exit 1
;;
esac
done
# Initial setup
source ~/.bashrc
currDir=`pwd`
if echo $PATH | grep -q $ANACONDA_KEYWORD; then
hasAnaconda=1
echo "Conda found in path"
fi
if echo $PATH | grep -q $MINICONDA_KEYWORD; then
hasAnaconda=1
echo "Miniconda found in path"
fi
if [[ $hasAnaconda -eq 0 ]]; then
echo "Anaconda/Miniconda not installed - install from $ANACONDA_DOWNLOAD_URL"
openURL $ANACONDA_DOWNLOAD_URL
exit 125
fi
# Hacky way of finding the conda base directory
condaPath=`which conda`
condaPath=`dirname ${condaPath}`
condaPath=`dirname ${condaPath}`
# Source conda
source $condaPath/etc/profile.d/conda.sh
# Check if OS is supported
if [[ "$OSTYPE" != "linux-gnu" && "$OSTYPE" != "darwin"* ]]; then
echo "Only Linux and MacOS are supported"
exit 125
fi
# Create Anaconda environment (dosma_env)
if [[ `conda env list | grep $ABCT_ENV_NAME` ]]; then
if [[ ${updateEnv} -eq 0 ]]; then
echo "Environment '${ABCT_ENV_NAME}' is installed. Run 'conda activate ${ABCT_ENV_NAME}' to get started."
exit 0
else
conda env remove -n $ABCT_ENV_NAME
conda create -y -n $ABCT_ENV_NAME python=3.9
fi
else
conda create -y -n $ABCT_ENV_NAME python=3.9
fi
conda activate $ABCT_ENV_NAME
# Install tensorflow and keras
# https://www.tensorflow.org/install/source#gpu
# pip install tensorflow
# Install pytorch
# FIXME: PyTorch has to be installed with pip to respect setup.py files from nn UNet
# pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cpu
# if [[ "$OSTYPE" == "darwin"* ]]; then
# # Mac
# if [[ $cudaVersion != "" ]]; then
# # CPU
# echo "Cannot install PyTorch with CUDA support on Mac"
# exit 1
# fi
# conda install -y pytorch torchvision torchaudio -c pytorch
# else
# # Linux
# if [[ $cudaVersion == "" ]]; then
# cudatoolkit="cpuonly"
# else
# cudatoolkit="cudatoolkit=${cudaVersion}"
# fi
# conda install -y pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 $cudatoolkit -c pytorch
# fi
# Install detectron2
# FIXME: Remove dependency on detectron2
#pip3 install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cpu/torch1.10/index.html
# Install totalSegmentor
# FIXME: Add this to the setup.py file
# pip3 install git+https://github.com/StanfordMIMI/TotalSegmentator.git
# cd $currDir/..
# echo $currDir
# exit 1
pip install -e . --no-cache-dir
echo ""
echo ""
echo "Run 'conda activate ${ABCT_ENV_NAME}' to get started." |