Skip to content

Commit 3a50f4a

Browse files
committed
StarDist2D 1.20.5, TensorFlow v2.19
1 parent 073ab8e commit 3a50f4a

3 files changed

Lines changed: 35 additions & 25 deletions

File tree

Colab_notebooks/Latest_Notebook_versions.csv

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Noise2Void (2D),1.16.2
2121
Noise2Void (3D),1.16.2
2222
pix2pix,1.17.5
2323
SplineDist (2D),1.14.1
24-
StarDist 2D,1.20.4
24+
StarDist 2D,1.20.5
2525
StarDist 3D,1.15.3
2626
YOLOv2,1.13
2727
Quality_control,1.13
@@ -30,5 +30,4 @@ DRMIME,1.14.1
3030
RetinaNet,1.14.1
3131
DFCAN 2D,1.14.1
3232
EmbedSeg 2D,1.15.0
33-
3433
WGAN 2D,1.15.1

Colab_notebooks/StarDist_2D_ZeroCostDL4Mic.ipynb

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,12 @@
165165
"\n",
166166
"# Install packages required for image processing and analysis\n",
167167
"\n",
168+
"# Downgrade numpy to a 1.X version\n",
169+
"import numpy as np\n",
170+
"if np.__version__ != \"1.26.4\":\n",
171+
" !pip uninstall numpy -y\n",
172+
" !pip install -q numpy==1.26.4\n",
173+
"\n",
168174
"# Package for handling tiff-files\n",
169175
"!pip install -q tifffile==2024.9.20\n",
170176
"\n",
@@ -185,21 +191,20 @@
185191
"!pip install -q fpdf2==2.8.2\n",
186192
"\n",
187193
"# Package for working with zarr, a format for efficient storage of large arrays\n",
194+
"!pip install -q numcodecs==0.15.1\n",
188195
"!pip install -q zarr==2.18.3\n",
189196
"\n",
190197
"# TensorFlow 2.15 and it's corresponding dependencies to avoid errors\n",
191-
"!pip install -q orbax-checkpoint==0.3.0\n",
192-
"!pip install -q tensorstore==0.1.40\n",
193-
"!pip install -q tf-keras==2.15\n",
194-
"!pip install -q tensorflow==2.15\n",
198+
"!pip install -q tf-keras==2.19\n",
199+
"!pip install -q tensorflow==2.19\n",
195200
"\n",
196201
"# Overall functionality: This code installs various packages necessary for image processing,\n",
197202
"# including handling image files, restoration of fluorescence microscopy images,\n",
198203
"# object detection and segmentation, GPU acceleration, file downloading, PDF generation,\n",
199204
"# table creation, storage of large arrays, and image compression.\n",
200205
"\n",
201206
"#Force session restart\n",
202-
"#exit(0)"
207+
"exit(0)"
203208
]
204209
},
205210
{
@@ -245,7 +250,7 @@
245250
"source": [
246251
"from __future__ import print_function, unicode_literals, absolute_import, division\n",
247252
"#@markdown ##Load key dependencies\n",
248-
"Notebook_version = '1.20.4'\n",
253+
"Notebook_version = '1.20.5'\n",
249254
"Network = 'StarDist 2D'\n",
250255
"\n",
251256
"from builtins import any as b_any\n",
@@ -948,7 +953,7 @@
948953
"source": [
949954
"#@markdown ##Play the cell to connect your Google Drive to Colab\n",
950955
"from google.colab import drive\n",
951-
"drive.mount('/content/gdrive')"
956+
"drive.mount('/content/gdrive', force_remount=True)"
952957
]
953958
},
954959
{
@@ -1085,27 +1090,27 @@
10851090
"Training_target = check_base_path(base_path, Training_target)\n",
10861091
"\n",
10871092
"#@markdown ###Name of the model and path to model folder:\n",
1088-
"model_name = 'test' #@param {type:\"string\"}\n",
1093+
"model_name = '' #@param {type:\"string\"}\n",
10891094
"model_path = '' #@param {type:\"string\"}\n",
10901095
"# Check that the base_path is on the path and otherwise add it\n",
10911096
"model_path = check_base_path(base_path, model_path)\n",
10921097
"\n",
10931098
"#@markdown ### Other parameters for training:\n",
1094-
"number_of_epochs = 50#@param {type:\"number\"}\n",
1099+
"number_of_epochs = 100#@param {type:\"number\"}\n",
10951100
"\n",
10961101
"#@markdown ###Advanced Parameters\n",
10971102
"Use_Default_Advanced_Parameters = True #@param {type:\"boolean\"}\n",
10981103
"\n",
10991104
"#@markdown ###If not, please input:\n",
11001105
"\n",
11011106
"#GPU_limit = 90 #@param {type:\"number\"}\n",
1102-
"batch_size = 15#@param {type:\"number\"}\n",
1107+
"batch_size = 2#@param {type:\"number\"}\n",
11031108
"number_of_steps = 50#@param {type:\"number\"}\n",
11041109
"patch_size = 512 #@param {type:\"number\"}\n",
11051110
"percentage_validation = 10 #@param {type:\"number\"}\n",
11061111
"n_rays = 32 #@param {type:\"number\"}\n",
11071112
"grid_parameter = 2#@param [1, 2, 4, 8, 16, 32] {type:\"raw\"}\n",
1108-
"initial_learning_rate = 0.0001 #@param {type:\"number\"}\n",
1113+
"initial_learning_rate = 0.0003 #@param {type:\"number\"}\n",
11091114
"\n",
11101115
"if (Use_Default_Advanced_Parameters):\n",
11111116
" print(\"Default advanced parameters enabled\")\n",
@@ -1226,7 +1231,7 @@
12261231
"source": [
12271232
"#Data augmentation\n",
12281233
"\n",
1229-
"Use_Data_augmentation = False #@param {type:\"boolean\"}\n",
1234+
"Use_Data_augmentation = True #@param {type:\"boolean\"}\n",
12301235
"\n",
12311236
"#@markdown ####Choose a factor by which you want to multiply your original dataset\n",
12321237
"\n",
@@ -1303,14 +1308,15 @@
13031308
"source": [
13041309
"# @markdown ##Loading weights from a pre-trained network\n",
13051310
"\n",
1306-
"Use_pretrained_model = True #@param {type:\"boolean\"}\n",
1311+
"Use_pretrained_model = False #@param {type:\"boolean\"}\n",
13071312
"pretrained_model_choice = \"2D_versatile_fluo_from_Stardist_Fiji\" #@param [\"Model_from_file\", \"BioImage Model Zoo\", \"2D_versatile_fluo_from_Stardist_Fiji\", \"2D_Demo_Model_from_Stardist_Github\", \"Versatile_H&E_nuclei\"]\n",
13081313
"Weights_choice = \"best\" #@param [\"last\", \"best\"]\n",
13091314
"\n",
13101315
"#@markdown ###If you chose \"Model_from_file\", please provide the path to the model folder:\n",
13111316
"pretrained_model_path = \"\" #@param {type:\"string\"}\n",
13121317
"# Check that the base_path is on the path and otherwise add it\n",
1313-
"pretrained_model_path = check_base_path(base_path, pretrained_model_path)\n",
1318+
"if pretrained_model_path:\n",
1319+
" pretrained_model_path = check_base_path(base_path, pretrained_model_path)\n",
13141320
"\n",
13151321
"#@markdown ###If you chose \"BioImage Model Zoo\", please provide the path or the URL to the model:\n",
13161322
"bioimageio_model = \"\" #@param {type:\"string\"}\n",
@@ -1654,7 +1660,7 @@
16541660
" for i in range(len(history.history['loss'])):\n",
16551661
" writer.writerow([history.history['loss'][i],\n",
16561662
" history.history['val_loss'][i],\n",
1657-
" history.history['lr'][i]])\n",
1663+
" history.history['learning_rate'][i]])\n",
16581664
"\n",
16591665
"\n",
16601666
"\n",
@@ -2440,8 +2446,8 @@
24402446
"#@markdown #####To analyse very large image, your images need to be divided into blocks. Each blocks will then be processed independently and re-assembled to generate the final image.\n",
24412447
"#@markdown #####Here you can choose the dimension of the block.\n",
24422448
"\n",
2443-
"block_size_Y = 1024#@param {type:\"number\"}\n",
2444-
"block_size_X = 1024#@param {type:\"number\"}\n",
2449+
"block_size_Y = 512#@param {type:\"number\"}\n",
2450+
"block_size_X = 512#@param {type:\"number\"}\n",
24452451
"\n",
24462452
"\n",
24472453
"#@markdown #####Here you can the amount of overlap between each block.\n",
@@ -2587,10 +2593,10 @@
25872593
"\n",
25882594
" # Save the predicted mask in the result folder\n",
25892595
" if Mask_images:\n",
2590-
" imsave(os.path.join(stack_result_path, f\"frame_{idx.zfill(5)}.tif\"),\n",
2596+
" imsave(os.path.join(stack_result_path, f\"frame_{str(idx).zfill(5)}.tif\"),\n",
25912597
" labels)\n",
25922598
" if Region_of_interests:\n",
2593-
" export_imagej_rois(os.path.join(polygon_stack_result_path, f\"frame_{idx.zfill(5)}.zip\"),\n",
2599+
" export_imagej_rois(os.path.join(polygon_stack_result_path, f\"frame_{str(idx).zfill(5)}.zip\"),\n",
25942600
" polygons['coord'],\n",
25952601
" compression=ZIP_DEFLATED)\n",
25962602
"\n",
@@ -2649,6 +2655,10 @@
26492655
"# **7. Version log**\n",
26502656
"---\n",
26512657
"\n",
2658+
"<font size = 4>**v1.20.5**: \n",
2659+
"\n",
2660+
"Fix the notebook to work with TensorFlow v2.19\n",
2661+
"\n",
26522662
"<font size = 4>**v1.20.4**: \n",
26532663
"\n",
26542664
"* Modify the section `6. Using the trained model notebook`:\n",
@@ -2742,4 +2752,4 @@
27422752
},
27432753
"nbformat": 4,
27442754
"nbformat_minor": 0
2745-
}
2755+
}

requirements_files/StarDist_2D_requirements_simple.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ future==1.0.0
77
h5py==3.12.1
88
ipywidgets==7.7.1
99
matplotlib==3.8.0
10+
numcodecs==0.15.1
1011
numpy==1.26.4
1112
opencv-python==4.10.0.84
1213
pandas==2.2.2
@@ -18,11 +19,11 @@ scikit-learn==1.5.2
1819
scipy==1.13.1
1920
stardist==0.9.1
2021
tabulate==0.9.0
21-
tensorflow==2.15.0
22+
tensorflow==2.19.0
2223
tifffile==2024.9.20
2324
tqdm==4.66.6
2425
wget==3.2
2526
zarr==2.18.3
2627
bioimageio.core==0.5.11
27-
keras==2.15.0
28-
h5py==3.12.1
28+
tf-keras==2.19.0
29+
h5py==3.12.1

0 commit comments

Comments
 (0)