Skip to content

Commit 059ca38

Browse files
edyoshikunmattersoflightziw-liu
authored
Updating demo notebook for training (#100)
* first pass on VSCyto2D demo * updating notebooks * draft modifications updating 2DUnet to UNeXT2 * editing solution * modifying to relative paths based on setup.sh download paths. * small edits * fixing video and adding todo comment for students to switch the top_dir. * updating the readme and setup.sh * addressing some typos * html to md (#106) * typographical * nits * -adding alias for UNeXt2_2D -fixing bug fluor-phase -addingtensorboard instructions to open on browser -fixing the markdowns to render properly on vscode jupyter * ruff and black * edit tensorboard instructions * clean up the order for Part 2: fluor2phase, training call follows model construction * restructured fluor2phase sections * Text edits * markdown and html fixes * merge import blocks * add line break * tweak typesetting * use the actual pi and more line breaks * rotate 'around' * addaptive figure size * remove division * FOVs -> samples * line breaks * remove duplicate function and more line breaks * send data to device * fix multisamping in example data for graphing * fix definition location * fix device and markdown block * reordering variable that prevented fluor2phase not to run if previous cells were not run * fixing vscode and juypter readability * remove old debug script * fix syntax * fix hyperlink * fix batch size story * remove emojis * making 3D_UNeXt2 example work * pointing to config files from 0.1.0 release --------- Co-authored-by: Shalin Mehta <[email protected]> Co-authored-by: Ziwen Liu <[email protected]> Co-authored-by: Ziwen Liu <[email protected]>
1 parent 2557b4b commit 059ca38

File tree

6 files changed

+765
-368
lines changed

6 files changed

+765
-368
lines changed

examples/demo_dlmbl/README.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Exercise 4: Image translation
1+
# Exercise 6: Image translation - Part 1
22

3-
This demo script was developed for the DL@MBL 2023 course by Ziwen Liu and Shalin Mehta, with many inputs and bugfixes by [Morgan Schwartz](https://github.com/msschwartz21), [Caroline Malin-Mayor](https://github.com/cmalinmayor), and [Peter Park](https://github.com/peterhpark).
3+
This demo script was developed for the DL@MBL 2024 course by Eduardo Hirata-Miyasaki, Ziwen Liu and Shalin Mehta, with many inputs and bugfixes by [Morgan Schwartz](https://github.com/msschwartz21), [Caroline Malin-Mayor](https://github.com/cmalinmayor), and [Peter Park](https://github.com/peterhpark).
44

55

66

@@ -9,10 +9,10 @@ This demo script was developed for the DL@MBL 2023 course by Ziwen Liu and Shali
99

1010
Make sure that you are inside of the `image_translation` folder by using the `cd` command to change directories if needed.
1111

12-
Make sure that you can use mamba to switch environments.
12+
Make sure that you can use conda to switch environments.
1313

1414
```bash
15-
mamba init
15+
conda init
1616
```
1717

1818
**Close your shell, and login again.**
@@ -23,7 +23,7 @@ sh setup.sh
2323
```
2424
Activate your environment
2525
```bash
26-
mamba activate 04_image_translation
26+
conda activate 06_image_translation
2727
```
2828

2929
## Use vscode
@@ -42,7 +42,8 @@ jupyter notebook
4242

4343
...and continue with the instructions in the notebook.
4444

45-
If 04_image_translation is not available as a kernel in jupyter, run
45+
If `06_image_translation` is not available as a kernel in jupyter, run:
46+
4647
```
47-
python -m ipykernel install --user --name=04_image_translation
48+
python -m ipykernel install --user --name=06_image_translation
4849
```
+8-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import argparse
2-
from traitlets.config import Config
3-
import nbformat as nbf
4-
from nbconvert.preprocessors import TagRemovePreprocessor, ClearOutputPreprocessor
2+
53
from nbconvert.exporters import NotebookExporter
4+
from nbconvert.preprocessors import ClearOutputPreprocessor, TagRemovePreprocessor
5+
from traitlets.config import Config
66

77

88
def get_arg_parser():
99
parser = argparse.ArgumentParser()
1010

11-
parser.add_argument('input_file')
12-
parser.add_argument('output_file')
11+
parser.add_argument("input_file")
12+
parser.add_argument("output_file")
1313

1414
return parser
1515

@@ -21,15 +21,15 @@ def convert(input_file, output_file):
2121
c.ClearOutputPreprocesser.enabled = True
2222
c.NotebookExporter.preprocessors = [
2323
"nbconvert.preprocessors.TagRemovePreprocessor",
24-
"nbconvert.preprocessors.ClearOutputPreprocessor"
24+
"nbconvert.preprocessors.ClearOutputPreprocessor",
2525
]
2626

2727
exporter = NotebookExporter(config=c)
2828
exporter.register_preprocessor(TagRemovePreprocessor(config=c), True)
2929
exporter.register_preprocessor(ClearOutputPreprocessor(), True)
3030

3131
output = NotebookExporter(config=c).from_filename(input_file)
32-
with open(output_file, 'w') as f:
32+
with open(output_file, "w") as f:
3333
f.write(output[0])
3434

3535

@@ -38,4 +38,4 @@ def convert(input_file, output_file):
3838
args = parser.parse_args()
3939

4040
convert(args.input_file, args.output_file)
41-
print(f'Converted {args.input_file} to {args.output_file}')
41+
print(f"Converted {args.input_file} to {args.output_file}")

examples/demo_dlmbl/debug_log_graph.py

-97
This file was deleted.

examples/demo_dlmbl/setup.sh

+19-14
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,36 @@
22

33
START_DIR=$(pwd)
44

5-
# Create mamba environment
6-
mamba create -y --name 04_image_translation python=3.10
5+
# Create conda environment
6+
conda create -y --name 06_image_translation python=3.10
77

88
# Install ipykernel in the environment.
9-
mamba install -y ipykernel nbformat nbconvert black jupytext ipywidgets --name 04_image_translation
9+
conda install -y ipykernel nbformat nbconvert black jupytext ipywidgets --name 06_image_translation
1010
# Specifying the environment explicitly.
11-
# mamba activate sometimes doesn't work from within shell scripts.
11+
# conda activate sometimes doesn't work from within shell scripts.
1212

1313
# install viscy and its dependencies`s in the environment using pip.
1414
mkdir -p ~/code/
1515
cd ~/code/
1616
git clone https://github.com/mehta-lab/viscy.git
1717
cd viscy
18-
git checkout 7c5e4c1d68e70163cf514d22c475da8ea7dc3a88 # Exercise is tested with this commit of viscy
19-
# Find path to the environment - mamba activate doesn't work from within shell scripts.
20-
ENV_PATH=$(conda info --envs | grep 04_image_translation | awk '{print $NF}')
18+
git checkout main #FIXME: change after merging this PR # Exercise is tested with this commit of viscy
19+
20+
# Find path to the environment - conda activate doesn't work from within shell scripts.
21+
ENV_PATH=$(conda info --envs | grep 06_image_translation | awk '{print $NF}')
2122
$ENV_PATH/bin/pip install ".[metrics]"
2223

23-
# Create data directory
24-
mkdir -p ~/data/04_image_translation
25-
cd ~/data/04_image_translation
26-
wget https://dl-at-mbl-2023-data.s3.us-east-2.amazonaws.com/DLMBL2023_image_translation_data_pyramid.tar.gz
27-
wget https://dl-at-mbl-2023-data.s3.us-east-2.amazonaws.com/DLMBL2023_image_translation_test.tar.gz
28-
tar -xzf DLMBL2023_image_translation_data_pyramid.tar.gz
29-
tar -xzf DLMBL2023_image_translation_test.tar.gz
24+
# Create the directory structure
25+
mkdir -p ~/data/06_image_translation/training
26+
mkdir -p ~/data/06_image_translation/test
27+
28+
# Change to the target directory
29+
cd ~/data/06_image_translation/training
30+
31+
# Download the OME-Zarr dataset recursively
32+
wget -m -np -nH --cut-dirs=4 -R "index.html*" "https://public.czbiohub.org/comp.micro/viscy/VSCyto2D/training/a549_hoechst_cellmask_train_val.zarr/"
33+
cd ~/data/06_image_translation/test
34+
wget -m -np -nH --cut-dirs=4 -R "index.html*" "https://public.czbiohub.org/comp.micro/viscy/VSCyto2D/test/a549_hoechst_cellmask_test.zarr/"
3035

3136
# Change back to the starting directory
3237
cd $START_DIR

0 commit comments

Comments
 (0)