-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from dlmbl/exercise2023
Exercise2023
- Loading branch information
Showing
16 changed files
with
2,040 additions
and
2,970 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
data* | ||
microDL* | ||
*.ipynb* | ||
*microdl_patches* | ||
microdl_model |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}') |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.