diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 43e68993..716887b8 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -7,7 +7,6 @@ on: push: branches: - main - - cy/training tags: - "v*" # Push events to matching v*, i.e. v1.0, v20.15.10 pull_request: diff --git a/.gitignore b/.gitignore index 157a1987..449daa44 100644 --- a/.gitignore +++ b/.gitignore @@ -126,6 +126,7 @@ wandb/ !napari_cellseg3d/_tests/res/wnet_test/*.tif !napari_cellseg3d/_tests/res/wnet_test/lab/*.tif !napari_cellseg3d/_tests/res/wnet_test/vol/*.tif +!examples/* #include docs images !docs/source/logo/* diff --git a/.napari/DESCRIPTION.md b/.napari/DESCRIPTION.md index 9a3143bb..d379ed68 100644 --- a/.napari/DESCRIPTION.md +++ b/.napari/DESCRIPTION.md @@ -117,7 +117,7 @@ this information here. ## Getting Help If you would like to report an issue with the plugin, -please open an [issue on Github](https://github.com/AdaptiveMotorControlLab/CellSeg3d/issues) +please open an [issue on Github](https://github.com/AdaptiveMotorControlLab/CellSeg3D/issues) 34\u001b[0m view \u001b[39m=\u001b[39m napari\u001b[39m.\u001b[39;49mview_image(preds, colormap\u001b[39m=\u001b[39;49m\u001b[39m\"\u001b[39;49m\u001b[39mturbo\u001b[39;49m\u001b[39m\"\u001b[39;49m)\n\u001b[0;32m 35\u001b[0m view\u001b[39m.\u001b[39madd_image(test_image, colormap\u001b[39m=\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mturbo\u001b[39m\u001b[39m\"\u001b[39m, blending\u001b[39m=\u001b[39m\u001b[39m\"\u001b[39m\u001b[39madditive\u001b[39m\u001b[39m\"\u001b[39m)\n\u001b[0;32m 36\u001b[0m view\u001b[39m.\u001b[39madd_image(rejected, colormap\u001b[39m=\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mturbo\u001b[39m\u001b[39m\"\u001b[39m, blending\u001b[39m=\u001b[39m\u001b[39m\"\u001b[39m\u001b[39madditive\u001b[39m\u001b[39m\"\u001b[39m)\n", + "\u001b[1;32mc:\\Users\\Cyril\\Desktop\\Code\\CellSeg3D\\napari_cellseg3d\\dev_scripts\\classifier_test.ipynb Cell 12\u001b[0m line \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 31\u001b[0m preds[crop_location_i:crop_location_i\u001b[39m+\u001b[39mcube_size, crop_location_j:crop_location_j\u001b[39m+\u001b[39mcube_size, crop_location_k:crop_location_k\u001b[39m+\u001b[39mcube_size] \u001b[39m=\u001b[39m \u001b[39m0\u001b[39m\n\u001b[0;32m 32\u001b[0m rejected[crop_location_i:crop_location_i\u001b[39m+\u001b[39mcube_size, crop_location_j:crop_location_j\u001b[39m+\u001b[39mcube_size, crop_location_k:crop_location_k\u001b[39m+\u001b[39mcube_size] \u001b[39m=\u001b[39m crop\n\u001b[1;32m---> 34\u001b[0m view \u001b[39m=\u001b[39m napari\u001b[39m.\u001b[39;49mview_image(preds, colormap\u001b[39m=\u001b[39;49m\u001b[39m\"\u001b[39;49m\u001b[39mturbo\u001b[39;49m\u001b[39m\"\u001b[39;49m)\n\u001b[0;32m 35\u001b[0m view\u001b[39m.\u001b[39madd_image(test_image, colormap\u001b[39m=\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mturbo\u001b[39m\u001b[39m\"\u001b[39m, blending\u001b[39m=\u001b[39m\u001b[39m\"\u001b[39m\u001b[39madditive\u001b[39m\u001b[39m\"\u001b[39m)\n\u001b[0;32m 36\u001b[0m view\u001b[39m.\u001b[39madd_image(rejected, colormap\u001b[39m=\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mturbo\u001b[39m\u001b[39m\"\u001b[39m, blending\u001b[39m=\u001b[39m\u001b[39m\"\u001b[39m\u001b[39madditive\u001b[39m\u001b[39m\"\u001b[39m)\n", "File \u001b[1;32mc:\\Users\\Cyril\\anaconda3\\envs\\cellseg3d\\lib\\site-packages\\napari\\view_layers.py:178\u001b[0m, in \u001b[0;36mview_image\u001b[1;34m(*args, **kwargs)\u001b[0m\n\u001b[0;32m 176\u001b[0m \u001b[39m@_merge_layer_viewer_sigs_docs\u001b[39m\n\u001b[0;32m 177\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mview_image\u001b[39m(\u001b[39m*\u001b[39margs, \u001b[39m*\u001b[39m\u001b[39m*\u001b[39mkwargs):\n\u001b[1;32m--> 178\u001b[0m \u001b[39mreturn\u001b[39;00m _make_viewer_then(\u001b[39m'\u001b[39;49m\u001b[39madd_image\u001b[39;49m\u001b[39m'\u001b[39;49m, args, kwargs)[\u001b[39m0\u001b[39m]\n", "File \u001b[1;32mc:\\Users\\Cyril\\anaconda3\\envs\\cellseg3d\\lib\\site-packages\\napari\\view_layers.py:156\u001b[0m, in \u001b[0;36m_make_viewer_then\u001b[1;34m(add_method, args, kwargs)\u001b[0m\n\u001b[0;32m 154\u001b[0m viewer \u001b[39m=\u001b[39m kwargs\u001b[39m.\u001b[39mpop(\u001b[39m\"\u001b[39m\u001b[39mviewer\u001b[39m\u001b[39m\"\u001b[39m, \u001b[39mNone\u001b[39;00m)\n\u001b[0;32m 155\u001b[0m \u001b[39mif\u001b[39;00m viewer \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m:\n\u001b[1;32m--> 156\u001b[0m viewer \u001b[39m=\u001b[39m Viewer(\u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mvkwargs)\n\u001b[0;32m 157\u001b[0m kwargs\u001b[39m.\u001b[39mupdate(kwargs\u001b[39m.\u001b[39mpop(\u001b[39m\"\u001b[39m\u001b[39mkwargs\u001b[39m\u001b[39m\"\u001b[39m, {}))\n\u001b[0;32m 158\u001b[0m method \u001b[39m=\u001b[39m \u001b[39mgetattr\u001b[39m(viewer, add_method)\n", "File \u001b[1;32mc:\\Users\\Cyril\\anaconda3\\envs\\cellseg3d\\lib\\site-packages\\napari\\viewer.py:67\u001b[0m, in \u001b[0;36mViewer.__init__\u001b[1;34m(self, title, ndisplay, order, axis_labels, show)\u001b[0m\n\u001b[0;32m 63\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mnapari\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mwindow\u001b[39;00m \u001b[39mimport\u001b[39;00m Window\n\u001b[0;32m 65\u001b[0m _initialize_plugins()\n\u001b[1;32m---> 67\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_window \u001b[39m=\u001b[39m Window(\u001b[39mself\u001b[39;49m, show\u001b[39m=\u001b[39;49mshow)\n\u001b[0;32m 68\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_instances\u001b[39m.\u001b[39madd(\u001b[39mself\u001b[39m)\n", diff --git a/napari_cellseg3d/dev_scripts/colab_training.py b/napari_cellseg3d/dev_scripts/colab_training.py index ef5245e8..a5020fec 100644 --- a/napari_cellseg3d/dev_scripts/colab_training.py +++ b/napari_cellseg3d/dev_scripts/colab_training.py @@ -332,7 +332,7 @@ def train( project="CellSeg3D (Colab)", name=f"{self.config.model_info.name} training - {utils.get_date_time()}", mode=self.wandb_config.mode, - tags=["WNet", "Colab"], + tags=["WNet3D", "Colab"], ) set_determinism(seed=self.config.deterministic_config.seed) @@ -379,7 +379,7 @@ def train( if self.config.weights_info.use_custom: if self.config.weights_info.use_pretrained: weights_file = "wnet.pth" - self.downloader.download_weights("WNet", weights_file) + self.downloader.download_weights("WNet3D", weights_file) weights = PRETRAINED_WEIGHTS_DIR / Path(weights_file) self.config.weights_info.path = weights else: @@ -596,9 +596,9 @@ def train( if WANDB_INSTALLED and self.wandb_config.save_model_artifact: model_artifact = wandb.Artifact( - "WNet", + "WNet3D", type="model", - description="CellSeg3D WNet", + description="CellSeg3D WNet3D", metadata=self.config.__dict__, ) model_artifact.add_file(save_weights_path) diff --git a/napari_cellseg3d/dev_scripts/remote_inference.py b/napari_cellseg3d/dev_scripts/remote_inference.py new file mode 100644 index 00000000..7a28bf51 --- /dev/null +++ b/napari_cellseg3d/dev_scripts/remote_inference.py @@ -0,0 +1,188 @@ +"""Script to perform inference on a single image and run post-processing on the results, withot napari.""" +import logging +from dataclasses import dataclass +from pathlib import Path +from typing import List + +import numpy as np +import torch + +from napari_cellseg3d.code_models.instance_segmentation import ( + clear_large_objects, + clear_small_objects, + threshold, + volume_stats, + voronoi_otsu, +) +from napari_cellseg3d.code_models.worker_inference import InferenceWorker +from napari_cellseg3d.config import ( + InferenceWorkerConfig, + InstanceSegConfig, + ModelInfo, + SlidingWindowConfig, +) +from napari_cellseg3d.utils import resize + +logger = logging.getLogger(__name__) +logging.basicConfig(level=logging.INFO) + + +class LogFixture: + """Fixture for napari-less logging, replaces napari_cellseg3d.interface.Log in model_workers. + + This allows to redirect the output of the workers to stdout instead of a specialized widget. + """ + + def __init__(self): + """Creates a LogFixture object.""" + super(LogFixture, self).__init__() + + def print_and_log(self, text, printing=None): + """Prints and logs text.""" + print(text) + + def warn(self, warning): + """Logs warning.""" + logger.warning(warning) + + def error(self, e): + """Logs error.""" + raise (e) + + +WINDOW_SIZE = 64 + +MODEL_INFO = ModelInfo( + name="SwinUNetR", + model_input_size=64, +) + +CONFIG = InferenceWorkerConfig( + device="cuda" if torch.cuda.is_available() else "cpu", + model_info=MODEL_INFO, + results_path=str(Path("./results").absolute()), + compute_stats=False, + sliding_window_config=SlidingWindowConfig(WINDOW_SIZE, 0.25), +) + + +@dataclass +class PostProcessConfig: + """Config for post-processing.""" + + threshold: float = 0.4 + spot_sigma: float = 0.55 + outline_sigma: float = 0.55 + isotropic_spot_sigma: float = 0.2 + isotropic_outline_sigma: float = 0.2 + anisotropy_correction: List[ + float + ] = None # TODO change to actual values, should be a ratio like [1,1/5,1] + clear_small_size: int = 5 + clear_large_objects: int = 500 + + +def inference_on_images( + image: np.array, config: InferenceWorkerConfig = CONFIG +): + """This function provides inference on an image with minimal config. + + Args: + image (np.array): Image to perform inference on. + config (InferenceWorkerConfig, optional): Config for InferenceWorker. Defaults to CONFIG, see above. + """ + # instance_method = InstanceSegmentationWrapper(voronoi_otsu, {"spot_sigma": 0.7, "outline_sigma": 0.7}) + + config.post_process_config.zoom.enabled = False + config.post_process_config.thresholding.enabled = ( + False # will need to be enabled and set to 0.5 for the test images + ) + config.post_process_config.instance = InstanceSegConfig( + enabled=False, + ) + + config.layer = image + + log = LogFixture() + worker = InferenceWorker(config) + logger.debug(f"Worker config: {worker.config}") + + worker.log_signal.connect(log.print_and_log) + worker.warn_signal.connect(log.warn) + worker.error_signal.connect(log.error) + + worker.log_parameters() + + results = [] + # append the InferenceResult when yielded by worker to results + for result in worker.inference(): + results.append(result) + + return results + + +def post_processing(semantic_segmentation, config: PostProcessConfig = None): + """Run post-processing on inference results.""" + config = PostProcessConfig() if config is None else config + # if config.anisotropy_correction is None: + # config.anisotropy_correction = [1, 1, 1 / 5] + if config.anisotropy_correction is None: + config.anisotropy_correction = [1, 1, 1] + + image = semantic_segmentation + # apply threshold to semantic segmentation + logger.info(f"Thresholding with {config.threshold}") + image = threshold(image, config.threshold) + logger.debug(f"Thresholded image shape: {image.shape}") + # remove artifacts by clearing large objects + logger.info(f"Clearing large objects with {config.clear_large_objects}") + image = clear_large_objects(image, config.clear_large_objects) + # run instance segmentation + logger.info( + f"Running instance segmentation with {config.spot_sigma} and {config.outline_sigma}" + ) + labels = voronoi_otsu( + image, + spot_sigma=config.spot_sigma, + outline_sigma=config.outline_sigma, + ) + # clear small objects + logger.info(f"Clearing small objects with {config.clear_small_size}") + labels = clear_small_objects(labels, config.clear_small_size).astype( + np.uint16 + ) + logger.debug(f"Labels shape: {labels.shape}") + # get volume stats WITH ANISOTROPY + logger.debug(f"NUMBER OF OBJECTS: {np.max(np.unique(labels))-1}") + stats_not_resized = volume_stats(labels) + ######## RUN WITH ANISOTROPY ######## + result_dict = {} + result_dict["Not resized"] = { + "labels": labels, + "stats": stats_not_resized, + } + + if config.anisotropy_correction != [1, 1, 1]: + logger.info("Resizing image to correct anisotropy") + image = resize(image, config.anisotropy_correction) + logger.debug(f"Resized image shape: {image.shape}") + logger.info("Running labels without anisotropy") + labels_resized = voronoi_otsu( + image, + spot_sigma=config.isotropic_spot_sigma, + outline_sigma=config.isotropic_outline_sigma, + ) + logger.info( + f"Clearing small objects with {config.clear_large_objects}" + ) + labels_resized = clear_small_objects( + labels_resized, config.clear_small_size + ).astype(np.uint16) + logger.debug( + f"NUMBER OF OBJECTS: {np.max(np.unique(labels_resized))-1}" + ) + logger.info("Getting volume stats without anisotropy") + stats_resized = volume_stats(labels_resized) + return labels_resized, stats_resized + + return labels, stats_not_resized diff --git a/napari_cellseg3d/dev_scripts/test_new_evaluation.ipynb b/napari_cellseg3d/dev_scripts/test_new_evaluation.ipynb index 12707e9b..dcb7ace9 100644 --- a/napari_cellseg3d/dev_scripts/test_new_evaluation.ipynb +++ b/napari_cellseg3d/dev_scripts/test_new_evaluation.ipynb @@ -24,7 +24,7 @@ { "data": { "text/plain": [ - "" + "" ] }, "execution_count": 2, @@ -62,8 +62,8 @@ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[1;31mIndexError\u001b[0m Traceback (most recent call last)", "Cell \u001b[1;32mIn[16], line 4\u001b[0m\n\u001b[0;32m 2\u001b[0m labels \u001b[38;5;241m=\u001b[39m imread(path_model_label)\n\u001b[0;32m 3\u001b[0m \u001b[38;5;66;03m# labels.shape\u001b[39;00m\n\u001b[1;32m----> 4\u001b[0m res \u001b[38;5;241m=\u001b[39m \u001b[43mevl\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mevaluate_model_performance\u001b[49m\u001b[43m(\u001b[49m\u001b[43mimread\u001b[49m\u001b[43m(\u001b[49m\u001b[43mpath_true_labels\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mlabels\u001b[49m\u001b[43m,\u001b[49m\u001b[43mvisualize\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mreturn_graphical_summary\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m,\u001b[49m\u001b[43mplot_according_to_gt_label\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m)\u001b[49m\n", - "File \u001b[1;32m~\\Desktop\\Code\\CellSeg3d\\napari_cellseg3d\\dev_scripts\\evaluate_labels.py:58\u001b[0m, in \u001b[0;36mevaluate_model_performance\u001b[1;34m(labels, model_labels, threshold_correct, print_details, visualize, return_graphical_summary, plot_according_to_gt_label)\u001b[0m\n\u001b[0;32m 20\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124;03m\"\"\"Evaluate the model performance.\u001b[39;00m\n\u001b[0;32m 21\u001b[0m \u001b[38;5;124;03mParameters\u001b[39;00m\n\u001b[0;32m 22\u001b[0m \u001b[38;5;124;03m----------\u001b[39;00m\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 55\u001b[0m \u001b[38;5;124;03mgraph_true_positive_ratio_model: ndarray\u001b[39;00m\n\u001b[0;32m 56\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[0;32m 57\u001b[0m log\u001b[38;5;241m.\u001b[39mdebug(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mMapping labels...\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m---> 58\u001b[0m tmp \u001b[38;5;241m=\u001b[39m \u001b[43mmap_labels\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 59\u001b[0m \u001b[43m \u001b[49m\u001b[43mlabels\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 60\u001b[0m \u001b[43m \u001b[49m\u001b[43mmodel_labels\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 61\u001b[0m \u001b[43m \u001b[49m\u001b[43mthreshold_correct\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 62\u001b[0m \u001b[43m \u001b[49m\u001b[43mreturn_total_number_gt_labels\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[0;32m 63\u001b[0m \u001b[43m \u001b[49m\u001b[43mreturn_dict_map\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[0;32m 64\u001b[0m \u001b[43m \u001b[49m\u001b[43mreturn_graphical_summary\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mreturn_graphical_summary\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 65\u001b[0m \u001b[43m \u001b[49m\u001b[43mplot_according_to_gt_labels\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mplot_according_to_gt_label\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 66\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 67\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m return_graphical_summary:\n\u001b[0;32m 68\u001b[0m (\n\u001b[0;32m 69\u001b[0m map_labels_existing,\n\u001b[0;32m 70\u001b[0m map_fused_neurons,\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 75\u001b[0m graph_true_positive_ratio_model,\n\u001b[0;32m 76\u001b[0m ) \u001b[38;5;241m=\u001b[39m tmp\n", - "File \u001b[1;32m~\\Desktop\\Code\\CellSeg3d\\napari_cellseg3d\\dev_scripts\\evaluate_labels.py:422\u001b[0m, in \u001b[0;36mmap_labels\u001b[1;34m(gt_labels, model_labels, threshold_correct, return_total_number_gt_labels, return_dict_map, accuracy_function, return_graphical_summary, plot_according_to_gt_labels)\u001b[0m\n\u001b[0;32m 419\u001b[0m \u001b[38;5;66;03m# remove from new_labels the labels that are in map_labels_existing\u001b[39;00m\n\u001b[0;32m 420\u001b[0m new_labels \u001b[38;5;241m=\u001b[39m np\u001b[38;5;241m.\u001b[39marray(new_labels)\n\u001b[0;32m 421\u001b[0m i_new_labels \u001b[38;5;241m=\u001b[39m np\u001b[38;5;241m.\u001b[39misin(\n\u001b[1;32m--> 422\u001b[0m \u001b[43mnew_labels\u001b[49m\u001b[43m[\u001b[49m\u001b[43m:\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mdict_map\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mmodel_label\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m]\u001b[49m,\n\u001b[0;32m 423\u001b[0m map_labels_existing[:, dict_map[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mmodel_label\u001b[39m\u001b[38;5;124m\"\u001b[39m]],\n\u001b[0;32m 424\u001b[0m invert\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m,\n\u001b[0;32m 425\u001b[0m )\n\u001b[0;32m 426\u001b[0m new_labels \u001b[38;5;241m=\u001b[39m new_labels[i_new_labels, :]\n\u001b[0;32m 427\u001b[0m \u001b[38;5;66;03m# find the fused neurons: multiple gt labels are mapped to the same model label\u001b[39;00m\n", + "File \u001b[1;32m~\\Desktop\\Code\\CellSeg3D\\napari_cellseg3d\\dev_scripts\\evaluate_labels.py:58\u001b[0m, in \u001b[0;36mevaluate_model_performance\u001b[1;34m(labels, model_labels, threshold_correct, print_details, visualize, return_graphical_summary, plot_according_to_gt_label)\u001b[0m\n\u001b[0;32m 20\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124;03m\"\"\"Evaluate the model performance.\u001b[39;00m\n\u001b[0;32m 21\u001b[0m \u001b[38;5;124;03mParameters\u001b[39;00m\n\u001b[0;32m 22\u001b[0m \u001b[38;5;124;03m----------\u001b[39;00m\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 55\u001b[0m \u001b[38;5;124;03mgraph_true_positive_ratio_model: ndarray\u001b[39;00m\n\u001b[0;32m 56\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[0;32m 57\u001b[0m log\u001b[38;5;241m.\u001b[39mdebug(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mMapping labels...\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m---> 58\u001b[0m tmp \u001b[38;5;241m=\u001b[39m \u001b[43mmap_labels\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 59\u001b[0m \u001b[43m \u001b[49m\u001b[43mlabels\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 60\u001b[0m \u001b[43m \u001b[49m\u001b[43mmodel_labels\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 61\u001b[0m \u001b[43m \u001b[49m\u001b[43mthreshold_correct\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 62\u001b[0m \u001b[43m \u001b[49m\u001b[43mreturn_total_number_gt_labels\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[0;32m 63\u001b[0m \u001b[43m \u001b[49m\u001b[43mreturn_dict_map\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[0;32m 64\u001b[0m \u001b[43m \u001b[49m\u001b[43mreturn_graphical_summary\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mreturn_graphical_summary\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 65\u001b[0m \u001b[43m \u001b[49m\u001b[43mplot_according_to_gt_labels\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mplot_according_to_gt_label\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 66\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 67\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m return_graphical_summary:\n\u001b[0;32m 68\u001b[0m (\n\u001b[0;32m 69\u001b[0m map_labels_existing,\n\u001b[0;32m 70\u001b[0m map_fused_neurons,\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 75\u001b[0m graph_true_positive_ratio_model,\n\u001b[0;32m 76\u001b[0m ) \u001b[38;5;241m=\u001b[39m tmp\n", + "File \u001b[1;32m~\\Desktop\\Code\\CellSeg3D\\napari_cellseg3d\\dev_scripts\\evaluate_labels.py:422\u001b[0m, in \u001b[0;36mmap_labels\u001b[1;34m(gt_labels, model_labels, threshold_correct, return_total_number_gt_labels, return_dict_map, accuracy_function, return_graphical_summary, plot_according_to_gt_labels)\u001b[0m\n\u001b[0;32m 419\u001b[0m \u001b[38;5;66;03m# remove from new_labels the labels that are in map_labels_existing\u001b[39;00m\n\u001b[0;32m 420\u001b[0m new_labels \u001b[38;5;241m=\u001b[39m np\u001b[38;5;241m.\u001b[39marray(new_labels)\n\u001b[0;32m 421\u001b[0m i_new_labels \u001b[38;5;241m=\u001b[39m np\u001b[38;5;241m.\u001b[39misin(\n\u001b[1;32m--> 422\u001b[0m \u001b[43mnew_labels\u001b[49m\u001b[43m[\u001b[49m\u001b[43m:\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mdict_map\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mmodel_label\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m]\u001b[49m,\n\u001b[0;32m 423\u001b[0m map_labels_existing[:, dict_map[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mmodel_label\u001b[39m\u001b[38;5;124m\"\u001b[39m]],\n\u001b[0;32m 424\u001b[0m invert\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m,\n\u001b[0;32m 425\u001b[0m )\n\u001b[0;32m 426\u001b[0m new_labels \u001b[38;5;241m=\u001b[39m new_labels[i_new_labels, :]\n\u001b[0;32m 427\u001b[0m \u001b[38;5;66;03m# find the fused neurons: multiple gt labels are mapped to the same model label\u001b[39;00m\n", "\u001b[1;31mIndexError\u001b[0m: too many indices for array: array is 1-dimensional, but 2 were indexed" ] } diff --git a/notebooks/Colab_WNet3D_training.ipynb b/notebooks/Colab_WNet3D_training.ipynb new file mode 100644 index 00000000..0c5ed172 --- /dev/null +++ b/notebooks/Colab_WNet3D_training.ipynb @@ -0,0 +1,498 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "provenance": [], + "gpuType": "T4", + "include_colab_link": true + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + }, + "accelerator": "GPU" + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "source": [ + "# **WNet3D: self-supervised 3D cell segmentation**\n", + "\n", + "---\n", + "\n", + "This notebook is part of the [CellSeg3D project](https://github.com/AdaptiveMotorControlLab/CellSeg3d) in the [Mathis Lab of Adaptive Intelligence](https://www.mackenziemathislab.org/).\n", + "\n", + "- πŸ’œ The foundation of this notebook owes much to the **[ZeroCostDL4Mic](https://github.com/HenriquesLab/ZeroCostDL4Mic)** project and to the **[DeepLabCut](https://github.com/DeepLabCut/DeepLabCut)** team for bringing Colab into scientific open software." + ], + "metadata": { + "id": "BTUVNXX7R3Go" + } + }, + { + "cell_type": "markdown", + "source": [ + "#**1. Installing dependencies**\n", + "---" + ], + "metadata": { + "id": "zmVCksV0EfVT" + } + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "td_vf_pneSak" + }, + "outputs": [], + "source": [ + "#@markdown ##Play to install WNet dependencies\n", + "!pip install napari-cellseg3d" + ] + }, + { + "cell_type": "markdown", + "source": [ + "##**1.2 Load key dependencies**\n", + "---" + ], + "metadata": { + "id": "nqctRognFGDT" + } + }, + { + "cell_type": "code", + "source": [ + "# @title\n", + "from pathlib import Path\n", + "from napari_cellseg3d.dev_scripts import colab_training as c\n", + "from napari_cellseg3d.config import WNetTrainingWorkerConfig, WandBConfig, WeightsInfo, PRETRAINED_WEIGHTS_DIR" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "wOOhJjkxjXz-", + "outputId": "8f94416d-a482-4ec6-f980-a728e908d90d" + }, + "execution_count": 2, + "outputs": [ + { + "output_type": "stream", + "name": "stderr", + "text": [ + "INFO:napari_cellseg3d.utils:wandb not installed, wandb config will not be taken into account\n", + "WARNING:napari_cellseg3d.utils:wandb not installed, wandb config will not be taken into account\n" + ] + } + ] + }, + { + "cell_type": "markdown", + "source": [ + "## (optional) **1.3 Initialize Weights & Biases integration **\n", + "---\n", + "If you wish to utilize Weights & Biases (WandB) for monitoring and logging your training session, execute the cell below.\n", + "To enable it, just input your API key in the space provided." + ], + "metadata": { + "id": "Ax-vJAWRwIKi" + } + }, + { + "cell_type": "code", + "source": [ + "!pip install -q wandb\n", + "import wandb\n", + "wandb.login()" + ], + "metadata": { + "id": "QNgC3awjwb7G" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# **2. Complete the Colab session**\n", + "---\n" + ], + "metadata": { + "id": "Zi9gRBHFFyX-" + } + }, + { + "cell_type": "markdown", + "source": [ + "\n", + "## **2.1. Check for GPU access**\n", + "---\n", + "\n", + "By default, this session is configured to use Python 3 and GPU acceleration. To verify or adjust these settings:\n", + "\n", + "Navigate to Runtime and select Change the Runtime type.\n", + "\n", + "For Runtime type, ensure it's set to Python 3 (the programming language this program is written in).\n", + "\n", + "Under Accelerator, choose GPU (Graphics Processing Unit).\n" + ], + "metadata": { + "id": "zSU-LYTfFnvF" + } + }, + { + "cell_type": "code", + "source": [ + "#@markdown ##Execute the cell below to verify if GPU access is available.\n", + "\n", + "import torch\n", + "if not torch.cuda.is_available():\n", + " print('You do not have GPU access.')\n", + " print('Did you change your runtime?')\n", + " print('If the runtime setting is correct then Google did not allocate a GPU for your session')\n", + " print('Expect slow performance. To access GPU try reconnecting later')\n", + "\n", + "else:\n", + " print('You have GPU access')\n", + " !nvidia-smi\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "Ie7bXiMgFtPH", + "outputId": "3276444c-5109-47b4-f507-ea9acaab15ad" + }, + "execution_count": 3, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "You have GPU access\n", + "Fri May 3 17:19:13 2024 \n", + "+---------------------------------------------------------------------------------------+\n", + "| NVIDIA-SMI 535.104.05 Driver Version: 535.104.05 CUDA Version: 12.2 |\n", + "|-----------------------------------------+----------------------+----------------------+\n", + "| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |\n", + "| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |\n", + "| | | MIG M. |\n", + "|=========================================+======================+======================|\n", + "| 0 Tesla T4 Off | 00000000:00:04.0 Off | 0 |\n", + "| N/A 50C P8 10W / 70W | 3MiB / 15360MiB | 0% Default |\n", + "| | | N/A |\n", + "+-----------------------------------------+----------------------+----------------------+\n", + " \n", + "+---------------------------------------------------------------------------------------+\n", + "| Processes: |\n", + "| GPU GI CI PID Type Process name GPU Memory |\n", + "| ID ID Usage |\n", + "|=======================================================================================|\n", + "| No running processes found |\n", + "+---------------------------------------------------------------------------------------+\n" + ] + } + ] + }, + { + "cell_type": "markdown", + "source": [ + "## **2.2. Mount Google Drive**\n", + "---\n", + "To integrate this notebook with your personal data, save your data on Google Drive in accordance with the directory structures detailed in Section 0.\n", + "\n", + "1. **Run** the **cell** below and click on the provided link.\n", + "\n", + "2. Log in to your Google account and grant the necessary permissions by clicking 'Allow'.\n", + "\n", + "3. Copy the generated authorization code and paste it into the cell, then press 'Enter'. This grants Colab access to read and write data to your Google Drive.\n", + "\n", + "4. After completion, you can view your data in the notebook. Simply click the Files tab on the top left and select 'Refresh'." + ], + "metadata": { + "id": "X_bbk7RAF2yw" + } + }, + { + "cell_type": "code", + "source": [ + "# mount user's Google Drive to Google Colab.\n", + "from google.colab import drive\n", + "drive.mount('/content/gdrive')" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "AsIARCablq1V", + "outputId": "77ffdbd1-4c89-4a56-e3da-7777a607a328" + }, + "execution_count": 4, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Mounted at /content/gdrive\n" + ] + } + ] + }, + { + "cell_type": "markdown", + "source": [ + "** If you cannot see your files, reactivate your session by connecting to your hosted runtime.**\n", + "\n", + "\n", + "\"Example
Connect to a hosted runtime.
" + ], + "metadata": { + "id": "r6FI22lkQLTv" + } + }, + { + "cell_type": "code", + "source": [ + "# @title\n", + "# import wandb\n", + "# wandb.login()" + ], + "metadata": { + "id": "EtsK08ECwlnJ" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "# **3. Select your parameters and paths**\n", + "---" + ], + "metadata": { + "id": "IkOpxYjaGM0m" + } + }, + { + "cell_type": "markdown", + "source": [ + "## **3.1. Choosing parameters**\n", + "\n", + "---\n", + "\n", + "### **Paths to the training data and model**\n", + "\n", + "* **`training_source`** specifies the paths to the training data. They must be a single multipage TIF file each\n", + "\n", + "* **`model_path`** specifies the directory where the model checkpoints will be saved.\n", + "\n", + "**Tip:** To easily copy paths, navigate to the 'Files' tab, right-click on a folder or file, and choose 'Copy path'.\n", + "\n", + "### **Training parameters**\n", + "\n", + "* **`number_of_epochs`** is the number of times the entire training data will be seen by the model. Default: 50\n", + "\n", + "* **`batchs_size`** is the number of image that will be bundled together at each training step. Default: 4\n", + "\n", + "* **`learning_rate`** is the step size of the update of the model's weight. Try decreasing it if the NCuts loss is unstable. Default: 2e-5\n", + "\n", + "* **`num_classes`** is the number of brightness clusters to segment the image in. Try raising it to 3 if you have artifacts or \"halos\" around your cells that have significantly different brightness. Default: 2\n", + "\n", + "* **`weight_decay`** is a regularization parameter used to prevent overfitting. Default: 0.01\n", + "\n", + "* **`validation_frequency`** is the frequency at which the provided evaluation data is used to estimate the model's performance.\n", + "\n", + "* **`intensity_sigma`** is the standard deviation of the feature similarity term. Default: 1\n", + "\n", + "* **`spatial_sigma`** is the standard deviation of the spatial proximity term. Default: 4\n", + "\n", + "* **`ncuts_radius`** is the radius for the NCuts loss computation, in pixels. Default: 2\n", + "\n", + "* **`rec_loss`** is the loss to use for the decoder. Can be Mean Square Error (MSE) or Binary Cross Entropy (BCE). Default : MSE\n", + "\n", + "* **`n_cuts_weight`** is the weight of the NCuts loss in the weighted sum for the backward pass. Default: 0.5\n", + "* **`rec_loss_weight`** is the weight of the reconstruction loss. Default: 0.005\n" + ], + "metadata": { + "id": "65FhTkYlGKRt" + } + }, + { + "cell_type": "code", + "source": [ + "#@markdown ###Path to the training data:\n", + "training_source = \"./gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full\" #@param {type:\"string\"}\n", + "#@markdown ###Model name and path to model folder:\n", + "model_path = \"./gdrive/MyDrive/CELLSEG_BENCHMARK/WNET_TRAINING_RESULTS\" #@param {type:\"string\"}\n", + "#@markdown ---\n", + "#@markdown ###Perform validation on a test dataset\n", + "do_validation = False #@param {type:\"boolean\"}\n", + "#@markdown ###Path to evaluation data (optional, use if checked above):\n", + "eval_source = \"./gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/eval/vol/\" #@param {type:\"string\"}\n", + "eval_target = \"./gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/eval/lab/\" #@param {type:\"string\"}\n", + "#@markdown ---\n", + "#@markdown ###Training parameters\n", + "number_of_epochs = 50 #@param {type:\"number\"}\n", + "#@markdown ###Default advanced parameters\n", + "use_default_advanced_parameters = False #@param {type:\"boolean\"}\n", + "#@markdown If not, please change:\n", + "\n", + "#@markdown Training parameters:\n", + "batch_size = 4 #@param {type:\"number\"}\n", + "learning_rate = 2e-5 #@param {type:\"number\"}\n", + "num_classes = 2 #@param {type:\"number\"}\n", + "weight_decay = 0.01 #@param {type:\"number\"}\n", + "#@markdown Validation parameters:\n", + "validation_frequency = 2 #@param {type:\"number\"}\n", + "#@markdown SoftNCuts parameters:\n", + "intensity_sigma = 1.0 #@param {type:\"number\"}\n", + "spatial_sigma = 4.0 #@param {type:\"number\"}\n", + "ncuts_radius = 2 #@param {type:\"number\"}\n", + "#@markdown Reconstruction loss:\n", + "rec_loss = \"MSE\" #@param[\"MSE\", \"BCE\"]\n", + "#@markdown Weighted sum of losses:\n", + "n_cuts_weight = 0.5 #@param {type:\"number\"}\n", + "rec_loss_weight = 0.005 #@param {type:\"number\"}" + ], + "metadata": { + "cellView": "form", + "id": "tTSCC6ChGuuA" + }, + "execution_count": 7, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [], + "metadata": { + "id": "HtoIo5GcKIXX" + } + }, + { + "cell_type": "markdown", + "source": [ + "# **4. Train the network**\n", + "---\n", + "\n", + "Important Reminder: Google Colab imposes a maximum session time to prevent extended GPU usage, such as for data mining. Ensure your training duration stays under 12 hours. If your training is projected to exceed this limit, consider reducing the `number_of_epochs`." + ], + "metadata": { + "id": "arWhMU6aKsri" + } + }, + { + "cell_type": "markdown", + "source": [ + "## **4.1. Initialize the config**\n", + "---" + ], + "metadata": { + "id": "L59J90S_Kva3" + } + }, + { + "cell_type": "code", + "source": [ + "# @title\n", + "train_data_folder = Path(training_source)\n", + "results_path = Path(model_path)\n", + "results_path.mkdir(exist_ok=True)\n", + "eval_image_folder = Path(eval_source)\n", + "eval_label_folder = Path(eval_target)\n", + "\n", + "eval_dict = c.create_eval_dataset_dict(\n", + " eval_image_folder,\n", + " eval_label_folder,\n", + " ) if do_validation else None\n", + "\n", + "try:\n", + " import wandb\n", + " WANDB_INSTALLED = True\n", + "except ImportError:\n", + " WANDB_INSTALLED = False\n", + "\n", + "\n", + "train_config = WNetTrainingWorkerConfig(\n", + " device=\"cuda:0\",\n", + " max_epochs=number_of_epochs,\n", + " learning_rate=2e-5,\n", + " validation_interval=2,\n", + " batch_size=4,\n", + " num_workers=2,\n", + " weights_info=WeightsInfo(),\n", + " results_path_folder=str(results_path),\n", + " train_data_dict=c.create_dataset_dict_no_labs(train_data_folder),\n", + " eval_volume_dict=eval_dict,\n", + ") if use_default_advanced_parameters else WNetTrainingWorkerConfig(\n", + " device=\"cuda:0\",\n", + " max_epochs=number_of_epochs,\n", + " learning_rate=learning_rate,\n", + " validation_interval=validation_frequency,\n", + " batch_size=batch_size,\n", + " num_workers=2,\n", + " weights_info=WeightsInfo(),\n", + " results_path_folder=str(results_path),\n", + " train_data_dict=c.create_dataset_dict_no_labs(train_data_folder),\n", + " eval_volume_dict=eval_dict,\n", + " # advanced\n", + " num_classes=num_classes,\n", + " weight_decay=weight_decay,\n", + " intensity_sigma=intensity_sigma,\n", + " spatial_sigma=spatial_sigma,\n", + " radius=ncuts_radius,\n", + " reconstruction_loss=rec_loss,\n", + " n_cuts_weight=n_cuts_weight,\n", + " rec_loss_weight=rec_loss_weight,\n", + ")\n", + "wandb_config = WandBConfig(\n", + " mode=\"disabled\" if not WANDB_INSTALLED else \"online\",\n", + " save_model_artifact=False,\n", + ")" + ], + "metadata": { + "id": "YOgLyUwPjvUX" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "## **4.2. Start training**\n", + "---" + ], + "metadata": { + "id": "idowGpeQPIm2" + } + }, + { + "cell_type": "code", + "source": [ + "# @title\n", + "worker = c.get_colab_worker(worker_config=train_config, wandb_config=wandb_config)\n", + "for epoch_loss in worker.train():\n", + " continue" + ], + "metadata": { + "id": "OXxKZhGMqguz" + }, + "execution_count": null, + "outputs": [] + } + ] +} diff --git a/notebooks/colab_inference_demo.ipynb b/notebooks/colab_inference_demo.ipynb new file mode 100644 index 00000000..84748f36 --- /dev/null +++ b/notebooks/colab_inference_demo.ipynb @@ -0,0 +1,320 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "view-in-github" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# **CellSeg3D : inference demo notebook**\n", + "\n", + "---\n", + "This notebook is part of the [CellSeg3D project](https://github.com/AdaptiveMotorControlLab/CellSeg3d) in the [Mathis Lab of Adaptive Intelligence](https://www.mackenziemathislab.org/).\n", + "\n", + "- πŸ’œ The foundation of this notebook owes much to the **[ZeroCostDL4Mic](https://github.com/HenriquesLab/ZeroCostDL4Mic)** project and to the **[DeepLabCut](https://github.com/DeepLabCut/DeepLabCut)** team for bringing Colab into scientific open software." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# **1. Installing dependencies**\n", + "---" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## **1.1 Installing CellSeg3D**\n", + "---" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "#@markdown ##Install CellSeg3D and dependencies\n", + "!git clone https://github.com/AdaptiveMotorControlLab/CellSeg3d.git --branch main --single-branch ./CellSeg3D\n", + "!pip install -e CellSeg3D" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## **1.2. Restart your runtime**\n", + "---\n", + "\n", + "\n", + "\n", + "** Please ignore the subsequent error message. An automatic restart of your Runtime is expected and is part of the process.**\n", + "\n", + "\"\"
" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# @title Force session restart\n", + "exit(0)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## **1.3 Load key dependencies**\n", + "---" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# @title Load libraries\n", + "from pathlib import Path\n", + "from tifffile import imread\n", + "from napari_cellseg3d.dev_scripts import remote_inference as cs3d\n", + "from napari_cellseg3d.utils import LOGGER as logger\n", + "import logging\n", + "\n", + "logger.setLevel(logging.INFO)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# **2. Inference**\n", + "---" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "## **2.1. Check for GPU access**\n", + "---\n", + "\n", + "By default, this session is configured to use Python 3 and GPU acceleration. To verify or adjust these settings:\n", + "\n", + "Navigate to Runtime and select Change the Runtime type.\n", + "\n", + "For Runtime type, ensure it's set to Python 3 (the programming language this program is written in).\n", + "\n", + "Under Accelerator, choose GPU (Graphics Processing Unit).\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "#@markdown This cell verifies if GPU access is available.\n", + "\n", + "import torch\n", + "if not torch.cuda.is_available():\n", + " print('You do not have GPU access.')\n", + " print('Did you change your runtime?')\n", + " print('If the runtime setting is correct then Google did not allocate a GPU for your session')\n", + " print('Expect slow performance. To access GPU try reconnecting later')\n", + "\n", + "else:\n", + " print('You have GPU access')\n", + " !nvidia-smi\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## **2.2 Run inference**\n", + "---" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# @title Load demo image and inference configuration\n", + "#@markdown This cell loads a demo image and load the inference configuration.\n", + "demo_image_path = \"./CellSeg3D/examples/c5image.tif\n", + "demo_image = imread(demo_image_path)\n", + "inference_config = cs3d.CONFIG\n", + "post_process_config = cs3d.PostProcessConfig()\n", + "# select cle device for colab\n", + "import pyclesperanto_prototype as cle\n", + "cle.select_device(\"cupy\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# @title Run inference on demo image\n", + "#@markdown This cell runs the inference on the demo image.\n", + "result = cs3d.inference_on_images(\n", + " demo_image,\n", + " config=inference_config,\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# @title Post-process the result\n", + "# @markdown This cell post-processes the result of the inference : thresholding, instance segmentation, and statistics.\n", + "instance_segmentation,stats = cs3d.post_processing(\n", + " result[0].semantic_segmentation,\n", + " config=post_process_config,\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# @title Display the result\n", + "#@markdown This cell displays the result of the inference and post-processing. Use the slider to navigate through the z-stack.\n", + "# @markdown *KNOWN ISSUE* : The colormap of the labels is not consistent between the z-stacks. \n", + "import matplotlib.pyplot as plt\n", + "import ipywidgets as widgets\n", + "from IPython.display import display\n", + "import matplotlib\n", + "import colorsys\n", + "import numpy as np\n", + "\n", + "def random_label_cmap(n=2**16, h = (0,1), l = (.4,1), s =(.2,.8)):\n", + " \"\"\"FUNCTION TAKEN FROM STARDIST REPO : https://github.com/stardist/stardist/blob/c6c261081c6f9717fa9f5c47720ad2d5a9153224/stardist/plot/plot.py#L8\"\"\"\n", + " h,l,s = np.random.uniform(*h,n), np.random.uniform(*l,n), np.random.uniform(*s,n)\n", + " cols = np.stack([colorsys.hls_to_rgb(_h,_l,_s) for _h,_l,_s in zip(h,l,s)],axis=0)\n", + " cols[0] = 0\n", + " # reset the random generator to the first draw to keep the colormap consistent\n", + "\n", + " return matplotlib.colors.ListedColormap(cols)\n", + "\n", + "label_cmap = random_label_cmap(n=instance_segmentation.max()+1)\n", + "\n", + "def update_plot(z):\n", + " plt.figure(figsize=(15, 15))\n", + " plt.subplot(1, 3, 1)\n", + " plt.imshow(demo_image[z], cmap='gray')\n", + " plt.subplot(1, 3, 2)\n", + " plt.imshow(result[0].semantic_segmentation[z], cmap='turbo')\n", + " plt.subplot(1, 3, 3)\n", + " plt.imshow(instance_segmentation[z], cmap=label_cmap)\n", + " plt.show()\n", + "\n", + "# Create a slider\n", + "z_slider = widgets.IntSlider(min=0, max=demo_image.shape[0]-1, step=1, value=demo_image.shape[0] // 2)\n", + "\n", + "# Display the slider and update the plot when the slider is changed\n", + "widgets.interact(update_plot, z=z_slider)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# @title Display the statistics\n", + "# @markdown This cell displays the statistics of the post-processed result.\n", + "import pandas as pd\n", + "data = pd.DataFrame(stats.get_dict())\n", + "display(data)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# @title Plot the a 3D view, with statistics\n", + "# @markdown This cell plots a 3D view of the cells, with the volume as the size of the points and the sphericity as the color.\n", + "import plotly.graph_objects as go\n", + "import numpy as np\n", + "\n", + "def plotly_cells_stats(data):\n", + "\n", + " x = data[\"Centroid x\"]\n", + " y = data[\"Centroid y\"]\n", + " z = data[\"Centroid z\"]\n", + "\n", + " fig = go.Figure(\n", + " data=go.Scatter3d(\n", + " x=np.floor(x),\n", + " y=np.floor(y),\n", + " z=np.floor(z),\n", + " mode=\"markers\",\n", + " marker=dict(\n", + " sizemode=\"diameter\",\n", + " sizeref=30,\n", + " sizemin=20,\n", + " size=data[\"Volume\"],\n", + " color=data[\"Sphericity (axes)\"],\n", + " colorscale=\"Turbo_r\",\n", + " colorbar_title=\"Sphericity\",\n", + " line_color=\"rgb(140, 140, 170)\",\n", + " ),\n", + " )\n", + " )\n", + "\n", + " fig.update_layout(\n", + " height=600,\n", + " width=600,\n", + " title=f'Total number of cells : {int(data[\"Number objects\"][0])}',\n", + " )\n", + "\n", + " fig.show(renderer=\"colab\")\n", + " \n", + "plotly_cells_stats(data)" + ] + } + ], + "metadata": { + "accelerator": "GPU", + "colab": { + "gpuType": "T4", + "include_colab_link": true, + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/notebooks/colab_wnet_training.ipynb b/notebooks/colab_wnet_training.ipynb deleted file mode 100644 index 5b984673..00000000 --- a/notebooks/colab_wnet_training.ipynb +++ /dev/null @@ -1,1300 +0,0 @@ -{ - "nbformat": 4, - "nbformat_minor": 0, - "metadata": { - "colab": { - "provenance": [], - "gpuType": "T4" - }, - "kernelspec": { - "name": "python3", - "display_name": "Python 3" - }, - "language_info": { - "name": "python" - }, - "accelerator": "GPU" - }, - "cells": [ - { - "cell_type": "markdown", - "source": [ - "# **WNet: 3D Unsupervised Cell Segmentation**\n", - "\n", - "---\n", - "*Disclaimer:*\n", - "\n", - "This notebook, part of the [CellSeg3D project](https://github.com/AdaptiveMotorControlLab/CellSeg3d) under the [Mathis Lab of Adaptive Motor Control](https://www.mackenziemathislab.org/), is a work-in-progress resource for training the WNet model for unsupervised cell segmentation.\n", - "\n", - "The foundation of this notebook owes much to the **[ZeroCostDL4Mic](https://github.com/HenriquesLab/ZeroCostDL4Mic)** project β€”a collaborative effort between the Jacquemet and Henriques laboratories, and created by Daniel Krentzel. Except for the model provided herein, all credits are duly given to their team." - ], - "metadata": { - "id": "BTUVNXX7R3Go" - } - }, - { - "cell_type": "markdown", - "source": [ - "#**1. Installing dependencies**\n", - "---" - ], - "metadata": { - "id": "zmVCksV0EfVT" - } - }, - { - "cell_type": "markdown", - "source": [ - "##**1.1 Installing CellSeg3D**\n", - "---" - ], - "metadata": { - "id": "kCNRISzSEnIh" - } - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "id": "td_vf_pneSak", - "colab": { - "base_uri": "https://localhost:8080/" - }, - "outputId": "df656d73-015c-473b-f63a-dd71ed17085e" - }, - "outputs": [ - { - "output_type": "stream", - "name": "stdout", - "text": [ - "fatal: destination path './CellSeg3D' already exists and is not an empty directory.\n", - "Obtaining file:///content/CellSeg3D\n", - " Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n", - " Checking if build backend supports build_editable ... \u001b[?25l\u001b[?25hdone\n", - " Getting requirements to build editable ... \u001b[?25l\u001b[?25hdone\n", - " Preparing editable metadata (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n", - "Requirement already satisfied: numpy in /usr/local/lib/python3.10/dist-packages (from napari-cellseg3d==0.0.3rc1) (1.22.4)\n", - "Requirement already satisfied: napari[all]>=0.4.14 in /usr/local/lib/python3.10/dist-packages (from napari-cellseg3d==0.0.3rc1) (0.4.18)\n", - "Requirement already satisfied: QtPy in /usr/local/lib/python3.10/dist-packages (from napari-cellseg3d==0.0.3rc1) (2.3.1)\n", - "Requirement already satisfied: opencv-python>=4.5.5 in /usr/local/lib/python3.10/dist-packages (from napari-cellseg3d==0.0.3rc1) (4.7.0.72)\n", - "Requirement already satisfied: scikit-image>=0.19.2 in /usr/local/lib/python3.10/dist-packages (from napari-cellseg3d==0.0.3rc1) (0.19.3)\n", - "Requirement already satisfied: matplotlib>=3.4.1 in /usr/local/lib/python3.10/dist-packages (from napari-cellseg3d==0.0.3rc1) (3.7.1)\n", - "Requirement already satisfied: tifffile>=2022.2.9 in /usr/local/lib/python3.10/dist-packages (from napari-cellseg3d==0.0.3rc1) (2023.7.18)\n", - "Requirement already satisfied: imageio-ffmpeg>=0.4.5 in /usr/local/lib/python3.10/dist-packages (from napari-cellseg3d==0.0.3rc1) (0.4.8)\n", - "Requirement already satisfied: imagecodecs>=2023.3.16 in /usr/local/lib/python3.10/dist-packages (from napari-cellseg3d==0.0.3rc1) (2023.7.10)\n", - "Requirement already satisfied: torch>=1.11 in /usr/local/lib/python3.10/dist-packages (from napari-cellseg3d==0.0.3rc1) (2.0.1+cu118)\n", - "Requirement already satisfied: monai[einops,nibabel]>=0.9.0 in /usr/local/lib/python3.10/dist-packages (from napari-cellseg3d==0.0.3rc1) (1.2.0)\n", - "Requirement already satisfied: itk in /usr/local/lib/python3.10/dist-packages (from napari-cellseg3d==0.0.3rc1) (5.3.0)\n", - "Requirement already satisfied: tqdm in /usr/local/lib/python3.10/dist-packages (from napari-cellseg3d==0.0.3rc1) (4.65.0)\n", - "Requirement already satisfied: nibabel in /usr/local/lib/python3.10/dist-packages (from napari-cellseg3d==0.0.3rc1) (4.0.2)\n", - "Requirement already satisfied: pillow in /usr/local/lib/python3.10/dist-packages (from napari-cellseg3d==0.0.3rc1) (9.4.0)\n", - "Requirement already satisfied: pyclesperanto-prototype in /usr/local/lib/python3.10/dist-packages (from napari-cellseg3d==0.0.3rc1) (0.24.1)\n", - "Requirement already satisfied: vispy>=0.9.6 in /usr/local/lib/python3.10/dist-packages (from napari-cellseg3d==0.0.3rc1) (0.12.2)\n", - "Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=3.4.1->napari-cellseg3d==0.0.3rc1) (1.1.0)\n", - "Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=3.4.1->napari-cellseg3d==0.0.3rc1) (0.11.0)\n", - "Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=3.4.1->napari-cellseg3d==0.0.3rc1) (4.41.1)\n", - "Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=3.4.1->napari-cellseg3d==0.0.3rc1) (1.4.4)\n", - "Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=3.4.1->napari-cellseg3d==0.0.3rc1) (23.1)\n", - "Requirement already satisfied: pyparsing>=2.3.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=3.4.1->napari-cellseg3d==0.0.3rc1) (3.1.0)\n", - "Requirement already satisfied: python-dateutil>=2.7 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=3.4.1->napari-cellseg3d==0.0.3rc1) (2.8.2)\n", - "Requirement already satisfied: einops in /usr/local/lib/python3.10/dist-packages (from monai[einops,nibabel]>=0.9.0->napari-cellseg3d==0.0.3rc1) (0.6.1)\n", - "Requirement already satisfied: appdirs>=1.4.4 in /usr/local/lib/python3.10/dist-packages (from napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (1.4.4)\n", - "Requirement already satisfied: app-model<0.3.0,>=0.1.0 in /usr/local/lib/python3.10/dist-packages (from napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (0.2.0)\n", - "Requirement already satisfied: cachey>=0.2.1 in /usr/local/lib/python3.10/dist-packages (from napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (0.2.1)\n", - "Requirement already satisfied: certifi>=2018.1.18 in /usr/local/lib/python3.10/dist-packages (from napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (2023.7.22)\n", - "Requirement already satisfied: dask[array]!=2.28.0,>=2.15.0 in /usr/local/lib/python3.10/dist-packages (from napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (2022.12.1)\n", - "Requirement already satisfied: imageio!=2.22.1,>=2.20 in /usr/local/lib/python3.10/dist-packages (from napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (2.25.1)\n", - "Requirement already satisfied: jsonschema>=3.2.0 in /usr/local/lib/python3.10/dist-packages (from napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (4.3.3)\n", - "Requirement already satisfied: lazy-loader>=0.2 in /usr/local/lib/python3.10/dist-packages (from napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (0.3)\n", - "Requirement already satisfied: magicgui>=0.3.6 in /usr/local/lib/python3.10/dist-packages (from napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (0.7.2)\n", - "Requirement already satisfied: napari-console>=0.0.6 in /usr/local/lib/python3.10/dist-packages (from napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (0.0.8)\n", - "Requirement already satisfied: napari-plugin-engine>=0.1.9 in /usr/local/lib/python3.10/dist-packages (from napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (0.2.0)\n", - "Requirement already satisfied: napari-svg>=0.1.7 in /usr/local/lib/python3.10/dist-packages (from napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (0.1.10)\n", - "Requirement already satisfied: npe2>=0.5.2 in /usr/local/lib/python3.10/dist-packages (from napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (0.7.2)\n", - "Requirement already satisfied: numpydoc>=0.9.2 in /usr/local/lib/python3.10/dist-packages (from napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (1.5.0)\n", - "Requirement already satisfied: pint>=0.17 in /usr/local/lib/python3.10/dist-packages (from napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (0.22)\n", - "Requirement already satisfied: psutil>=5.0 in /usr/local/lib/python3.10/dist-packages (from napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (5.9.5)\n", - "Requirement already satisfied: psygnal>=0.3.4 in /usr/local/lib/python3.10/dist-packages (from napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (0.9.1)\n", - "Requirement already satisfied: pydantic<2,>=1.9.0 in /usr/local/lib/python3.10/dist-packages (from napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (1.10.12)\n", - "Requirement already satisfied: pygments>=2.6.0 in /usr/local/lib/python3.10/dist-packages (from napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (2.14.0)\n", - "Requirement already satisfied: PyOpenGL>=3.1.0 in /usr/local/lib/python3.10/dist-packages (from napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (3.1.7)\n", - "Requirement already satisfied: PyYAML>=5.1 in /usr/local/lib/python3.10/dist-packages (from napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (6.0.1)\n", - "Requirement already satisfied: sphinx<5,>=4.3.0 in /usr/local/lib/python3.10/dist-packages (from napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (4.5.0)\n", - "Requirement already satisfied: superqt>=0.4.1 in /usr/local/lib/python3.10/dist-packages (from napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (0.4.1)\n", - "Requirement already satisfied: toolz>=0.10.0 in /usr/local/lib/python3.10/dist-packages (from napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (0.12.0)\n", - "Requirement already satisfied: typing-extensions>=4.2.0 in /usr/local/lib/python3.10/dist-packages (from napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (4.7.1)\n", - "Requirement already satisfied: wrapt>=1.11.1 in /usr/local/lib/python3.10/dist-packages (from napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (1.14.1)\n", - "Requirement already satisfied: pandas>=1.3.0 in /usr/local/lib/python3.10/dist-packages (from napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (1.5.3)\n", - "Requirement already satisfied: scipy>=1.5.4 in /usr/local/lib/python3.10/dist-packages (from napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (1.10.1)\n", - "Requirement already satisfied: PyQt5!=5.15.0,>=5.12.3 in /usr/local/lib/python3.10/dist-packages (from napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (5.15.9)\n", - "Requirement already satisfied: napari-plugin-manager<0.2.0,>=0.1.0a1 in /usr/local/lib/python3.10/dist-packages (from napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (0.1.0a2)\n", - "Requirement already satisfied: networkx>=2.2 in /usr/local/lib/python3.10/dist-packages (from scikit-image>=0.19.2->napari-cellseg3d==0.0.3rc1) (3.1)\n", - "Requirement already satisfied: PyWavelets>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from scikit-image>=0.19.2->napari-cellseg3d==0.0.3rc1) (1.4.1)\n", - "Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from torch>=1.11->napari-cellseg3d==0.0.3rc1) (3.12.2)\n", - "Requirement already satisfied: sympy in /usr/local/lib/python3.10/dist-packages (from torch>=1.11->napari-cellseg3d==0.0.3rc1) (1.11.1)\n", - "Requirement already satisfied: jinja2 in /usr/local/lib/python3.10/dist-packages (from torch>=1.11->napari-cellseg3d==0.0.3rc1) (3.1.2)\n", - "Requirement already satisfied: triton==2.0.0 in /usr/local/lib/python3.10/dist-packages (from torch>=1.11->napari-cellseg3d==0.0.3rc1) (2.0.0)\n", - "Requirement already satisfied: cmake in /usr/local/lib/python3.10/dist-packages (from triton==2.0.0->torch>=1.11->napari-cellseg3d==0.0.3rc1) (3.25.2)\n", - "Requirement already satisfied: lit in /usr/local/lib/python3.10/dist-packages (from triton==2.0.0->torch>=1.11->napari-cellseg3d==0.0.3rc1) (16.0.6)\n", - "Requirement already satisfied: freetype-py in /usr/local/lib/python3.10/dist-packages (from vispy>=0.9.6->napari-cellseg3d==0.0.3rc1) (2.4.0)\n", - "Requirement already satisfied: hsluv in /usr/local/lib/python3.10/dist-packages (from vispy>=0.9.6->napari-cellseg3d==0.0.3rc1) (5.0.3)\n", - "Requirement already satisfied: itk-core==5.3.0 in /usr/local/lib/python3.10/dist-packages (from itk->napari-cellseg3d==0.0.3rc1) (5.3.0)\n", - "Requirement already satisfied: itk-numerics==5.3.0 in /usr/local/lib/python3.10/dist-packages (from itk->napari-cellseg3d==0.0.3rc1) (5.3.0)\n", - "Requirement already satisfied: itk-io==5.3.0 in /usr/local/lib/python3.10/dist-packages (from itk->napari-cellseg3d==0.0.3rc1) (5.3.0)\n", - "Requirement already satisfied: itk-filtering==5.3.0 in /usr/local/lib/python3.10/dist-packages (from itk->napari-cellseg3d==0.0.3rc1) (5.3.0)\n", - "Requirement already satisfied: itk-registration==5.3.0 in /usr/local/lib/python3.10/dist-packages (from itk->napari-cellseg3d==0.0.3rc1) (5.3.0)\n", - "Requirement already satisfied: itk-segmentation==5.3.0 in /usr/local/lib/python3.10/dist-packages (from itk->napari-cellseg3d==0.0.3rc1) (5.3.0)\n", - "Requirement already satisfied: setuptools in /usr/local/lib/python3.10/dist-packages (from nibabel->napari-cellseg3d==0.0.3rc1) (67.7.2)\n", - "Requirement already satisfied: pyopencl in /usr/local/lib/python3.10/dist-packages (from pyclesperanto-prototype->napari-cellseg3d==0.0.3rc1) (2023.1.1)\n", - "Requirement already satisfied: transforms3d in /usr/local/lib/python3.10/dist-packages (from pyclesperanto-prototype->napari-cellseg3d==0.0.3rc1) (0.4.1)\n", - "Requirement already satisfied: in-n-out>=0.1.5 in /usr/local/lib/python3.10/dist-packages (from app-model<0.3.0,>=0.1.0->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (0.1.8)\n", - "Requirement already satisfied: heapdict in /usr/local/lib/python3.10/dist-packages (from cachey>=0.2.1->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (1.0.1)\n", - "Requirement already satisfied: click>=7.0 in /usr/local/lib/python3.10/dist-packages (from dask[array]!=2.28.0,>=2.15.0->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (8.1.6)\n", - "Requirement already satisfied: cloudpickle>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from dask[array]!=2.28.0,>=2.15.0->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (2.2.1)\n", - "Requirement already satisfied: fsspec>=0.6.0 in /usr/local/lib/python3.10/dist-packages (from dask[array]!=2.28.0,>=2.15.0->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (2023.6.0)\n", - "Requirement already satisfied: partd>=0.3.10 in /usr/local/lib/python3.10/dist-packages (from dask[array]!=2.28.0,>=2.15.0->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (1.4.0)\n", - "Requirement already satisfied: attrs>=17.4.0 in /usr/local/lib/python3.10/dist-packages (from jsonschema>=3.2.0->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (23.1.0)\n", - "Requirement already satisfied: pyrsistent!=0.17.0,!=0.17.1,!=0.17.2,>=0.14.0 in /usr/local/lib/python3.10/dist-packages (from jsonschema>=3.2.0->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (0.19.3)\n", - "Requirement already satisfied: docstring-parser>=0.7 in /usr/local/lib/python3.10/dist-packages (from magicgui>=0.3.6->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (0.15)\n", - "Requirement already satisfied: ipykernel>=5.2.0 in /usr/local/lib/python3.10/dist-packages (from napari-console>=0.0.6->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (5.5.6)\n", - "Requirement already satisfied: IPython>=7.7.0 in /usr/local/lib/python3.10/dist-packages (from napari-console>=0.0.6->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (7.34.0)\n", - "Requirement already satisfied: qtconsole!=4.7.6,!=5.4.2,>=4.5.1 in /usr/local/lib/python3.10/dist-packages (from napari-console>=0.0.6->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (5.4.3)\n", - "Requirement already satisfied: pip in /usr/local/lib/python3.10/dist-packages (from napari-plugin-manager<0.2.0,>=0.1.0a1->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (23.1.2)\n", - "Requirement already satisfied: build in /usr/local/lib/python3.10/dist-packages (from npe2>=0.5.2->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (0.10.0)\n", - "Requirement already satisfied: rich in /usr/local/lib/python3.10/dist-packages (from npe2>=0.5.2->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (13.4.2)\n", - "Requirement already satisfied: tomli-w in /usr/local/lib/python3.10/dist-packages (from npe2>=0.5.2->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (1.0.0)\n", - "Requirement already satisfied: tomli in /usr/local/lib/python3.10/dist-packages (from npe2>=0.5.2->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (2.0.1)\n", - "Requirement already satisfied: typer in /usr/local/lib/python3.10/dist-packages (from npe2>=0.5.2->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (0.9.0)\n", - "Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/dist-packages (from jinja2->torch>=1.11->napari-cellseg3d==0.0.3rc1) (2.1.3)\n", - "Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas>=1.3.0->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (2022.7.1)\n", - "Requirement already satisfied: mypy-extensions in /usr/local/lib/python3.10/dist-packages (from psygnal>=0.3.4->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (1.0.0)\n", - "Requirement already satisfied: PyQt5-sip<13,>=12.11 in /usr/local/lib/python3.10/dist-packages (from PyQt5!=5.15.0,>=5.12.3->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (12.12.2)\n", - "Requirement already satisfied: PyQt5-Qt5>=5.15.2 in /usr/local/lib/python3.10/dist-packages (from PyQt5!=5.15.0,>=5.12.3->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (5.15.2)\n", - "Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-packages (from python-dateutil>=2.7->matplotlib>=3.4.1->napari-cellseg3d==0.0.3rc1) (1.16.0)\n", - "Requirement already satisfied: pooch>=1.3.0 in /usr/local/lib/python3.10/dist-packages (from scikit-image>=0.19.2->napari-cellseg3d==0.0.3rc1) (1.6.0)\n", - "Requirement already satisfied: sphinxcontrib-applehelp in /usr/local/lib/python3.10/dist-packages (from sphinx<5,>=4.3.0->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (1.0.4)\n", - "Requirement already satisfied: sphinxcontrib-devhelp in /usr/local/lib/python3.10/dist-packages (from sphinx<5,>=4.3.0->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (1.0.2)\n", - "Requirement already satisfied: sphinxcontrib-jsmath in /usr/local/lib/python3.10/dist-packages (from sphinx<5,>=4.3.0->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (1.0.1)\n", - "Requirement already satisfied: sphinxcontrib-htmlhelp>=2.0.0 in /usr/local/lib/python3.10/dist-packages (from sphinx<5,>=4.3.0->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (2.0.1)\n", - "Requirement already satisfied: sphinxcontrib-serializinghtml>=1.1.5 in /usr/local/lib/python3.10/dist-packages (from sphinx<5,>=4.3.0->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (1.1.5)\n", - "Requirement already satisfied: sphinxcontrib-qthelp in /usr/local/lib/python3.10/dist-packages (from sphinx<5,>=4.3.0->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (1.0.3)\n", - "Requirement already satisfied: docutils<0.18,>=0.14 in /usr/local/lib/python3.10/dist-packages (from sphinx<5,>=4.3.0->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (0.17.1)\n", - "Requirement already satisfied: snowballstemmer>=1.1 in /usr/local/lib/python3.10/dist-packages (from sphinx<5,>=4.3.0->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (2.2.0)\n", - "Requirement already satisfied: babel>=1.3 in /usr/local/lib/python3.10/dist-packages (from sphinx<5,>=4.3.0->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (2.12.1)\n", - "Requirement already satisfied: alabaster<0.8,>=0.7 in /usr/local/lib/python3.10/dist-packages (from sphinx<5,>=4.3.0->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (0.7.13)\n", - "Requirement already satisfied: imagesize in /usr/local/lib/python3.10/dist-packages (from sphinx<5,>=4.3.0->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (1.4.1)\n", - "Requirement already satisfied: requests>=2.5.0 in /usr/local/lib/python3.10/dist-packages (from sphinx<5,>=4.3.0->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (2.27.1)\n", - "Requirement already satisfied: pytools>=2021.2.7 in /usr/local/lib/python3.10/dist-packages (from pyopencl->pyclesperanto-prototype->napari-cellseg3d==0.0.3rc1) (2023.1.1)\n", - "Requirement already satisfied: platformdirs>=2.2.0 in /usr/local/lib/python3.10/dist-packages (from pyopencl->pyclesperanto-prototype->napari-cellseg3d==0.0.3rc1) (3.9.1)\n", - "Requirement already satisfied: mpmath>=0.19 in /usr/local/lib/python3.10/dist-packages (from sympy->torch>=1.11->napari-cellseg3d==0.0.3rc1) (1.3.0)\n", - "Requirement already satisfied: ipython-genutils in /usr/local/lib/python3.10/dist-packages (from ipykernel>=5.2.0->napari-console>=0.0.6->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (0.2.0)\n", - "Requirement already satisfied: traitlets>=4.1.0 in /usr/local/lib/python3.10/dist-packages (from ipykernel>=5.2.0->napari-console>=0.0.6->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (5.7.1)\n", - "Requirement already satisfied: jupyter-client in /usr/local/lib/python3.10/dist-packages (from ipykernel>=5.2.0->napari-console>=0.0.6->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (6.1.12)\n", - "Requirement already satisfied: tornado>=4.2 in /usr/local/lib/python3.10/dist-packages (from ipykernel>=5.2.0->napari-console>=0.0.6->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (6.3.1)\n", - "Requirement already satisfied: jedi>=0.16 in /usr/local/lib/python3.10/dist-packages (from IPython>=7.7.0->napari-console>=0.0.6->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (0.19.0)\n", - "Requirement already satisfied: decorator in /usr/local/lib/python3.10/dist-packages (from IPython>=7.7.0->napari-console>=0.0.6->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (4.4.2)\n", - "Requirement already satisfied: pickleshare in /usr/local/lib/python3.10/dist-packages (from IPython>=7.7.0->napari-console>=0.0.6->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (0.7.5)\n", - "Requirement already satisfied: prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0 in /usr/local/lib/python3.10/dist-packages (from IPython>=7.7.0->napari-console>=0.0.6->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (3.0.39)\n", - "Requirement already satisfied: backcall in /usr/local/lib/python3.10/dist-packages (from IPython>=7.7.0->napari-console>=0.0.6->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (0.2.0)\n", - "Requirement already satisfied: matplotlib-inline in /usr/local/lib/python3.10/dist-packages (from IPython>=7.7.0->napari-console>=0.0.6->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (0.1.6)\n", - "Requirement already satisfied: pexpect>4.3 in /usr/local/lib/python3.10/dist-packages (from IPython>=7.7.0->napari-console>=0.0.6->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (4.8.0)\n", - "Requirement already satisfied: locket in /usr/local/lib/python3.10/dist-packages (from partd>=0.3.10->dask[array]!=2.28.0,>=2.15.0->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (1.0.0)\n", - "Requirement already satisfied: jupyter-core in /usr/local/lib/python3.10/dist-packages (from qtconsole!=4.7.6,!=5.4.2,>=4.5.1->napari-console>=0.0.6->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (5.3.1)\n", - "Requirement already satisfied: pyzmq>=17.1 in /usr/local/lib/python3.10/dist-packages (from qtconsole!=4.7.6,!=5.4.2,>=4.5.1->napari-console>=0.0.6->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (23.2.1)\n", - "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests>=2.5.0->sphinx<5,>=4.3.0->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (1.26.16)\n", - "Requirement already satisfied: charset-normalizer~=2.0.0 in /usr/local/lib/python3.10/dist-packages (from requests>=2.5.0->sphinx<5,>=4.3.0->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (2.0.12)\n", - "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests>=2.5.0->sphinx<5,>=4.3.0->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (3.4)\n", - "Requirement already satisfied: pyproject_hooks in /usr/local/lib/python3.10/dist-packages (from build->npe2>=0.5.2->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (1.0.0)\n", - "Requirement already satisfied: markdown-it-py>=2.2.0 in /usr/local/lib/python3.10/dist-packages (from rich->npe2>=0.5.2->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (3.0.0)\n", - "Requirement already satisfied: parso<0.9.0,>=0.8.3 in /usr/local/lib/python3.10/dist-packages (from jedi>=0.16->IPython>=7.7.0->napari-console>=0.0.6->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (0.8.3)\n", - "Requirement already satisfied: mdurl~=0.1 in /usr/local/lib/python3.10/dist-packages (from markdown-it-py>=2.2.0->rich->npe2>=0.5.2->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (0.1.2)\n", - "Requirement already satisfied: ptyprocess>=0.5 in /usr/local/lib/python3.10/dist-packages (from pexpect>4.3->IPython>=7.7.0->napari-console>=0.0.6->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (0.7.0)\n", - "Requirement already satisfied: wcwidth in /usr/local/lib/python3.10/dist-packages (from prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0->IPython>=7.7.0->napari-console>=0.0.6->napari[all]>=0.4.14->napari-cellseg3d==0.0.3rc1) (0.2.6)\n", - "Building wheels for collected packages: napari-cellseg3d\n", - " Building editable for napari-cellseg3d (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n", - " Created wheel for napari-cellseg3d: filename=napari_cellseg3d-0.0.3rc1-0.editable-py3-none-any.whl size=6209 sha256=307ee3cf2e41bdc6b51500507122f9cdac4161970a01fe63986c0743dbc738f7\n", - " Stored in directory: /tmp/pip-ephem-wheel-cache-l3d04gq9/wheels/a1/e1/dc/cc9f89fc6f907d6bd38a2cbf3335706054a5435e97f664034d\n", - "Successfully built napari-cellseg3d\n", - "Installing collected packages: napari-cellseg3d\n", - " Attempting uninstall: napari-cellseg3d\n", - " Found existing installation: napari-cellseg3d 0.0.3rc1\n", - " Uninstalling napari-cellseg3d-0.0.3rc1:\n", - " Successfully uninstalled napari-cellseg3d-0.0.3rc1\n", - "Successfully installed napari-cellseg3d-0.0.3rc1\n" - ] - } - ], - "source": [ - "#@markdown ##Play to install WNet dependencies\n", - "!git clone https://github.com/AdaptiveMotorControlLab/CellSeg3d.git --branch cy/wnet-extras --single-branch ./CellSeg3D\n", - "!pip install -e CellSeg3D" - ] - }, - { - "cell_type": "markdown", - "source": [ - "## **1.2. Restart your runtime**\n", - "---\n", - "\n", - "\n", - "\n", - "** Please ignore the subsequent error message. An automatic restart of your Runtime is expected and is part of the process.**\n", - "\n", - "\"\"
" - ], - "metadata": { - "id": "JilkN37yEUrs" - } - }, - { - "cell_type": "code", - "source": [ - "# @title\n", - "#Force session restart\n", - "exit(0)" - ], - "metadata": { - "cellView": "form", - "id": "2i3XU68IEG-K" - }, - "execution_count": 2, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "##**1.3 Load key dependencies**\n", - "---" - ], - "metadata": { - "id": "nqctRognFGDT" - } - }, - { - "cell_type": "code", - "source": [ - "# @title\n", - "from pathlib import Path\n", - "from napari_cellseg3d.dev_scripts import colab_training as c\n", - "from napari_cellseg3d.config import WNetTrainingWorkerConfig, WandBConfig, WeightsInfo, PRETRAINED_WEIGHTS_DIR" - ], - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "wOOhJjkxjXz-", - "outputId": "d0cf25c9-4255-4a35-e35c-31578231a92d" - }, - "execution_count": 4, - "outputs": [ - { - "output_type": "stream", - "name": "stderr", - "text": [ - "DEBUG:napari_cellseg3d.utils:PRETRAINED WEIGHT DIR LOCATION : /content/CellSeg3D/napari_cellseg3d/code_models/models/pretrained\n", - "DEBUG:napari_cellseg3d.utils:PRETRAINED WEIGHT DIR LOCATION : /content/CellSeg3D/napari_cellseg3d/code_models/models/pretrained\n" - ] - } - ] - }, - { - "cell_type": "markdown", - "source": [ - "##**1.4 Initialize Weights & Biases integration (optional)**\n", - "---" - ], - "metadata": { - "id": "Ax-vJAWRwIKi" - } - }, - { - "cell_type": "code", - "source": [ - "!pip install -q wandb\n", - "import wandb\n", - "wandb.login()" - ], - "metadata": { - "id": "QNgC3awjwb7G" - }, - "execution_count": null, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "# **2. Complete the Colab session**\n", - "---\n", - "If you wish to utilize Weights & Biases (WandB) for monitoring and logging your training session, execute the cell below.\n", - "To enable it, just input your API key in the space provided." - ], - "metadata": { - "id": "Zi9gRBHFFyX-" - } - }, - { - "cell_type": "markdown", - "source": [ - "\n", - "## **2.1. Check for GPU access**\n", - "---\n", - "\n", - "By default, this session is configured to use Python 3 and GPU acceleration. To verify or adjust these settings:\n", - "\n", - "Navigate to Runtime and select Change the Runtime type.\n", - "\n", - "For Runtime type, ensure it's set to Python 3 (the programming language this program is written in).\n", - "\n", - "Under Accelerator, choose GPU (Graphics Processing Unit).\n" - ], - "metadata": { - "id": "zSU-LYTfFnvF" - } - }, - { - "cell_type": "code", - "source": [ - "#@markdown ##Execute the cell below to verify if GPU access is available.\n", - "\n", - "import torch\n", - "if not torch.cuda.is_available():\n", - " print('You do not have GPU access.')\n", - " print('Did you change your runtime?')\n", - " print('If the runtime setting is correct then Google did not allocate a GPU for your session')\n", - " print('Expect slow performance. To access GPU try reconnecting later')\n", - "\n", - "else:\n", - " print('You have GPU access')\n", - " !nvidia-smi\n" - ], - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "cellView": "form", - "id": "Ie7bXiMgFtPH", - "outputId": "95bc0d9f-7be1-49ac-b1e1-93e1b1d0bed1" - }, - "execution_count": 1, - "outputs": [ - { - "output_type": "stream", - "name": "stdout", - "text": [ - "You have GPU access\n", - "Thu Aug 3 14:22:50 2023 \n", - "+-----------------------------------------------------------------------------+\n", - "| NVIDIA-SMI 525.105.17 Driver Version: 525.105.17 CUDA Version: 12.0 |\n", - "|-------------------------------+----------------------+----------------------+\n", - "| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |\n", - "| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |\n", - "| | | MIG M. |\n", - "|===============================+======================+======================|\n", - "| 0 Tesla T4 Off | 00000000:00:04.0 Off | 0 |\n", - "| N/A 57C P8 10W / 70W | 3MiB / 15360MiB | 0% Default |\n", - "| | | N/A |\n", - "+-------------------------------+----------------------+----------------------+\n", - " \n", - "+-----------------------------------------------------------------------------+\n", - "| Processes: |\n", - "| GPU GI CI PID Type Process name GPU Memory |\n", - "| ID ID Usage |\n", - "|=============================================================================|\n", - "| No running processes found |\n", - "+-----------------------------------------------------------------------------+\n" - ] - } - ] - }, - { - "cell_type": "markdown", - "source": [ - "## **2.2. Mount Google Drive**\n", - "---\n", - "To integrate this notebook with your personal data, save your data on Google Drive in accordance with the directory structures detailed in Section 0.\n", - "\n", - "1. **Run** the **cell** below and click on the provided link.\n", - "\n", - "2. Log in to your Google account and grant the necessary permissions by clicking 'Allow'.\n", - "\n", - "3. Copy the generated authorization code and paste it into the cell, then press 'Enter'. This grants Colab access to read and write data to your Google Drive.\n", - "\n", - "4. After completion, you can view your data in the notebook. Simply click the Files tab on the top left and select 'Refresh'." - ], - "metadata": { - "id": "X_bbk7RAF2yw" - } - }, - { - "cell_type": "code", - "source": [ - "#@markdown ##Play the cell to connect your Google Drive to Colab\n", - "\n", - "#@markdown * Click on the URL.\n", - "\n", - "#@markdown * Sign in your Google Account.\n", - "\n", - "#@markdown * Copy the authorization code.\n", - "\n", - "#@markdown * Enter the authorization code.\n", - "\n", - "#@markdown * Click on \"Files\" site on the right. Refresh the site. Your Google Drive folder should now be available here as \"drive\".\n", - "\n", - "# mount user's Google Drive to Google Colab.\n", - "from google.colab import drive\n", - "drive.mount('/content/gdrive')" - ], - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "AsIARCablq1V", - "outputId": "18638e0f-fd7b-41cf-c761-81e1c43ca8ab" - }, - "execution_count": 6, - "outputs": [ - { - "output_type": "stream", - "name": "stdout", - "text": [ - "Drive already mounted at /content/gdrive; to attempt to forcibly remount, call drive.mount(\"/content/gdrive\", force_remount=True).\n" - ] - } - ] - }, - { - "cell_type": "markdown", - "source": [ - "** If you cannot see your files, reactivate your session by connecting to your hosted runtime.**\n", - "\n", - "\n", - "\"Example
Connect to a hosted runtime.
" - ], - "metadata": { - "id": "r6FI22lkQLTv" - } - }, - { - "cell_type": "code", - "source": [ - "# @title\n", - "# import wandb\n", - "# wandb.login()" - ], - "metadata": { - "cellView": "form", - "id": "EtsK08ECwlnJ" - }, - "execution_count": 7, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [ - "# **3. Select your parameters and paths**\n", - "---" - ], - "metadata": { - "id": "IkOpxYjaGM0m" - } - }, - { - "cell_type": "markdown", - "source": [ - "## **3.1. Choosing parameters**\n", - "\n", - "---\n", - "\n", - "### **Paths to the training data and model**\n", - "\n", - "* **`training_source`** specifies the paths to the training data. They must be a single multipage TIF file each\n", - "\n", - "* **`model_path`** specifies the directory where the model checkpoints will be saved.\n", - "\n", - "**Tip:** To easily copy paths, navigate to the 'Files' tab, right-click on a folder or file, and choose 'Copy path'.\n", - "\n", - "### **Training parameters**\n", - "\n", - "* **`number_of_epochs`** is the number of times the entire training data will be seen by the model. Default: 50\n", - "\n", - "* **`batchs_size`** is the number of image that will be bundled together at each training step. Default: 4\n", - "\n", - "* **`learning_rate`** is the step size of the update of the model's weight. Try decreasing it if the NCuts loss is unstable. Default: 2e-5\n", - "\n", - "* **`num_classes`** is the number of brightness clusters to segment the image in. Try raising it to 3 if you have artifacts or \"halos\" around your cells that have significantly different brightness. Default: 2\n", - "\n", - "* **`weight_decay`** is a regularization parameter used to prevent overfitting. Default: 0.01\n", - "\n", - "* **`validation_frequency`** is the frequency at which the provided evaluation data is used to estimate the model's performance.\n", - "\n", - "* **`intensity_sigma`** is the standard deviation of the feature similarity term. Default: 1\n", - "\n", - "* **`spatial_sigma`** is the standard deviation of the spatial proximity term. Default: 4\n", - "\n", - "* **`ncuts_radius`** is the radius for the NCuts loss computation, in pixels. Default: 2\n", - "\n", - "* **`rec_loss`** is the loss to use for the decoder. Can be Mean Square Error (MSE) or Binary Cross Entropy (BCE). Default : MSE\n", - "\n", - "* **`n_cuts_weight`** is the weight of the NCuts loss in the weighted sum for the backward pass. Default: 0.5\n", - "* **`rec_loss_weight`** is the weight of the reconstruction loss. Default: 0.005\n" - ], - "metadata": { - "id": "65FhTkYlGKRt" - } - }, - { - "cell_type": "code", - "source": [ - "#@markdown ###Path to the training data:\n", - "training_source = \"./gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full\" #@param {type:\"string\"}\n", - "#@markdown ###Model name and path to model folder:\n", - "model_path = \"./gdrive/MyDrive/CELLSEG_BENCHMARK/WNET_TRAINING_RESULTS\" #@param {type:\"string\"}\n", - "#@markdown ---\n", - "#@markdown ###Perform validation on a test dataset\n", - "do_validation = True #@param {type:\"boolean\"}\n", - "#@markdown ###Path to evaluation data (optional, use if checked above):\n", - "eval_source = \"./gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/eval/vol/\" #@param {type:\"string\"}\n", - "eval_target = \"./gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/eval/lab/\" #@param {type:\"string\"}\n", - "#@markdown ---\n", - "#@markdown ###Training parameters\n", - "number_of_epochs = 50 #@param {type:\"number\"}\n", - "#@markdown ###Default advanced parameters\n", - "use_default_advanced_parameters = False #@param {type:\"boolean\"}\n", - "#@markdown If not, please change:\n", - "\n", - "#@markdown Training parameters:\n", - "batch_size = 4 #@param {type:\"number\"}\n", - "learning_rate = 2e-5 #@param {type:\"number\"}\n", - "num_classes = 2 #@param {type:\"number\"}\n", - "weight_decay = 0.01 #@param {type:\"number\"}\n", - "#@markdown Validation parameters:\n", - "validation_frequency = 2 #@param {type:\"number\"}\n", - "#@markdown SoftNCuts parameters:\n", - "intensity_sigma = 1.0 #@param {type:\"number\"}\n", - "spatial_sigma = 4.0 #@param {type:\"number\"}\n", - "ncuts_radius = 2 #@param {type:\"number\"}\n", - "#@markdown Reconstruction loss:\n", - "rec_loss = \"MSE\" #@param[\"MSE\", \"BCE\"]\n", - "#@markdown Weighted sum of losses:\n", - "n_cuts_weight = 0.5 #@param {type:\"number\"}\n", - "rec_loss_weight = 0.005 #@param {type:\"number\"}" - ], - "metadata": { - "cellView": "form", - "id": "tTSCC6ChGuuA" - }, - "execution_count": 5, - "outputs": [] - }, - { - "cell_type": "markdown", - "source": [], - "metadata": { - "id": "HtoIo5GcKIXX" - } - }, - { - "cell_type": "markdown", - "source": [ - "# **4. Train the network**\n", - "---\n", - "\n", - "Important Reminder: Google Colab imposes a maximum session time to prevent extended GPU usage, such as for data mining. Ensure your training duration stays under 12 hours. If your training is projected to exceed this limit, consider reducing the `number_of_epochs`." - ], - "metadata": { - "id": "arWhMU6aKsri" - } - }, - { - "cell_type": "markdown", - "source": [ - "## **4.1. Initialize the config**\n", - "---" - ], - "metadata": { - "id": "L59J90S_Kva3" - } - }, - { - "cell_type": "code", - "source": [ - "# @title\n", - "train_data_folder = Path(training_source)\n", - "results_path = Path(model_path)\n", - "results_path.mkdir(exist_ok=True)\n", - "eval_image_folder = Path(eval_source)\n", - "eval_label_folder = Path(eval_target)\n", - "\n", - "eval_dict = c.create_eval_dataset_dict(\n", - " eval_image_folder,\n", - " eval_label_folder,\n", - " ) if do_validation else None\n", - "\n", - "try:\n", - " import wandb\n", - " WANDB_INSTALLED = True\n", - "except ImportError:\n", - " WANDB_INSTALLED = False\n", - "\n", - "\n", - "train_config = WNetTrainingWorkerConfig(\n", - " device=\"cuda:0\",\n", - " max_epochs=number_of_epochs,\n", - " learning_rate=2e-5,\n", - " validation_interval=2,\n", - " batch_size=4,\n", - " num_workers=2,\n", - " weights_info=WeightsInfo(),\n", - " results_path_folder=str(results_path),\n", - " train_data_dict=c.create_dataset_dict_no_labs(train_data_folder),\n", - " eval_volume_dict=eval_dict,\n", - ") if use_default_advanced_parameters else WNetTrainingWorkerConfig(\n", - " device=\"cuda:0\",\n", - " max_epochs=number_of_epochs,\n", - " learning_rate=learning_rate,\n", - " validation_interval=validation_frequency,\n", - " batch_size=batch_size,\n", - " num_workers=2,\n", - " weights_info=WeightsInfo(),\n", - " results_path_folder=str(results_path),\n", - " train_data_dict=c.create_dataset_dict_no_labs(train_data_folder),\n", - " eval_volume_dict=eval_dict,\n", - " # advanced\n", - " num_classes=num_classes,\n", - " weight_decay=weight_decay,\n", - " intensity_sigma=intensity_sigma,\n", - " spatial_sigma=spatial_sigma,\n", - " radius=ncuts_radius,\n", - " reconstruction_loss=rec_loss,\n", - " n_cuts_weight=n_cuts_weight,\n", - " rec_loss_weight=rec_loss_weight,\n", - ")\n", - "wandb_config = WandBConfig(\n", - " mode=\"disabled\" if not WANDB_INSTALLED else \"online\",\n", - " save_model_artifact=False,\n", - ")" - ], - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "YOgLyUwPjvUX", - "outputId": "fe7bbf61-4f27-483e-ef3d-e93553c5d8ad" - }, - "execution_count": 7, - "outputs": [ - { - "output_type": "stream", - "name": "stderr", - "text": [ - "INFO:napari_cellseg3d.utils:Images :\n", - "\n", - "INFO:napari_cellseg3d.utils:c3_image_cropped_eval.tif\n", - "INFO:napari_cellseg3d.utils:**********\n", - "INFO:napari_cellseg3d.utils:Labels :\n", - "\n", - "INFO:napari_cellseg3d.utils:c3_labels_cropped_eval.tif\n", - "INFO:napari_cellseg3d.utils:Images :\n", - "INFO:napari_cellseg3d.utils:c1_images_cropped_10\n", - "INFO:napari_cellseg3d.utils:c1_images_cropped_11\n", - "INFO:napari_cellseg3d.utils:c1_images_cropped_12\n", - "INFO:napari_cellseg3d.utils:c1_images_cropped_13\n", - "INFO:napari_cellseg3d.utils:c1_images_cropped_14\n", - "INFO:napari_cellseg3d.utils:c1_images_cropped_15\n", - "INFO:napari_cellseg3d.utils:c1_images_cropped_16\n", - "INFO:napari_cellseg3d.utils:c1_images_cropped_17\n", - "INFO:napari_cellseg3d.utils:c1_images_cropped_18\n", - "INFO:napari_cellseg3d.utils:c1_images_cropped_19\n", - "INFO:napari_cellseg3d.utils:c1_images_cropped_20\n", - "INFO:napari_cellseg3d.utils:c1_images_cropped_21\n", - "INFO:napari_cellseg3d.utils:c1_images_cropped_22\n", - "INFO:napari_cellseg3d.utils:c1_images_cropped_23\n", - "INFO:napari_cellseg3d.utils:c1_images_cropped_3\n", - "INFO:napari_cellseg3d.utils:c1_images_cropped_4\n", - "INFO:napari_cellseg3d.utils:c1_images_cropped_5\n", - "INFO:napari_cellseg3d.utils:c1_images_cropped_6\n", - "INFO:napari_cellseg3d.utils:c1_images_cropped_7\n", - "INFO:napari_cellseg3d.utils:c1_images_cropped_8\n", - "INFO:napari_cellseg3d.utils:c1_images_cropped_9\n", - "INFO:napari_cellseg3d.utils:c2_images_cropped_0\n", - "INFO:napari_cellseg3d.utils:c2_images_cropped_1\n", - "INFO:napari_cellseg3d.utils:c2_images_cropped_10\n", - "INFO:napari_cellseg3d.utils:c2_images_cropped_11\n", - "INFO:napari_cellseg3d.utils:c2_images_cropped_12\n", - "INFO:napari_cellseg3d.utils:c2_images_cropped_13\n", - "INFO:napari_cellseg3d.utils:c2_images_cropped_14\n", - "INFO:napari_cellseg3d.utils:c2_images_cropped_15\n", - "INFO:napari_cellseg3d.utils:c2_images_cropped_16\n", - "INFO:napari_cellseg3d.utils:c2_images_cropped_17\n", - "INFO:napari_cellseg3d.utils:c2_images_cropped_18\n", - "INFO:napari_cellseg3d.utils:c2_images_cropped_19\n", - "INFO:napari_cellseg3d.utils:c2_images_cropped_2\n", - "INFO:napari_cellseg3d.utils:c2_images_cropped_3\n", - "INFO:napari_cellseg3d.utils:c2_images_cropped_4\n", - "INFO:napari_cellseg3d.utils:c2_images_cropped_5\n", - "INFO:napari_cellseg3d.utils:c2_images_cropped_6\n", - "INFO:napari_cellseg3d.utils:c2_images_cropped_7\n", - "INFO:napari_cellseg3d.utils:c2_images_cropped_8\n", - "INFO:napari_cellseg3d.utils:c2_images_cropped_9\n", - "INFO:napari_cellseg3d.utils:c3_images_cropped_0\n", - "INFO:napari_cellseg3d.utils:c3_images_cropped_1\n", - "INFO:napari_cellseg3d.utils:c3_images_cropped_10\n", - "INFO:napari_cellseg3d.utils:c3_images_cropped_11\n", - "INFO:napari_cellseg3d.utils:c3_images_cropped_12\n", - "INFO:napari_cellseg3d.utils:c3_images_cropped_13\n", - "INFO:napari_cellseg3d.utils:c3_images_cropped_14\n", - "INFO:napari_cellseg3d.utils:c3_images_cropped_15\n", - "INFO:napari_cellseg3d.utils:c3_images_cropped_16\n", - "INFO:napari_cellseg3d.utils:c3_images_cropped_17\n", - "INFO:napari_cellseg3d.utils:c3_images_cropped_18\n", - "INFO:napari_cellseg3d.utils:c3_images_cropped_19\n", - "INFO:napari_cellseg3d.utils:c3_images_cropped_2\n", - "INFO:napari_cellseg3d.utils:c3_images_cropped_20\n", - "INFO:napari_cellseg3d.utils:c3_images_cropped_21\n", - "INFO:napari_cellseg3d.utils:c3_images_cropped_22\n", - "INFO:napari_cellseg3d.utils:c3_images_cropped_23\n", - "INFO:napari_cellseg3d.utils:c3_images_cropped_24\n", - "INFO:napari_cellseg3d.utils:c3_images_cropped_25\n", - "INFO:napari_cellseg3d.utils:c3_images_cropped_26\n", - "INFO:napari_cellseg3d.utils:c3_images_cropped_27\n", - "INFO:napari_cellseg3d.utils:c3_images_cropped_28\n", - "INFO:napari_cellseg3d.utils:c3_images_cropped_29\n", - "INFO:napari_cellseg3d.utils:c3_images_cropped_3\n", - "INFO:napari_cellseg3d.utils:c3_images_cropped_4\n", - "INFO:napari_cellseg3d.utils:c3_images_cropped_5\n", - "INFO:napari_cellseg3d.utils:c3_images_cropped_6\n", - "INFO:napari_cellseg3d.utils:c3_images_cropped_7\n", - "INFO:napari_cellseg3d.utils:c3_images_cropped_8\n", - "INFO:napari_cellseg3d.utils:c3_images_cropped_9\n", - "INFO:napari_cellseg3d.utils:c4_images_cropped_0\n", - "INFO:napari_cellseg3d.utils:c4_images_cropped_10\n", - "INFO:napari_cellseg3d.utils:c4_images_cropped_11\n", - "INFO:napari_cellseg3d.utils:c4_images_cropped_12\n", - "INFO:napari_cellseg3d.utils:c4_images_cropped_13\n", - "INFO:napari_cellseg3d.utils:c4_images_cropped_14\n", - "INFO:napari_cellseg3d.utils:c4_images_cropped_15\n", - "INFO:napari_cellseg3d.utils:c4_images_cropped_16\n", - "INFO:napari_cellseg3d.utils:c4_images_cropped_17\n", - "INFO:napari_cellseg3d.utils:c4_images_cropped_18\n", - "INFO:napari_cellseg3d.utils:c4_images_cropped_19\n", - "INFO:napari_cellseg3d.utils:c4_images_cropped_2\n", - "INFO:napari_cellseg3d.utils:c4_images_cropped_3\n", - "INFO:napari_cellseg3d.utils:c4_images_cropped_4\n", - "INFO:napari_cellseg3d.utils:c4_images_cropped_5\n", - "INFO:napari_cellseg3d.utils:c4_images_cropped_6\n", - "INFO:napari_cellseg3d.utils:c4_images_cropped_7\n", - "INFO:napari_cellseg3d.utils:c4_images_cropped_8\n", - "INFO:napari_cellseg3d.utils:c4_images_cropped_9\n", - "INFO:napari_cellseg3d.utils:c5_images_cropped_0\n", - "INFO:napari_cellseg3d.utils:c5_images_cropped_1\n", - "INFO:napari_cellseg3d.utils:c5_images_cropped_10\n", - "INFO:napari_cellseg3d.utils:c5_images_cropped_11\n", - "INFO:napari_cellseg3d.utils:c5_images_cropped_12\n", - "INFO:napari_cellseg3d.utils:c5_images_cropped_13\n", - "INFO:napari_cellseg3d.utils:c5_images_cropped_14\n", - "INFO:napari_cellseg3d.utils:c5_images_cropped_15\n", - "INFO:napari_cellseg3d.utils:c5_images_cropped_16\n", - "INFO:napari_cellseg3d.utils:c5_images_cropped_17\n", - "INFO:napari_cellseg3d.utils:c5_images_cropped_18\n", - "INFO:napari_cellseg3d.utils:c5_images_cropped_19\n", - "INFO:napari_cellseg3d.utils:c5_images_cropped_2\n", - "INFO:napari_cellseg3d.utils:c5_images_cropped_3\n", - "INFO:napari_cellseg3d.utils:c5_images_cropped_4\n", - "INFO:napari_cellseg3d.utils:c5_images_cropped_5\n", - "INFO:napari_cellseg3d.utils:c5_images_cropped_6\n", - "INFO:napari_cellseg3d.utils:c5_images_cropped_7\n", - "INFO:napari_cellseg3d.utils:c5_images_cropped_8\n", - "INFO:napari_cellseg3d.utils:c5_images_cropped_9\n", - "INFO:napari_cellseg3d.utils:images_cropped_0\n", - "INFO:napari_cellseg3d.utils:images_cropped_1\n", - "INFO:napari_cellseg3d.utils:images_cropped_10\n", - "INFO:napari_cellseg3d.utils:images_cropped_11\n", - "INFO:napari_cellseg3d.utils:images_cropped_12\n", - "INFO:napari_cellseg3d.utils:images_cropped_13\n", - "INFO:napari_cellseg3d.utils:images_cropped_14\n", - "INFO:napari_cellseg3d.utils:images_cropped_15\n", - "INFO:napari_cellseg3d.utils:images_cropped_16\n", - "INFO:napari_cellseg3d.utils:images_cropped_17\n", - "INFO:napari_cellseg3d.utils:images_cropped_18\n", - "INFO:napari_cellseg3d.utils:images_cropped_19\n", - "INFO:napari_cellseg3d.utils:images_cropped_2\n", - "INFO:napari_cellseg3d.utils:images_cropped_20\n", - "INFO:napari_cellseg3d.utils:images_cropped_21\n", - "INFO:napari_cellseg3d.utils:images_cropped_22\n", - "INFO:napari_cellseg3d.utils:images_cropped_23\n", - "INFO:napari_cellseg3d.utils:images_cropped_24\n", - "INFO:napari_cellseg3d.utils:images_cropped_25\n", - "INFO:napari_cellseg3d.utils:images_cropped_26\n", - "INFO:napari_cellseg3d.utils:images_cropped_27\n", - "INFO:napari_cellseg3d.utils:images_cropped_28\n", - "INFO:napari_cellseg3d.utils:images_cropped_29\n", - "INFO:napari_cellseg3d.utils:images_cropped_3\n", - "INFO:napari_cellseg3d.utils:images_cropped_30\n", - "INFO:napari_cellseg3d.utils:images_cropped_31\n", - "INFO:napari_cellseg3d.utils:images_cropped_4\n", - "INFO:napari_cellseg3d.utils:images_cropped_5\n", - "INFO:napari_cellseg3d.utils:images_cropped_6\n", - "INFO:napari_cellseg3d.utils:images_cropped_7\n", - "INFO:napari_cellseg3d.utils:images_cropped_8\n", - "INFO:napari_cellseg3d.utils:images_cropped_9\n", - "INFO:napari_cellseg3d.utils:**********\n" - ] - } - ] - }, - { - "cell_type": "markdown", - "source": [ - "## **4.2. Start training**\n", - "---" - ], - "metadata": { - "id": "idowGpeQPIm2" - } - }, - { - "cell_type": "code", - "source": [ - "# @title\n", - "worker = c.get_colab_worker(worker_config=train_config, wandb_config=wandb_config)\n", - "for epoch_loss in worker.train():\n", - " continue" - ], - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/", - "height": 1000 - }, - "cellView": "form", - "id": "OXxKZhGMqguz", - "outputId": "aa79f4a6-dced-495d-95f9-42d31702506d" - }, - "execution_count": null, - "outputs": [ - { - "output_type": "stream", - "name": "stderr", - "text": [ - "DEBUG:napari_cellseg3d.utils:wandb config : {'device': 'cuda:0', 'max_epochs': 50, 'learning_rate': 2e-05, 'validation_interval': 2, 'batch_size': 4, 'deterministic_config': DeterministicConfig(enabled=True, seed=34936339), 'scheduler_factor': 0.5, 'scheduler_patience': 10, 'weights_info': WeightsInfo(path='/content/CellSeg3D/napari_cellseg3d/code_models/models/pretrained', custom=False, use_pretrained=False), 'results_path_folder': 'gdrive/MyDrive/CELLSEG_BENCHMARK/WNET_TRAINING_RESULTS', 'sampling': False, 'num_samples': 2, 'sample_size': None, 'do_augmentation': True, 'num_workers': 2, 'train_data_dict': [{'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_10.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_11.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_12.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_13.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_14.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_15.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_16.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_17.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_18.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_19.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_20.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_21.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_22.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_23.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_3.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_4.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_5.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_6.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_7.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_8.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_9.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_0.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_1.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_10.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_11.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_12.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_13.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_14.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_15.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_16.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_17.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_18.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_19.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_2.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_3.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_4.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_5.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_6.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_7.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_8.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_9.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_0.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_1.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_10.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_11.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_12.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_13.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_14.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_15.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_16.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_17.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_18.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_19.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_2.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_20.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_21.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_22.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_23.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_24.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_25.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_26.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_27.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_28.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_29.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_3.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_4.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_5.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_6.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_7.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_8.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_9.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_0.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_10.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_11.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_12.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_13.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_14.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_15.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_16.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_17.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_18.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_19.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_2.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_3.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_4.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_5.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_6.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_7.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_8.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_9.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_0.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_1.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_10.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_11.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_12.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_13.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_14.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_15.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_16.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_17.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_18.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_19.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_2.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_3.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_4.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_5.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_6.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_7.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_8.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_9.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_0.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_1.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_10.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_11.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_12.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_13.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_14.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_15.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_16.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_17.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_18.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_19.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_2.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_20.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_21.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_22.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_23.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_24.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_25.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_26.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_27.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_28.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_29.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_3.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_30.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_31.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_4.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_5.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_6.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_7.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_8.tif'}, {'image': 'gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_9.tif'}], 'in_channels': 1, 'out_channels': 1, 'num_classes': 2, 'dropout': 0.65, 'use_clipping': False, 'clipping': 1.0, 'weight_decay': 0.01, 'intensity_sigma': 1.0, 'spatial_sigma': 4.0, 'radius': 2, 'reconstruction_loss': 'MSE', 'n_cuts_weight': 0.5, 'rec_loss_weight': 0.005, 'eval_volume_dict': [{'image': PosixPath('gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/eval/vol/c3_image_cropped_eval.tif'), 'label': PosixPath('gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/eval/lab/c3_labels_cropped_eval.tif')}]}\n", - "\u001b[34m\u001b[1mwandb\u001b[0m: Currently logged in as: \u001b[33mc-achard\u001b[0m. Use \u001b[1m`wandb login --relogin`\u001b[0m to force relogin\n" - ] - }, - { - "output_type": "display_data", - "data": { - "text/plain": [ - "" - ], - "text/html": [ - "Tracking run with wandb version 0.15.8" - ] - }, - "metadata": {} - }, - { - "output_type": "display_data", - "data": { - "text/plain": [ - "" - ], - "text/html": [ - "Run data is saved locally in /content/wandb/run-20230803_142423-rbekeggu" - ] - }, - "metadata": {} - }, - { - "output_type": "display_data", - "data": { - "text/plain": [ - "" - ], - "text/html": [ - "Syncing run astral-rain-1 to Weights & Biases (docs)
" - ] - }, - "metadata": {} - }, - { - "output_type": "display_data", - "data": { - "text/plain": [ - "" - ], - "text/html": [ - " View project at https://wandb.ai/c-achard/CellSeg3D%20WNet%20%28Colab%29" - ] - }, - "metadata": {} - }, - { - "output_type": "display_data", - "data": { - "text/plain": [ - "" - ], - "text/html": [ - " View run at https://wandb.ai/c-achard/CellSeg3D%20WNet%20%28Colab%29/runs/rbekeggu" - ] - }, - "metadata": {} - }, - { - "output_type": "stream", - "name": "stderr", - "text": [ - "INFO:napari_cellseg3d.utils:********************\n", - "INFO:napari_cellseg3d.utils:-- Parameters --\n", - "INFO:napari_cellseg3d.utils:Device: cuda:0\n", - "INFO:napari_cellseg3d.utils:Batch size: 4\n", - "INFO:napari_cellseg3d.utils:Epochs: 50\n", - "INFO:napari_cellseg3d.utils:Learning rate: 2e-05\n", - "INFO:napari_cellseg3d.utils:Validation interval: 2\n", - "INFO:napari_cellseg3d.utils:Using data augmentation\n", - "INFO:napari_cellseg3d.utils:-- Model --\n", - "INFO:napari_cellseg3d.utils:Using 2 classes\n", - "INFO:napari_cellseg3d.utils:Weight decay: 0.01\n", - "INFO:napari_cellseg3d.utils:* NCuts : \n", - "INFO:napari_cellseg3d.utils:- Intensity sigma 1.0\n", - "INFO:napari_cellseg3d.utils:- Spatial sigma 4.0\n", - "INFO:napari_cellseg3d.utils:- Radius : 2\n", - "INFO:napari_cellseg3d.utils:* Reconstruction loss : MSE\n", - "INFO:napari_cellseg3d.utils:Weighted sum : 0.5*NCuts + 0.005*Reconstruction\n", - "INFO:napari_cellseg3d.utils:-- Data --\n", - "INFO:napari_cellseg3d.utils:Training data :\n", - "\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_10.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_11.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_12.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_13.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_14.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_15.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_16.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_17.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_18.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_19.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_20.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_21.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_22.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_23.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_3.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_4.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_5.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_6.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_7.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_8.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c1_images_cropped_9.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_0.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_1.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_10.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_11.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_12.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_13.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_14.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_15.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_16.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_17.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_18.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_19.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_2.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_3.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_4.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_5.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_6.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_7.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_8.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c2_images_cropped_9.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_0.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_1.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_10.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_11.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_12.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_13.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_14.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_15.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_16.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_17.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_18.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_19.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_2.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_20.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_21.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_22.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_23.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_24.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_25.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_26.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_27.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_28.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_29.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_3.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_4.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_5.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_6.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_7.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_8.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c3_images_cropped_9.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_0.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_10.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_11.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_12.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_13.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_14.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_15.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_16.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_17.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_18.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_19.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_2.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_3.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_4.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_5.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_6.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_7.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_8.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c4_images_cropped_9.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_0.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_1.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_10.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_11.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_12.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_13.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_14.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_15.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_16.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_17.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_18.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_19.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_2.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_3.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_4.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_5.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_6.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_7.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_8.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/c5_images_cropped_9.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_0.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_1.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_10.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_11.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_12.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_13.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_14.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_15.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_16.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_17.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_18.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_19.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_2.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_20.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_21.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_22.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_23.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_24.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_25.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_26.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_27.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_28.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_29.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_3.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_30.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_31.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_4.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_5.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_6.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_7.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_8.tif\n", - "INFO:napari_cellseg3d.utils:gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/VIP_full/images_cropped_9.tif\n", - "INFO:napari_cellseg3d.utils:\n", - "Validation data :\n", - "\n", - "INFO:napari_cellseg3d.utils:image: gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/eval/vol/c3_image_cropped_eval.tif\n", - "INFO:napari_cellseg3d.utils:label: gdrive/MyDrive/CELLSEG_BENCHMARK/DATA/WNET/eval/lab/c3_labels_cropped_eval.tif\n", - "INFO:napari_cellseg3d.utils:********************\n", - "INFO:napari_cellseg3d.utils:Initializing training...\n", - "INFO:napari_cellseg3d.utils:- Getting the data\n", - "DEBUG:napari_cellseg3d.utils:Loading volume dataset\n", - "monai.transforms.io.dictionary LoadImaged.__init__:image_only: Current default value of argument `image_only=False` has been deprecated since version 1.1. It will be changed to `image_only=True` in version 1.3.\n", - "DEBUG:napari_cellseg3d.utils:Data is 3D\n", - "DEBUG:napari_cellseg3d.utils:Image shape is torch.Size([64, 64, 64])\n", - "DEBUG:napari_cellseg3d.utils:Padding sizes are [64, 64, 64]\n", - "Loading dataset: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 142/142 [00:00<00:00, 44275.29it/s]\n", - "DEBUG:napari_cellseg3d.utils:Data shape : torch.Size([64, 64, 64])\n", - "Loading dataset: 0%| | 0/1 [00:00)\n", - "('use_patch', False)\n", - "('patch_size', (64, 64, 64))\n", - "('num_patches', 30)\n", - "('eval_num_patches', 20)\n", - "('do_augmentation', True)\n", - "('parallel', False)\n", - "('save_model', True)\n", - "('save_model_path', './../results/new_model/wnet_new_model_all_data_3class.pth')\n", - "('save_every', 5)\n", - "('weights_path', None)\n", - "Initializing training...\n", - "Getting the data\n", - "2023-07-10 10:00:17,137 - Images :\n", - "2023-07-10 10:00:17,137 - 1\n", - "2023-07-10 10:00:17,137 - 2\n", - "2023-07-10 10:00:17,137 - **********\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Loading dataset: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 2/2 [00:00