bnsreenu / python_for_microscopists

https://www.youtube.com/channel/UC34rW-HtPJulxr5wp2Xa04w?sub_confirmation=1
MIT License
3.78k stars 2.35k forks source link

label transferring error #79

Open apal6 opened 5 months ago

apal6 commented 5 months ago

Hi @bnsreenu,

This is my first time analysing bioimages and I am trying out different models but started with STARdist. This is IF image and I want to perform nuclei segmentation on DAPI file. I was able to follow the tutorial and basically trying to run the notebook on my image with default settings and i get this error. Could you please help? Thank you!

labels, polys = model.predict_instances_big(image, axes='YXC', block_size=4096, min_overlap=128, context=128, normalizer=normalizer, n_tiles=(4,4,1))

`effective: block_size=(4096, 4096, 3), min_overlap=(128, 128, 0), context=(128, 128, 0) 0%| | 0/10 [00:00<?, ?it/s]

ValueError Traceback (most recent call last) in <cell line: 2>() 1 #Slow - takes time to segment the large image ----> 2 labels, polys = model.predict_instances_big(image, axes='YXC', block_size=4096, min_overlap=128, context=128, 3 normalizer=normalizer, n_tiles=(4,4,1))

5 frames /usr/local/lib/python3.10/dist-packages/stardist/models/base.py in predict_instances_big(self, img, axes, block_size, min_overlap, context, labels_out, labels_out_dtype, show_progress, kwargs) 941 # actual computation 942 for block in blocks: --> 943 labels, polys = self.predict_instances(block.read(img, axes=axes), kwargs) 944 labels = block.crop_context(labels, axes=axes_out) 945 labels, polys = block.filter_objects(labels, polys, axes=axes_out)

/usr/local/lib/python3.10/dist-packages/stardist/models/base.py in predict_instances(self, *args, *kwargs) 775 # return last "yield"ed value of generator 776 r = None --> 777 for r in self._predict_instances_generator(args, **kwargs): 778 pass 779 return r

/usr/local/lib/python3.10/dist-packages/stardist/models/base.py in _predict_instances_generator(self, img, axes, normalizer, sparse, prob_thresh, nms_thresh, scale, n_tiles, show_tile_progress, verbose, return_labels, predict_kwargs, nms_kwargs, overlap_label, return_predict) 727 res = None 728 if sparse: --> 729 for res in self._predict_sparse_generator(img, axes=axes, normalizer=normalizer, n_tiles=n_tiles, 730 prob_thresh=prob_thresh, show_tile_progress=show_tile_progress, **predict_kwargs): 731 if res is None:

/usr/local/lib/python3.10/dist-packages/stardist/models/base.py in _predict_sparse_generator(self, img, prob_thresh, axes, normalizer, n_tiles, show_tile_progress, b, **predict_kwargs) 538 predict_kwargs.setdefault('verbose', 0) 539 x, axes, axes_net, axes_net_div_by, _permute_axes, resizer, n_tiles, grid, grid_dict, channel, predict_direct, tiling_setup = \ --> 540 self._predict_setup(img, axes, normalizer, n_tiles, show_tile_progress, predict_kwargs) 541 542 def _prep(prob, dist):

/usr/local/lib/python3.10/dist-packages/stardist/models/base.py in _predict_setup(self, img, axes, normalizer, n_tiles, show_tile_progress, predict_kwargs) 379 380 channel = axes_dict(axes_net)['C'] --> 381 self.config.n_channel_in == x.shape[channel] or _raise(ValueError()) 382 axes_net_div_by = self._axes_div_by(axes_net) 383

/usr/local/lib/python3.10/dist-packages/csbdeep/utils/utils.py in _raise(e) 89 def _raise(e): 90 if isinstance(e, BaseException): ---> 91 raise e 92 else: 93 raise ValueError(e)

ValueError:`