Skip to content

Commit 463c2f8

Browse files
fix tif load gui
1 parent 567c8cf commit 463c2f8

File tree

5 files changed

+35
-21
lines changed

5 files changed

+35
-21
lines changed

docs/examples/mono_channel_bact.ipynb

Lines changed: 11 additions & 11 deletions
Large diffs are not rendered by default.

src/.DS_Store

0 Bytes
Binary file not shown.

src/cellpose_omni/gui/MainWindowModules/models.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ def compute_model(self):
375375

376376
### will either have to put in edge cases for worm etc or just generalize model loading to respect what is there
377377
# try:
378-
omni_model = 'omni' in self.current_model
378+
omni_model = 'omni' in self.current_model or 'affinity' in self.current_model
379379
bacterial = 'bact' in self.current_model
380380
if omni_model or bacterial:
381381
self.NetAvg.setCurrentIndex(1) #one run net
@@ -386,11 +386,11 @@ def compute_model(self):
386386
# allow omni to be togged manually or forced by model
387387
if OMNI_INSTALLED:
388388
if omni_model:
389-
logger.info('turning on Omnipose mask recontruction version for Omnipose models (see menu)')
389+
logger.info('turning on Omnipose mask reconstruction version for Omnipose models (see menu)')
390390
if not self.omni.isChecked():
391-
print('WARNING: Omnipose models require Omnipose mask recontruction (toggle back on in menu)')
391+
print('WARNING: Omnipose models require Omnipose mask reconstruction (toggle back on in menu)')
392392
if not self.cluster.isChecked():
393-
print(('NOTE: clutering algorithm can help with over-segmentation in thin cells.'
393+
print(('NOTE: clustering algorithm can help with over-segmentation in thin cells.'
394394
'Default is ON with omnipose models (see menu)'))
395395

396396
elif self.omni.isChecked():

src/cellpose_omni/gui/io.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,15 @@ def read_image_with_channel_axis(filename):
3939
meta: The metadata dictionary.
4040
"""
4141
img = iio.imread(filename)
42-
meta = iio.immeta(filename)
42+
# meta = iio.immeta(filename)
43+
try:
44+
meta = iio.immeta(filename)
45+
except Exception as e:
46+
print(f"Warning: could not load metadata for {filename}: {e}")
47+
meta = {}
4348

49+
print('image shape', img.shape)
50+
# Check if the image is grayscale saved as RGB
4451

4552
if 'axes' in meta:
4653
axes = meta['axes']
@@ -170,6 +177,7 @@ def _load_image(parent, filename=None, load_seg=True):
170177

171178
# from here, we now will just be loading an image and a mask image file format, not npy
172179
try:
180+
173181
logger.info(f'[_load image] loading image: {filename}')
174182
image, channel_axis, meta = read_image_with_channel_axis(filename)
175183
logger.info(f'[_load image] image shape: {image.shape}, channel_axis: {channel_axis}')
@@ -178,7 +186,6 @@ def _load_image(parent, filename=None, load_seg=True):
178186
# if image.ndim ==3 and image.shape[-1] == 3:
179187
# print('Assuming RGB image, converting to CYX')
180188
# image = np.transpose(image, (2,0,1))
181-
182189
_initialize_images(parent, image, channel_axis)
183190
parent.reset()
184191
parent.recenter()

src/omnipose/core.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,13 @@ def get_niter(dists):
136136
of the distance field relaxation method
137137
138138
"""
139-
isarray = type(dists) == np.ndarray
140-
module = np if isarray else torch
139+
# isarray = type(dists) == np.ndarray
140+
# module = np if isarray else torch
141+
module = utils.get_module(dists)
141142
c = module.ceil(module.max(dists)*1.16)+1
142-
return c.astype(int) if isarray else c.int()
143+
return c.astype(int) if module==np else c.int()
144+
145+
# deprecated? only called during training flow generation it seems, not inference
143146

144147
# m = module.max(dists)
145148
# c = module.ceil(m*1.16)
@@ -1486,7 +1489,11 @@ def compute_masks(dP, dist, affinity_graph=None, bd=None, p=None, coords=None, i
14861489
affinity_graph = affinity_graph.squeeze().cpu().numpy()
14871490
# print(affinity_graph.shape,affinity_graph[(Ellipsis,)+tuple(coords)].shape)
14881491
affinity_graph = affinity_graph[(Ellipsis,)+tuple(coords)]
1489-
1492+
1493+
1494+
# despur really not needed anymore, handled by the affinity grpah torch version
1495+
1496+
14901497
# elif despur:
14911498
# if it is passed in, we need the neigh_inds to compute masks
14921499
# (though eventually we will want this to also be in parallel on GPU...)

0 commit comments

Comments
 (0)