Mercurial > repos > bgruening > cellpose
comparison cp_segmentation.py @ 2:e5370bb71633 draft default tip
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/cellpose commit 5846f23282167df28e6cc00e1bda31523b66b5b4
author | bgruening |
---|---|
date | Sat, 15 Mar 2025 17:23:55 +0000 |
parents | 1857781df226 |
children |
comparison
equal
deleted
inserted
replaced
1:1857781df226 | 2:e5370bb71633 |
---|---|
1 import argparse | 1 import argparse |
2 import json | 2 import json |
3 import os | 3 import os |
4 import warnings | 4 import warnings |
5 | 5 |
6 # Make sure, that `MKL_NUM_THREADS` is set to 1, to ensure reproducibility: | |
7 # https://forum.image.sc/t/reproducibility-how-we-spent-years-building-containers-and-then-mkl-decided-to-screw-our-results/109599 | |
8 if str(os.environ['MKL_NUM_THREADS']) != '1': | |
9 warnings.warn('MKL_NUM_THREADS must be set to 1 to ensure reproducibility, and will be adjusted accordingly for now.') | |
10 os.environ['MKL_NUM_THREADS'] = '1' | |
11 | |
12 # Load the remaining packages *after* adjusting `MKL_NUM_THREADS` (this likely necessary for it to take effect) | |
6 import matplotlib.pyplot as plt | 13 import matplotlib.pyplot as plt |
7 import numpy as np | 14 import numpy as np |
8 import skimage.io | 15 import skimage.io |
16 import torch | |
9 from cellpose import models, plot, transforms | 17 from cellpose import models, plot, transforms |
18 | |
19 # Apply PyTorch guidelines for reproducibility | |
20 torch.backends.cudnn.benchmark = True | |
21 torch.backends.cudnn.deterministic = True | |
22 torch.manual_seed(0) | |
10 | 23 |
11 | 24 |
12 def main(inputs, img_path, img_format, output_dir): | 25 def main(inputs, img_path, img_format, output_dir): |
13 """ | 26 """ |
14 Parameter | 27 Parameter |