Skip to content

Commit

Permalink
updated notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
mese79 committed Oct 24, 2024
1 parent a6c4cda commit 75988b0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
19 changes: 13 additions & 6 deletions run_pipeline.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -201,17 +201,17 @@
"outputs": [],
"source": [
"# input image\n",
"data_path = \"../datasets/Johan/dino_host/test_substacks/Stack02_bin4_(1-3598-3).tif\"\n",
"data_path = \"../datasets/data.tif\"\n",
"data_path = Path(data_path)\n",
"print(f\"data_path exists: {data_path.exists()}\")\n",
"\n",
"# random forest model\n",
"rf_model_path = \"../datasets/Johan/dino_host/mito/host/rf_model.bin\"\n",
"rf_model_path = \"../datasets/rf_model.bin\"\n",
"rf_model_path = Path(rf_model_path)\n",
"print(f\"rf_model_path exists: {rf_model_path.exists()}\")\n",
"\n",
"# result folder\n",
"segmentation_dir = Path(\"../datasets/Johan/dino_host/mito/host/segmentation_result\")\n",
"segmentation_dir = Path(\"../datasets/segmentation_result\")\n",
"segmentation_dir.mkdir(parents=True, exist_ok=True)\n",
"\n",
"# temporary storage path for saving extracted embeddings patches\n",
Expand Down Expand Up @@ -249,9 +249,16 @@
"outputs": [],
"source": [
"with open(rf_model_path, mode=\"rb\") as f:\n",
" rf_model = pickle.load(f)\n",
" rf_model.set_params(verbose=0)\n",
"\n",
" model_data = pickle.load(f)\n",
"# compatibility check for old format rf model\n",
"if isinstance(model_data, dict): # noqa: SIM108\n",
" # new format\n",
" rf_model = model_data[\"rf_model\"]\n",
"else:\n",
" # old format\n",
" rf_model = model_data\n",
"\n",
"rf_model.set_params(verbose=0)\n",
"rf_model"
]
},
Expand Down
2 changes: 1 addition & 1 deletion src/featureforest/utils/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def get_slice_features(

# get sam encoder output for image patches
print("extracting features:")
for b_idx in np_progress(range(num_batches), desc="extracting feature:"):
for b_idx in np_progress(range(num_batches), desc="extracting feature"):
print(f"batch #{b_idx + 1} of {num_batches}")
start = b_idx * batch_size
end = start + batch_size
Expand Down

0 comments on commit 75988b0

Please sign in to comment.