Skip to content

Commit

Permalink
【Fix】 fix cell_segment
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhenbin24 committed Dec 4, 2023
1 parent 91c0ec1 commit f69952f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
38 changes: 21 additions & 17 deletions docs/source/Tutorials/Cell_Segmentation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
"\n",
"Install necessary packages by running commands as below:\n",
"\n",
">    **pip install tensorflow==2.7.0** \n",
">    **pip install torch==1.10.0** \n",
">    **pip install torchvision==0.11.1** \n",
">    **pip install tensorflow==2.7.0**\n",
">    **pip install torch==1.10.0**\n",
">    **pip install torchvision==0.11.1**\n",
">    **pip install albumentations==0.4.6**\n",
"\n",
"</div>"
Expand Down Expand Up @@ -136,14 +136,15 @@
"model = './cell_segmetation_v3.0.onnx'\n",
"image = './SS200000135TL_D1_regist.tif'\n",
"output = './result_v3'\n",
"tissue_seg_model = \"/data/users/wenzhenbin/script/cell_seg/weight_tissue_cut_tool_220304.hdf5\"\n",
"tissue_seg_model = \"./weight_tissue_cut_tool_220304.hdf5\"\n",
"\n",
"im.cell_seg_v3(\n",
" model_path=model,\n",
" img_path=image,\n",
" out_path=output,\n",
" need_tissue_cut=True,\n",
" gpu=0,\n",
" is_water=False,\n",
" tissue_seg_model_path=tissue_seg_model,\n",
" tissue_seg_method=1\n",
" )"
Expand Down Expand Up @@ -180,10 +181,10 @@
"source": [
"from stereo import image as im\n",
"\n",
"model = './cell_segmetation_v3.0.onnx'\n",
"model = './cellseg_bcdu_SHDI_221008_tf.onnx'\n",
"image = './SS200000135TL_D1_regist.tif'\n",
"output = './result_v3_new'\n",
"tissue_seg_model = \"//weight_tissue_cut_tool_220304.hdf5\"\n",
"tissue_seg_model = \"/weight_tissue_cut_tool_220304.hdf5\"\n",
"\n",
"im.cell_seg(\n",
" model_path=model,\n",
Expand All @@ -193,7 +194,7 @@
" gpu=0,\n",
" tissue_seg_model_path=tissue_seg_model,\n",
" tissue_seg_method=1,\n",
" version='v3'\n",
" method='v3'\n",
" )"
]
},
Expand Down Expand Up @@ -442,8 +443,8 @@
" out_path=output,\n",
" tissue_seg_model_path=tissue_seg_model,\n",
" tissue_seg_method=1,\n",
" num_threads=60\n",
" version=\"v1\"\n",
" num_threads=60,\n",
" method=\"v1\"\n",
" )"
]
},
Expand Down Expand Up @@ -2334,7 +2335,7 @@
"source": [
"from stereo import image as im\n",
"\n",
"model = './cell_segmentation_v1.0_pro.onnx'\n",
"model = './best_model.pth'\n",
"image = './SS200000135TL_D1_regist.tif'\n",
"output = './result_v1_pro'\n",
"tissue_seg_model = \"./weight_tissue_cut_tool_220304.hdf5\"\n",
Expand All @@ -2345,8 +2346,9 @@
" out_path=output,\n",
" tissue_seg_model_path=tissue_seg_model,\n",
" tissue_seg_method=1,\n",
" gpu=0, \n",
" version=\"v1_pro\"\n",
" gpu=0,\n",
" deep_crop_size=256,\n",
" method=\"v1_pro\"\n",
" )"
]
},
Expand Down Expand Up @@ -2418,15 +2420,17 @@
}
],
"source": [
"model = './cell_segmentation_deepcell/'\n",
"from stereo import image as im\n",
"\n",
"image = './SS200000135TL_D1_regist.tif'\n",
"output = './deepcell/'\n",
"model_path ='./'\n",
"tissue_seg_model = \"./weight_tissue_cut_tool_220304.hdf5\"\n",
"\n",
"im.cell_seg_deepcell(\n",
" model_dir=model,\n",
" img_path=image,\n",
" out_path=output,\n",
" model_path = model_path,\n",
" tissue_seg_model_path=tissue_seg_model,\n",
" tissue_seg_method=1\n",
" )"
Expand Down Expand Up @@ -2494,9 +2498,9 @@
"\n",
"Install necessary packages by running commands as below:\n",
"\n",
"> &ensp;&ensp; **pip install patchify** \n",
"> &ensp;&ensp; **pip install torch** \n",
"> &ensp;&ensp; **pip install fastremap** \n",
"> &ensp;&ensp; **pip install patchify**\n",
"> &ensp;&ensp; **pip install torch**\n",
"> &ensp;&ensp; **pip install fastremap**\n",
"> &ensp;&ensp; **pip install roifile**\n",
"\n",
"</div>"
Expand Down
3 changes: 1 addition & 2 deletions stereo/image/segmentation_deepcell/seg_utils/cell_infer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging
import os

import numpy as np
import tensorflow as tf
Expand Down Expand Up @@ -31,7 +30,7 @@ def __init__(self,
format_model_output_fn=None,
dataset_metadata=None,
model_metadata=None):
model_path = os.path.join(os.path.split(__file__)[0], 'model') if model is None else model
model_path = model
self.model = tf.keras.models.load_model(model_path, compile=False)
self.model_image_shape = self.model.input_shape[1:]
# Require dimension 1 larger than model_input_shape due to addition of batch dimension
Expand Down
2 changes: 0 additions & 2 deletions stereo/image/segmentation_deepcell/segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ def cell_seg_deepcell(
------------------
None
"""
if version == 'v1' and not model_path:
raise Exception("cell_seg_deepcell() missing 1 required keyword argument: 'model_path'")
try:
import tensorflow as tf # noqa
except Exception:
Expand Down

0 comments on commit f69952f

Please sign in to comment.