-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_exp5.sh
executable file
·104 lines (88 loc) · 4.25 KB
/
run_exp5.sh
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
#!/bin/bash
if command -v curl &> /dev/null; then
echo "curl is installed"
curl -LsSf https://astral.sh/uv/0.5.9/install.sh | sh
elif command -v wget &> /dev/null; then
echo "wget is installed"
wget -qO- https://astral.sh/uv/0.5.9/install.sh | sh
else
echo "Please install curl or wget"
exit 1
fi
PYTHON_INTERPRETER=python
# Function to log messages with timestamp
log_message() {
echo "[$(date +"%Y-%m-%d_%H-%M-%S")] $1"
}
VENV_DIR="venv-gallia"
REQUIREMENTS_FILE="requirements.txt"
if [ -d "$VENV_DIR" ]; then
log_message "Virtual environment '$VENV_DIR' found."
# Activate the virtual environment
source "$VENV_DIR/bin/activate"
log_message "Virtual environment '$VENV_DIR' activated."
else
log_message "Virtual environment '$VENV_DIR' does not exist. Creating..."
make create_environment
log_message "Activating environment"
source venv-gallia/bin/activate ## TODO rename env name?
log_message "Installing all requirements"
make requirements
fi
# Check if PyTorch has CUDA available
cuda_available=$($PYTHON_INTERPRETER -c "import torch; print(torch.cuda.is_available())")
log_message "CUDA available: $cuda_available"
# If CUDA is available, export the CUBLAS_WORKSPACE_CONFIG variable
if [ "$cuda_available" == "True" ]; then
export CUBLAS_WORKSPACE_CONFIG=:16:8
log_message "CUDA is available. CUBLAS_WORKSPACE_CONFIG is set to :16:8."
else
log_message "CUDA is not available. No changes made."
fi
####################################
#### Prepare Runs ##################
log_message "Getting preprocessed data"
bash ./get_preprocessed_data.sh
log_message "Creating configs"
$PYTHON_INTERPRETER create_cfg.py
#### Exp5 TCGA and MNIST ####
log_message "Starting Experiment 5: TCGA and MNIST"
mkdir -p ./reports/paper-visualizations/Exp5
cp ./config_runs/Exp5/*.yaml .
make visualize RUN_ID=Exp5_TCGA_MNIST
log_message "Experiment 5 main run done"
log_message "Starting Img_to_Img run for comparison"
make visualize RUN_ID=Exp5_TCGA_MNISTImgImg
log_message "Experiment 5 Img_to_Img run done"
log_message "Starting TCGA extra visualization"
log_message "Creating comparison plots"
$PYTHON_INTERPRETER eval-xmodalix-scripts/plot_compare_tcga.py Exp5_TCGA_MNIST # Corrected to use $PYTHON_INTERPRETER
log_message "Creating comparison plots done"
log_message "Eval against Img_to_Img"
$PYTHON_INTERPRETER eval-xmodalix-scripts/eval_against_ImgImg.py Exp5_TCGA_MNIST # Corrected to use $PYTHON_INTERPRETER
log_message "Eval against Img_to_Img done"
log_message "Eval xmodalix with classification"
$PYTHON_INTERPRETER eval-xmodalix-scripts/eval_xmodalix.py Exp5_TCGA_MNIST # Corrected to use $PYTHON_INTERPRETER
log_message "Eval xmodalix with classification done"
#### SKIPPING THIS PART FOR TCGA BECAUSE WE HAVE NO TIMESEREIS DATA
log_message "Creating GIFs"
$PYTHON_INTERPRETER eval-xmodalix-scripts/generate_gif.py Exp5_TCGA_MNIST # Corrected to use $PYTHON_INTERPRETER
log_message "Creating GIFs done"
# clean up
bash ./clean.sh Exp5_TCGA_MNIST,Exp5_TCGA_MNISTImggImg true true # Clean up and keep only reports folder
rm ./Exp5_Exp5_TCGA_MNIST_config.yaml
rm ./Exp5_Exp5_TCGA_MNISTImgImg_config.yaml
log_message "Exp5 removed intermediate data"
# Get paper visualization
log_message "Copying visualizations to reports/paper-visualizations/Exp5"
mkdir -p ./reports/paper-visualizations/Exp5/temp
mv ./reports/paper-visualizations/Exp5/* ./reports/paper-visualizations/Exp5/temp
# move the below files from temp to the main folder
mv ./reports/paper-visualizations/Exp5/temp/xmodal_vs_normal_test_boxplot.png ./reports/paper-visualizations/Exp5/Figure_S5_C_MSE_Boxplot_Exp_5.png
mv ./reports/paper-visualizations/Exp5/temp/xmodal_vs_normal_test_bar.png ./reports/paper-visualizations/Exp5/Figure_S5_D_MSE_Barplot_Exp_5.png
mv ./reports/paper-visualizations/Exp5/temp/xmodalix_eval_classifier_metrics.csv ./reports/paper-visualizations/Exp5/Table_S5_F1_Classifier.csv
mv ./reports/Exp5_TCGA_MNIST/figures/loss_plot_relative.png ./reports/paper-visualizations/Exp5/Figure_4_C_rel_loss_Exp_5.png
mv ./reports/Exp5_TCGA_MNIST/figures/translategrid_extra_class_labels.png ./reports/paper-visualizations/Exp5/Figure_4_D_Digit_Grid.png
rm -r ./reports/paper-visualizations/Exp5/temp
log_message "Exp5 ALL DONE"
# rm -r ./reports/paper-visualizations/Exp5/temp