From e1d9df7bf7ff91e781d07d7aa34fe223b1ef9c9d Mon Sep 17 00:00:00 2001 From: yalaudah Date: Fri, 29 May 2020 20:12:30 +0000 Subject: [PATCH] Fixes for development inside the docker container (#335) * Fix the mound command for the HRNet pretrained model in the docker readme * Properly catch InvalidGitRepository exception * make repo paths consistent with non-docker runs -- this way configs paths do not need to be changed * Properly catch InvalidGitRepository exception in train.py --- docker/Dockerfile | 7 ++++--- docker/README.md | 2 +- experiments/interpretation/dutchf3_patch/local/test.py | 3 ++- experiments/interpretation/dutchf3_patch/local/train.py | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 00f8320c..69332630 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -25,7 +25,8 @@ RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86 wget --quiet https://github.com/microsoft/seismic-deeplearning/archive/master.zip -O master.zip && \ unzip master.zip && rm master.zip -RUN cd seismic-deeplearning-master && \ +RUN mv seismic-deeplearning-master seismic-deeplearning && \ + cd seismic-deeplearning && \ conda env create -n seismic-interpretation --file environment/anaconda/local/environment.yml && \ source activate seismic-interpretation && \ python -m ipykernel install --user --name seismic-interpretation && \ @@ -34,7 +35,7 @@ RUN cd seismic-deeplearning-master && \ # TODO: add back in later when Penobscot notebook is available # Download Penobscot dataset: -# RUN cd seismic-deeplearning-master && \ +# RUN cd seismic-deeplearning && \ # data_dir="/home/username/data/penobscot" && \ # mkdir -p "$data_dir" && \ # ./scripts/download_penobscot.sh "$data_dir" && \ @@ -44,7 +45,7 @@ RUN cd seismic-deeplearning-master && \ # cd .. # Download F3 dataset: -RUN cd seismic-deeplearning-master && \ +RUN cd seismic-deeplearning && \ data_dir="/home/username/data/dutch" && \ mkdir -p "$data_dir" && \ ./scripts/download_dutch_f3.sh "$data_dir" && \ diff --git a/docker/README.md b/docker/README.md index 16f40d65..28cbba69 100644 --- a/docker/README.md +++ b/docker/README.md @@ -22,7 +22,7 @@ This process will take a few minutes to complete. # Run the Docker image: Once the Docker image is built, you can run it anytime using the following command: ```bash -sudo docker run --rm -it -p 9000:9000 -p 9001:9001 --gpus=all --shm-size 11G --mount type=bind,source=$PWD/hrnetv2_w48_imagenet_pretrained.pth,target=/home/models/hrnetv2_w48_imagenet_pretrained.pth seismic-deeplearning +sudo docker run --rm -it -p 9000:9000 -p 9001:9001 --gpus=all --shm-size 11G --mount type=bind,source=$PWD/hrnetv2_w48_imagenet_pretrained.pth,target=/home/username/seismic-deeplearning/docker/hrnetv2_w48_imagenet_pretrained.pth seismic-deeplearning ``` If you have saved the pretrained model in a different directory, make sure you replace `$PWD/hrnetv2_w48_imagenet_pretrained.pth` with the **absolute** path to the pretrained HRNet model. The command above will run a Jupyter Lab instance that you can access by clicking on the link in your terminal. You can then navigate to the notebook or script that you would like to run. diff --git a/experiments/interpretation/dutchf3_patch/local/test.py b/experiments/interpretation/dutchf3_patch/local/test.py index f993a7bf..da06a9c0 100644 --- a/experiments/interpretation/dutchf3_patch/local/test.py +++ b/experiments/interpretation/dutchf3_patch/local/test.py @@ -245,6 +245,7 @@ def _patch_label_2d( output = output_p[:, :, ps:-ps, ps:-ps] return output + def _evaluate_split( split, section_aug, model, pre_processing, output_processing, device, running_metrics_overall, config, debug=False, ): @@ -273,7 +274,7 @@ def _evaluate_split( output_dir = generate_path( f"debug/{config.OUTPUT_DIR}_test_{split}", git_branch(), git_hash(), config.MODEL.NAME, current_datetime(), ) - except TypeError: + except: output_dir = generate_path(f"debug/{config.OUTPUT_DIR}_test_{split}", config.MODEL.NAME, current_datetime(),) running_metrics_split = runningScore(n_classes) diff --git a/experiments/interpretation/dutchf3_patch/local/train.py b/experiments/interpretation/dutchf3_patch/local/train.py index c91f8333..eb4d524b 100644 --- a/experiments/interpretation/dutchf3_patch/local/train.py +++ b/experiments/interpretation/dutchf3_patch/local/train.py @@ -72,7 +72,7 @@ def run(*options, cfg=None, debug=False): output_dir = generate_path( config.OUTPUT_DIR, git_branch(), git_hash(), config_file_name, config.TRAIN.MODEL_DIR, current_datetime(), ) - except TypeError: + except: output_dir = generate_path(config.OUTPUT_DIR, config_file_name, config.TRAIN.MODEL_DIR, current_datetime(),) # Logging: