From fa265fae16ba2a9a54795b43beb54cf510395040 Mon Sep 17 00:00:00 2001 From: Ben Blaiszik Date: Mon, 15 Jul 2024 11:15:43 -0500 Subject: [PATCH] Update segmentation example --- .../dendrite_segmentation.ipynb | 187 +++--------------- 1 file changed, 28 insertions(+), 159 deletions(-) diff --git a/examples/dendrite-segmentation/dendrite_segmentation.ipynb b/examples/dendrite-segmentation/dendrite_segmentation.ipynb index 5a4ca048..c990ef3a 100644 --- a/examples/dendrite-segmentation/dendrite_segmentation.ipynb +++ b/examples/dendrite-segmentation/dendrite_segmentation.ipynb @@ -43,7 +43,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 4, "metadata": { "id": "uqzPXhJZ-mjy" }, @@ -57,7 +57,7 @@ "except: # when not in google colab\n", " no_local_server=False\n", " no_browser=False\n", - " use_globus=True" + " use_globus=False" ] }, { @@ -74,132 +74,11 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": { "id": "0bJUs5pJHsc4" }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Requirement already satisfied: scikit-learn in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (1.3.2)\n", - "Requirement already satisfied: numpy<2.0,>=1.17.3 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from scikit-learn) (1.26.2)\n", - "Requirement already satisfied: scipy>=1.5.0 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from scikit-learn) (1.11.4)\n", - "Requirement already satisfied: joblib>=1.1.1 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from scikit-learn) (1.3.2)\n", - "Requirement already satisfied: threadpoolctl>=2.0.0 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from scikit-learn) (3.2.0)\n", - "Collecting scikit-image\n", - " Downloading scikit_image-0.22.0-cp310-cp310-macosx_10_9_x86_64.whl.metadata (13 kB)\n", - "Requirement already satisfied: numpy>=1.22 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from scikit-image) (1.26.2)\n", - "Requirement already satisfied: scipy>=1.8 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from scikit-image) (1.11.4)\n", - "Requirement already satisfied: networkx>=2.8 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from scikit-image) (3.2.1)\n", - "Requirement already satisfied: pillow>=9.0.1 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from scikit-image) (10.1.0)\n", - "Collecting imageio>=2.27 (from scikit-image)\n", - " Downloading imageio-2.33.0-py3-none-any.whl.metadata (4.9 kB)\n", - "Collecting tifffile>=2022.8.12 (from scikit-image)\n", - " Downloading tifffile-2023.9.26-py3-none-any.whl.metadata (30 kB)\n", - "Requirement already satisfied: packaging>=21 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from scikit-image) (23.2)\n", - "Collecting lazy_loader>=0.3 (from scikit-image)\n", - " Downloading lazy_loader-0.3-py3-none-any.whl.metadata (4.3 kB)\n", - "Downloading scikit_image-0.22.0-cp310-cp310-macosx_10_9_x86_64.whl (13.9 MB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m13.9/13.9 MB\u001b[0m \u001b[31m25.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n", - "\u001b[?25hDownloading imageio-2.33.0-py3-none-any.whl (313 kB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m313.3/313.3 kB\u001b[0m \u001b[31m23.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", - "\u001b[?25hDownloading lazy_loader-0.3-py3-none-any.whl (9.1 kB)\n", - "Downloading tifffile-2023.9.26-py3-none-any.whl (222 kB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m222.9/222.9 kB\u001b[0m \u001b[31m19.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", - "\u001b[?25hInstalling collected packages: tifffile, lazy_loader, imageio, scikit-image\n", - "Successfully installed imageio-2.33.0 lazy_loader-0.3 scikit-image-0.22.0 tifffile-2023.9.26\n", - "Requirement already satisfied: tensorflow in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (2.15.0)\n", - "Requirement already satisfied: absl-py>=1.0.0 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from tensorflow) (2.0.0)\n", - "Requirement already satisfied: astunparse>=1.6.0 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from tensorflow) (1.6.3)\n", - "Requirement already satisfied: flatbuffers>=23.5.26 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from tensorflow) (23.5.26)\n", - "Requirement already satisfied: gast!=0.5.0,!=0.5.1,!=0.5.2,>=0.2.1 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from tensorflow) (0.5.4)\n", - "Requirement already satisfied: google-pasta>=0.1.1 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from tensorflow) (0.2.0)\n", - "Requirement already satisfied: h5py>=2.9.0 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from tensorflow) (3.10.0)\n", - "Requirement already satisfied: libclang>=13.0.0 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from tensorflow) (16.0.6)\n", - "Requirement already satisfied: ml-dtypes~=0.2.0 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from tensorflow) (0.2.0)\n", - "Requirement already satisfied: numpy<2.0.0,>=1.23.5 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from tensorflow) (1.26.2)\n", - "Requirement already satisfied: opt-einsum>=2.3.2 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from tensorflow) (3.3.0)\n", - "Requirement already satisfied: packaging in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from tensorflow) (23.2)\n", - "Requirement already satisfied: protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<5.0.0dev,>=3.20.3 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from tensorflow) (4.23.4)\n", - "Requirement already satisfied: setuptools in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from tensorflow) (58.1.0)\n", - "Requirement already satisfied: six>=1.12.0 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from tensorflow) (1.16.0)\n", - "Requirement already satisfied: termcolor>=1.1.0 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from tensorflow) (2.3.0)\n", - "Requirement already satisfied: typing-extensions>=3.6.6 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from tensorflow) (4.8.0)\n", - "Requirement already satisfied: wrapt<1.15,>=1.11.0 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from tensorflow) (1.14.1)\n", - "Requirement already satisfied: tensorflow-io-gcs-filesystem>=0.23.1 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from tensorflow) (0.34.0)\n", - "Requirement already satisfied: grpcio<2.0,>=1.24.3 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from tensorflow) (1.59.3)\n", - "Requirement already satisfied: tensorboard<2.16,>=2.15 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from tensorflow) (2.15.1)\n", - "Requirement already satisfied: tensorflow-estimator<2.16,>=2.15.0 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from tensorflow) (2.15.0)\n", - "Requirement already satisfied: keras<2.16,>=2.15.0 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from tensorflow) (2.15.0)\n", - "Requirement already satisfied: wheel<1.0,>=0.23.0 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from astunparse>=1.6.0->tensorflow) (0.42.0)\n", - "Requirement already satisfied: google-auth<3,>=1.6.3 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from tensorboard<2.16,>=2.15->tensorflow) (2.23.4)\n", - "Requirement already satisfied: google-auth-oauthlib<2,>=0.5 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from tensorboard<2.16,>=2.15->tensorflow) (1.1.0)\n", - "Requirement already satisfied: markdown>=2.6.8 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from tensorboard<2.16,>=2.15->tensorflow) (3.5.1)\n", - "Requirement already satisfied: requests<3,>=2.21.0 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from tensorboard<2.16,>=2.15->tensorflow) (2.31.0)\n", - "Requirement already satisfied: tensorboard-data-server<0.8.0,>=0.7.0 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from tensorboard<2.16,>=2.15->tensorflow) (0.7.2)\n", - "Requirement already satisfied: werkzeug>=1.0.1 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from tensorboard<2.16,>=2.15->tensorflow) (3.0.1)\n", - "Requirement already satisfied: cachetools<6.0,>=2.0.0 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from google-auth<3,>=1.6.3->tensorboard<2.16,>=2.15->tensorflow) (5.3.2)\n", - "Requirement already satisfied: pyasn1-modules>=0.2.1 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from google-auth<3,>=1.6.3->tensorboard<2.16,>=2.15->tensorflow) (0.3.0)\n", - "Requirement already satisfied: rsa<5,>=3.1.4 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from google-auth<3,>=1.6.3->tensorboard<2.16,>=2.15->tensorflow) (4.9)\n", - "Requirement already satisfied: requests-oauthlib>=0.7.0 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from google-auth-oauthlib<2,>=0.5->tensorboard<2.16,>=2.15->tensorflow) (1.3.1)\n", - "Requirement already satisfied: charset-normalizer<4,>=2 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from requests<3,>=2.21.0->tensorboard<2.16,>=2.15->tensorflow) (3.3.2)\n", - "Requirement already satisfied: idna<4,>=2.5 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from requests<3,>=2.21.0->tensorboard<2.16,>=2.15->tensorflow) (3.6)\n", - "Requirement already satisfied: urllib3<3,>=1.21.1 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from requests<3,>=2.21.0->tensorboard<2.16,>=2.15->tensorflow) (2.1.0)\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Requirement already satisfied: certifi>=2017.4.17 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from requests<3,>=2.21.0->tensorboard<2.16,>=2.15->tensorflow) (2023.7.22)\n", - "Requirement already satisfied: MarkupSafe>=2.1.1 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from werkzeug>=1.0.1->tensorboard<2.16,>=2.15->tensorflow) (2.1.3)\n", - "Requirement already satisfied: pyasn1<0.6.0,>=0.4.6 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from pyasn1-modules>=0.2.1->google-auth<3,>=1.6.3->tensorboard<2.16,>=2.15->tensorflow) (0.5.1)\n", - "Requirement already satisfied: oauthlib>=3.0.0 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<2,>=0.5->tensorboard<2.16,>=2.15->tensorflow) (3.2.2)\n", - "Collecting keras-unet\n", - " Downloading keras_unet-0.1.2-py3-none-any.whl (16 kB)\n", - "Installing collected packages: keras-unet\n", - "Successfully installed keras-unet-0.1.2\n", - "Requirement already satisfied: opencv-python in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (4.8.1.78)\n", - "Requirement already satisfied: numpy>=1.21.2 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from opencv-python) (1.26.2)\n", - "Collecting pandas==1.2.2\n", - " Using cached pandas-1.2.2.tar.gz (5.5 MB)\n", - " Installing build dependencies ... \u001b[?25ldone\n", - "\u001b[?25h Getting requirements to build wheel ... \u001b[?25ldone\n", - "\u001b[?25h Preparing metadata (pyproject.toml) ... \u001b[?25ldone\n", - "\u001b[?25hCollecting tables==3.6.1\n", - " Using cached tables-3.6.1.tar.gz (4.6 MB)\n", - " Preparing metadata (setup.py) ... \u001b[?25lerror\n", - " \u001b[1;31merror\u001b[0m: \u001b[1msubprocess-exited-with-error\u001b[0m\n", - " \n", - " \u001b[31m×\u001b[0m \u001b[32mpython setup.py egg_info\u001b[0m did not run successfully.\n", - " \u001b[31m│\u001b[0m exit code: \u001b[1;36m1\u001b[0m\n", - " \u001b[31m╰─>\u001b[0m \u001b[31m[10 lines of output]\u001b[0m\n", - " \u001b[31m \u001b[0m /var/folders/pt/yt32tjj14wnd61myqn_0mj6r0000gn/T/H5closer_08_171.c:2:5: error: call to undeclared function 'H5close'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]\n", - " \u001b[31m \u001b[0m H5close();\n", - " \u001b[31m \u001b[0m ^\n", - " \u001b[31m \u001b[0m 1 error generated.\n", - " \u001b[31m \u001b[0m * Using Python 3.10.0 (v3.10.0:b494f5935c, Oct 4 2021, 14:59:20) [Clang 12.0.5 (clang-1205.0.22.11)]\n", - " \u001b[31m \u001b[0m * USE_PKGCONFIG: False\n", - " \u001b[31m \u001b[0m .. ERROR:: Could not find a local HDF5 installation.\n", - " \u001b[31m \u001b[0m You may need to explicitly state where your local HDF5 headers and\n", - " \u001b[31m \u001b[0m library can be found by setting the ``HDF5_DIR`` environment\n", - " \u001b[31m \u001b[0m variable or by using the ``--hdf5`` command-line option.\n", - " \u001b[31m \u001b[0m \u001b[31m[end of output]\u001b[0m\n", - " \n", - " \u001b[1;35mnote\u001b[0m: This error originates from a subprocess, and is likely not a problem with pip.\n", - "\u001b[1;31merror\u001b[0m: \u001b[1mmetadata-generation-failed\u001b[0m\n", - "\n", - "\u001b[31m×\u001b[0m Encountered error while generating package metadata.\n", - "\u001b[31m╰─>\u001b[0m See above for output.\n", - "\n", - "\u001b[1;35mnote\u001b[0m: This is an issue with the package mentioned above, not pip.\n", - "\u001b[1;36mhint\u001b[0m: See above for details.\n", - "\u001b[?25h" - ] - } - ], + "outputs": [], "source": [ "!pip install scikit-learn\n", "!pip install foundry_ml\n", @@ -223,29 +102,11 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": { "id": "hWjnG87hgMyz" }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "2023-11-30 10:42:29.671551: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.\n", - "To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "-----------------------------------------\n", - "keras-unet init: TF version is >= 2.0.0 - using `tf.keras` instead of `Keras`\n", - "-----------------------------------------\n" - ] - } - ], + "outputs": [], "source": [ "from foundry.foundry import Foundry\n", "from skimage.io import imshow, imread\n", @@ -273,7 +134,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 6, "metadata": { "id": "cmqehQpfA7VB", "outputId": "18cfe26b-2484-4985-9264-4be8031295c6" @@ -295,7 +156,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 7, "metadata": { "colab": { "base_uri": "https://localhost:8080/", @@ -318,7 +179,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 8, "metadata": { "tags": [ "keep_output" @@ -357,7 +218,7 @@ " 0\n", " foundry_stan_segmentation_v1.1\n", " Dataset for Semantic Segmentation of Dendrites...\n", - " 2021\n", + " root=2021\n", " 10.18126/d4kn-cz3p\n", " \n", " \n", @@ -368,14 +229,14 @@ " dataset_name \\\n", "0 foundry_stan_segmentation_v1.1 \n", "\n", - " title year \\\n", - "0 Dataset for Semantic Segmentation of Dendrites... 2021 \n", + " title year \\\n", + "0 Dataset for Semantic Segmentation of Dendrites... root=2021 \n", "\n", " DOI FoundryDataset \n", "0 10.18126/d4kn-cz3p " ] @@ -1058,7 +928,6 @@ "metadata": { "id": "0U1i3PN9gMy_", "outputId": "dc030ad3-6e96-4577-bcc6-5e34ab6844d9", - "scrolled": false, "tags": [ "keep_output" ] @@ -1109,7 +978,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.4" + "version": "3.12.1" } }, "nbformat": 4,