Skip to content

Commit

Permalink
Merge pull request #2 from dlmbl/exercise2023
Browse files Browse the repository at this point in the history
Exercise2023
  • Loading branch information
mattersoflight authored Aug 21, 2023
2 parents bb97db1 + fc92870 commit ee33c7a
Show file tree
Hide file tree
Showing 16 changed files with 2,040 additions and 2,970 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
data*
microDL*
*.ipynb*
*microdl_patches*
microdl_model
Binary file removed 20220828_DLMBL_ImageTranslation.pdf
Binary file not shown.
Binary file removed 20220830_DLMBL_FailureModes.pdf
Binary file not shown.
61 changes: 11 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,64 +1,25 @@
# Exercise 4: Image translation
## Setup

## Get the terminal ready.
If the `(base)` prefix is not present in front of the shell prompt, you need to initialize conda and restart the terminal:
```
conda init bash
```
Make sure that you are inside of the `image_translation` folder by using the `cd` command to change directories if needed.

## Go to the folder with all the DLMBL exercises and update this exercise.
Make sure that you can use mamba to switch environments. The `setup.sh` script uses `mamba activate`.

```
cd DL-MBL-2022
git submodule update --init 04_image_translation
cd 04_image_translation
```bash
mamba init
```

**Close your shell, and login again.**

## Download data.
Open the terminal and run the shell script that downloads the data. You are welcome to examine the script to understand the steps.
```
bash download_data.sh
Run the setup script to create the environment for this exercise and download the dataset.
```bash
sh setup.sh
```

## Setup microDL.
Open the terminal and run the shell script that fetches the correct release of microDL repository and adds it to python search path. You are welcome to examine the script to understand the steps. `source` command is needed to add the environment variables set in the script to the current shell.
```
source setup_microdl.sh
```
Launch a jupyter environment

## Setup and activate the new conda environment.
```
conda env create --file=microDL/conda_env_microdl_care.yml
conda activate microdl2022
```

## Start jupyter lab
### If working on a virtual desktop (e.g., NoMachine)
Launch jupyter lab from the terminal within your session:
```
jupyter lab
```

### If working on a terminal

Launch a jupyter lab server that you can connect from your browser:

```
jupyter lab --ip=0.0.0.0 --port=8888 --no-browser
```

Then you can access your notebooks in your browser at:

```
http://<your server name>.compute.amazonaws.com:8888?<token generated by jupyter lab>
```

<your server name> is the host address you use to connect via ssh or nomachine, and *not the hostname displayed by jupyter lab in the terminal*. You do need to copy the token shown by the jupyter lab server in the terminal.

## Open the notebook

Open `DL-MBL-2022/04_image_translation/exercise.ipynb`, and continue with the instructions in the notebook.



...and continue with the instructions in the notebook.
41 changes: 41 additions & 0 deletions convert-solution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import argparse
from traitlets.config import Config
import nbformat as nbf
from nbconvert.preprocessors import TagRemovePreprocessor, ClearOutputPreprocessor
from nbconvert.exporters import NotebookExporter


def get_arg_parser():
parser = argparse.ArgumentParser()

parser.add_argument('input_file')
parser.add_argument('output_file')

return parser


def convert(input_file, output_file):
c = Config()
c.TagRemovePreprocessor.remove_cell_tags = ("solution",)
c.TagRemovePreprocessor.enabled = True
c.ClearOutputPreprocesser.enabled = True
c.NotebookExporter.preprocessors = [
"nbconvert.preprocessors.TagRemovePreprocessor",
"nbconvert.preprocessors.ClearOutputPreprocessor"
]

exporter = NotebookExporter(config=c)
exporter.register_preprocessor(TagRemovePreprocessor(config=c), True)
exporter.register_preprocessor(ClearOutputPreprocessor(), True)

output = NotebookExporter(config=c).from_filename(input_file)
with open(output_file, 'w') as f:
f.write(output[0])


if __name__ == "__main__":
parser = get_arg_parser()
args = parser.parse_args()

convert(args.input_file, args.output_file)
print(f'Converted {args.input_file} to {args.output_file}')
12 changes: 0 additions & 12 deletions download_data.sh

This file was deleted.

Loading

0 comments on commit ee33c7a

Please sign in to comment.