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 " ,
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 {
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 " ,
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 {
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 " ,
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 " ,
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 " ,
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 " ,
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 " ,
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 " ,
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 " ,
27422752 },
27432753 "nbformat" : 4 ,
27442754 "nbformat_minor" : 0
2745- }
2755+ }
0 commit comments