Skip to content

Commit da09b99

Browse files
Update segmentation related documentation and ignore model loading warnings
1 parent 80de1f7 commit da09b99

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

flamingo_tools/segmentation/unet_prediction.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import multiprocessing as mp
22
import os
3+
import warnings
34
from concurrent import futures
45

56
import imageio.v3 as imageio
@@ -37,10 +38,12 @@ def ndim(self):
3738

3839

3940
def prediction_impl(input_path, input_key, output_folder, model_path, scale, block_shape, halo):
40-
if os.path.isdir(model_path):
41-
model = load_model(model_path)
42-
else:
43-
model = torch.load(model_path)
41+
with warnings.catch_warnings():
42+
warnings.simplefilter("ignore")
43+
if os.path.isdir(model_path):
44+
model = load_model(model_path)
45+
else:
46+
model = torch.load(model_path)
4447

4548
mask_path = os.path.join(output_folder, "mask.zarr")
4649
image_mask = z5py.File(mask_path, "r")["mask"]

scripts/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ You can run it like this for an input volume that is stored in n5, e.g. the fuse
3636
python run_prediction_distance_unet.py -i /path/to/volume.n5 -k setup0/timepoint0/s0 -m /path/to/model -o /path/to/output_folder
3737
```
3838
Here, `-i` specifies the input filepath, `-o` the folder where the results are saved and `-k` the internal path in the n5 file.
39-
The `-m` argument specifies the model to use for prediction. You need to give the path to the folder that contains the checkpoint (the `best.pt` file).
39+
The `-m` argument specifies the filepath to the model for prediction. You need to give the path to the folder that contains the checkpoint (the `best.pt` file).
4040

4141
You can also run the script for a tif file. In this case you don't need the `-k` parameter:
4242
```

0 commit comments

Comments
 (0)