Closed zt6597 closed 1 year ago
@zt6597 Hi. The regist.tif should be replaced with mask.tif file.
@zt6597 Hi. The regist.tif should be replaced with mask.tif file.
@TheSallyGardens Thanks for your reply, but i get confused. Is mask.tif generated from Cell Segmentation function? Should i use regist.tif as th input for Cell Segmentation?
@TheSallyGardens I use regist.tif as th input for Cell Segmentation workflow, and i got the following error:
Python 3.8.16 | packaged by conda-forge | (default, Feb 1 2023, 16:01:55) IPython 8.10.0 -- An enhanced Interactive Python. Type '?' for help.
RuntimeError Traceback (most recent call last) Cell In[1], line 7 4 img_path = './data/C01626E6F6_regist.tif' 5 out_path = './segmentation/' ----> 7 im.cell_seg(model_path, img_path, out_path)
File ~/miniconda3/envs/st/lib/python3.8/site-packages/stereopy-0.9.0-py3.8.egg/stereo/image/segmentation/segment.py:23, in cell_seg(model_path, img_path, out_path, depp_cro_size, overlap, gpu) 21 flag = 0 22 cell_seg_pipeline = pipeline.CellSegPipe(model_path, img_path, out_path, flag, depp_cro_size, overlap) ---> 23 cell_seg_pipeline.run()
File ~/miniconda3/envs/st/lib/python3.8/site-packages/stereopy-0.9.0-py3.8.egg/stereo/image/segmentation/seg_utils/cell_seg_pipeline.py:290, in CellSegPipe.run(self) 282 t1 = time.time() 284 # q = Queue() 285 # t = Process(target=self.tissue_cell_infer, args=(q,)) 286 # t.start() 287 288 # tissue_cell_label = q.get() 289 # t.join() --> 290 tissue_cell_label = self.tissue_cell_infer() 291 t2 = time.time() 292 logger.info('Cell inference : %.2f' % (t2 - t1))
File ~/miniconda3/envs/st/lib/python3.8/site-packages/stereopy-0.9.0-py3.8.egg/stereo/image/segmentation/seg_utils/cell_seg_pipeline.py:154, in CellSegPipe.tissue_cell_infer(self, q) 152 tissue_bbox = self.tissue_bbox[idx] 153 tissue_img = [img[p[0]: p[2], p[1]: p[3]] for p in tissue_bbox] --> 154 label_list = cell_infer.cellInfer(self.model_path, tissue_img, self.deep_crop_size, self.overlap) 155 tissue_cell_label.append(label_list) 156 if q is not None:
File ~/miniconda3/envs/st/lib/python3.8/site-packages/stereopy-0.9.0-py3.8.egg/stereo/image/segmentation/seg_utils/cell_infer.py:388, in cellInfer(model_path, file, size, overlap) 386 dataset = data_batch(img_list) 387 test_dataloader = torch.utils.data.DataLoader(dataset, batch_size=32) --> 388 for batch in tqdm(test_dataloader, ncols=80): 389 img = batch 390 img = img.to(device, dtype=torch.float)
File ~/miniconda3/envs/st/lib/python3.8/site-packages/tqdm-4.60.0-py3.8.egg/tqdm/std.py:1178, in tqdm.iter(self) 1175 time = self._time 1177 try: -> 1178 for obj in iterable: 1179 yield obj 1180 # Update and possibly print the progressbar. 1181 # Note: does not call self.update(1) for speed optimisation.
File ~/miniconda3/envs/st/lib/python3.8/site-packages/torch/utils/data/dataloader.py:521, in _BaseDataLoaderIter.next(self) 519 if self._sampler_iter is None: 520 self._reset() --> 521 data = self._next_data() 522 self._num_yielded += 1 523 if self._dataset_kind == _DatasetKind.Iterable and \ 524 self._IterableDataset_len_called is not None and \ 525 self._num_yielded > self._IterableDataset_len_called:
File ~/miniconda3/envs/st/lib/python3.8/site-packages/torch/utils/data/dataloader.py:561, in _SingleProcessDataLoaderIter._next_data(self) 559 def _next_data(self): 560 index = self._next_index() # may raise StopIteration --> 561 data = self._dataset_fetcher.fetch(index) # may raise StopIteration 562 if self._pin_memory: 563 data = _utils.pin_memory.pin_memory(data)
File ~/miniconda3/envs/st/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py:52, in _MapDatasetFetcher.fetch(self, possibly_batched_index) 50 else: 51 data = self.dataset[possibly_batched_index] ---> 52 return self.collate_fn(data)
File ~/miniconda3/envs/st/lib/python3.8/site-packages/torch/utils/data/_utils/collate.py:56, in default_collate(batch) 54 storage = elem.storage()._new_shared(numel) 55 out = elem.new(storage) ---> 56 return torch.stack(batch, 0, out=out) 57 elif elem_type.module == 'numpy' and elemtype.name != 'str' \ 58 and elemtype.name != 'string': 59 if elem_type.name == 'ndarray' or elem_type.name == 'memmap': 60 # array of string classes and object
RuntimeError: stack expects each tensor to be equal size, but got [6, 256, 256] at entry 0 and [6, 256, 255] at entry 9
@zt6597 Hi,could you try the code? `from stereo.tools.cell_correct import cell_correct
out_dir = "cell_correct_result" bgef_path = "C01626E6F6.raw.gef" image_path = "C01626E6F6_regist.tif" model_path = "cell_segmentation/seg_model_20211210.pth" model_type = "deep-learning"
gpu = -1 only_save_result = False fast = True data = cell_correct(out_dir=out_dir, bgef_path=bgef_path, image_path=image_path, model_path=model_path, model_type=model_type, gpu=gpu, process_count=10, only_save_result=only_save_result, fast=fast) `
@TheSallyGardens Hi. I followed the code , and i got the same error: actually, my chip is 2cm*1cm, i think the picture size of regist.tif can't fit the tensor code
RuntimeError Traceback (most recent call last) Cell In[3], line 13 11 only_save_result = False 12 fast = True ---> 13 data = cell_correct(out_dir=out_dir, 14 bgef_path=bgef_path, 15 image_path=image_path, 16 model_path=model_path, 17 model_type=model_type, 18 gpu=gpu, 19 process_count=10, 20 only_save_result=only_save_result, 21 fast=fast)
File ~/miniconda3/envs/st/lib/python3.8/site-packages/stereopy-0.9.0-py3.8.egg/stereo/utils/time_consume.py:57, in log_consumed_time.
File ~/miniconda3/envs/st/lib/python3.8/site-packages/stereopy-0.9.0-py3.8.egg/stereo/tools/cell_correct.py:201, in cell_correct(out_dir, threshold, gem_path, bgef_path, raw_cgef_path, mask_path, image_path, model_path, mask_save, model_type, deep_cro_size, overlap, gpu, process_count, only_save_result, fast) 199 cell_segment = CellSegment(image_path, gpu, out_dir) 200 logger.info(f"there is no mask file, generate it by model {model_path}") --> 201 cell_segment.generate_mask(model_path, model_type, deep_cro_size, overlap) 202 mask_path = cell_segment.get_mask_files()[0] 203 logger.info(f"the generated mask file {mask_path}")
File ~/miniconda3/envs/st/lib/python3.8/site-packages/stereopy-0.9.0-py3.8.egg/stereo/tools/cell_segment.py:20, in CellSegment.generate_mask(self, model_path, model_type, depp_cro_size, overlap) 18 self.mask_out_path = os.path.join(self.mask_out_path, model_type) 19 if model_type == 'deep-learning': ---> 20 cell_seg(model_path, self.image_path, self.mask_out_path, depp_cro_size, overlap, self.gpu) 21 else: 22 cell_seg_deepcell(model_path, self.image_path, self.mask_out_path, depp_cro_size, overlap, self.gpu)
File ~/miniconda3/envs/st/lib/python3.8/site-packages/stereopy-0.9.0-py3.8.egg/stereo/image/segmentation/segment.py:23, in cell_seg(model_path, img_path, out_path, depp_cro_size, overlap, gpu) 21 flag = 0 22 cell_seg_pipeline = pipeline.CellSegPipe(model_path, img_path, out_path, flag, depp_cro_size, overlap) ---> 23 cell_seg_pipeline.run()
File ~/miniconda3/envs/st/lib/python3.8/site-packages/stereopy-0.9.0-py3.8.egg/stereo/image/segmentation/seg_utils/cell_seg_pipeline.py:290, in CellSegPipe.run(self) 282 t1 = time.time() 284 # q = Queue() 285 # t = Process(target=self.tissue_cell_infer, args=(q,)) 286 # t.start() 287 288 # tissue_cell_label = q.get() 289 # t.join() --> 290 tissue_cell_label = self.tissue_cell_infer() 291 t2 = time.time() 292 logger.info('Cell inference : %.2f' % (t2 - t1))
File ~/miniconda3/envs/st/lib/python3.8/site-packages/stereopy-0.9.0-py3.8.egg/stereo/image/segmentation/seg_utils/cell_seg_pipeline.py:154, in CellSegPipe.tissue_cell_infer(self, q) 152 tissue_bbox = self.tissue_bbox[idx] 153 tissue_img = [img[p[0]: p[2], p[1]: p[3]] for p in tissue_bbox] --> 154 label_list = cell_infer.cellInfer(self.model_path, tissue_img, self.deep_crop_size, self.overlap) 155 tissue_cell_label.append(label_list) 156 if q is not None:
File ~/miniconda3/envs/st/lib/python3.8/site-packages/stereopy-0.9.0-py3.8.egg/stereo/image/segmentation/seg_utils/cell_infer.py:388, in cellInfer(model_path, file, size, overlap) 386 dataset = data_batch(img_list) 387 test_dataloader = torch.utils.data.DataLoader(dataset, batch_size=32) --> 388 for batch in tqdm(test_dataloader, ncols=80): 389 img = batch 390 img = img.to(device, dtype=torch.float)
File ~/miniconda3/envs/st/lib/python3.8/site-packages/tqdm-4.60.0-py3.8.egg/tqdm/std.py:1178, in tqdm.iter(self) 1175 time = self._time 1177 try: -> 1178 for obj in iterable: 1179 yield obj 1180 # Update and possibly print the progressbar. 1181 # Note: does not call self.update(1) for speed optimisation.
File ~/miniconda3/envs/st/lib/python3.8/site-packages/torch/utils/data/dataloader.py:521, in _BaseDataLoaderIter.next(self) 519 if self._sampler_iter is None: 520 self._reset() --> 521 data = self._next_data() 522 self._num_yielded += 1 523 if self._dataset_kind == _DatasetKind.Iterable and \ 524 self._IterableDataset_len_called is not None and \ 525 self._num_yielded > self._IterableDataset_len_called:
File ~/miniconda3/envs/st/lib/python3.8/site-packages/torch/utils/data/dataloader.py:561, in _SingleProcessDataLoaderIter._next_data(self) 559 def _next_data(self): 560 index = self._next_index() # may raise StopIteration --> 561 data = self._dataset_fetcher.fetch(index) # may raise StopIteration 562 if self._pin_memory: 563 data = _utils.pin_memory.pin_memory(data)
File ~/miniconda3/envs/st/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py:52, in _MapDatasetFetcher.fetch(self, possibly_batched_index) 50 else: 51 data = self.dataset[possibly_batched_index] ---> 52 return self.collate_fn(data)
File ~/miniconda3/envs/st/lib/python3.8/site-packages/torch/utils/data/_utils/collate.py:56, in default_collate(batch) 54 storage = elem.storage()._new_shared(numel) 55 out = elem.new(storage) ---> 56 return torch.stack(batch, 0, out=out) 57 elif elem_type.module == 'numpy' and elemtype.name != 'str' \ 58 and elemtype.name != 'string': 59 if elem_type.name == 'ndarray' or elem_type.name == 'memmap': 60 # array of string classes and object
RuntimeError: stack expects each tensor to be equal size, but got [6, 256, 256] at entry 0 and [6, 256, 255] at entry 9
@zt6597 Hi,could you try the code? `from stereo.tools.cell_correct import cell_correct
out_dir = "cell_correct_result" bgef_path = "C01626E6F6.raw.gef" image_path = "C01626E6F6_regist.tif" model_path = "cell_segmentation/seg_model_20211210.pth" model_type = "deep-learning" #model_path = "cell_segmentation_deepcell" #model_type = "deep-cell" gpu = -1 only_save_result = False fast = True data = cell_correct(out_dir=out_dir, bgef_path=bgef_path, image_path=image_path, model_path=model_path, model_type=model_type, gpu=gpu, process_count=10, only_save_result=only_save_result, fast=fast) `
@zt6597 Sorry for the late reply. After our troubleshooting, we found that there is a problem with our deep-learning model, which will be updated in the next version. Now we recommend that you use the deepcell model.
Thank u very much! At this timepoint, i find deep-learning model can work well in SAW pipeline.
Hi, the new version of stereopy (v0.11.0) has resolved this issue, please upgrade your stereopy version.
Notice: this issue has been closed because it has been inactive for 14 days. You may reopen this issue if it has been closed in error.
Hi stereopy team, I followed the cell correct tutorial to cell correct my data, code as followed in #96 Yet i got the error:
Python 3.8.16 | packaged by conda-forge | (default, Feb 1 2023, 16:01:55)
In [1]: from stereo.tools.cell_correct import cell_correct ...: bgef_path = "./data/C01626E6F6.raw.gef" ...: mask_path = "./data/C01626E6F6_regist.tif" ...: out_dir = "./cell_correct_result" ...: only_save_result = False ...: fast = True ...: data = cell_correct(out_dir=out_dir, ...: bgef_path=bgef_path, ...: mask_path=mask_path, ...: process_count=10, ...: only_save_result=only_save_result, ...: fast=fast) [2023-02-19 11:03:58][Stereo][328478][140382292883264][time_consume][55][INFO]: start to run cell_correct... [2023-02-19 11:03:58][Stereo][328478][140382292883264][time_consume][55][INFO]: start to run correcting... [2023-02-19 11:03:58][Stereo][328478][140382292883264][time_consume][55][INFO]: start to run generate_raw_data... [2023-02-19 11:03:58][Stereo][328478][140382292883264][cell_correct][99][INFO]: start to generate raw cellbin gef (./cell_correct_result/C01626E6F6.raw.raw.cellbin.gef) create h5 file: ./cell_correct_result/C01626E6F6.raw.raw.cellbin.gef minx:0 miny:0 maxx:26459 maxy:44099 genecnt:28263 geneExpcnt:138988822 hashcnt:99139069 readBgef_new - elapsed time: 223833.54450 ms img row:44100 col:26460 readmask_new - elapsed time: 3465.90027 ms storeAttr - 0.000116 cpu sec Segmentation fault (core dumped)
I don't know how to solve it? Thanks!