From f77af11029eb2af1b5f4cd03d09ca64897bcafb4 Mon Sep 17 00:00:00 2001 From: Liezl Maree <38435167+roomrys@users.noreply.github.com> Date: Fri, 15 Sep 2023 16:51:23 -0700 Subject: [PATCH] SLEAP 1.3.3 (#1505) * Do not try to remove item if already deleted (#1498) * Set `LD_LIBRARY_PATH` on `mamba activate` (#1496) * Add version restrictions to tensorflow for pypi (#1485) * Remove `imageio` pin (#1501) * Reset LD_LIBRARY_PATH on deactivate (#1502) * Brown bag bump to 1.3.3 (#1484) --- .conda/README.md | 4 +- .conda/build.sh | 10 ++++- .conda/sleap_activate.sh | 6 +++ .conda/sleap_deactivate.sh | 4 ++ .github/ISSUE_TEMPLATE/bug_report.md | 2 +- docs/conf.py | 4 +- docs/installation.md | 39 ++++++++++++++++++- docs/notebooks/Data_structures.ipynb | 2 +- .../Interactive_and_realtime_inference.ipynb | 2 +- .../Interactive_and_resumable_training.ipynb | 2 +- docs/notebooks/Model_evaluation.ipynb | 2 +- docs/notebooks/Post_inference_tracking.ipynb | 2 +- ..._and_inference_on_an_example_dataset.ipynb | 2 +- ...ing_and_inference_using_Google_Drive.ipynb | 2 +- environment.yml | 1 + pypi_requirements.txt | 20 +++++++--- sleap/gui/overlays/base.py | 20 +++++++--- sleap/version.py | 2 +- 18 files changed, 100 insertions(+), 26 deletions(-) create mode 100644 .conda/sleap_activate.sh create mode 100644 .conda/sleap_deactivate.sh diff --git a/.conda/README.md b/.conda/README.md index 65fadd36e..71a49d7f1 100644 --- a/.conda/README.md +++ b/.conda/README.md @@ -3,7 +3,7 @@ This folder defines the conda package build for Linux and Windows. There are run To build, first go to the base repo directory and install the build environment: ``` -conda env create -f environment_build.yml -n sleap_build && conda activate sleap_build +mamba env create -f environment_build.yml -n sleap_build && conda activate sleap_build ``` And finally, run the build command pointing to this directory: @@ -15,7 +15,7 @@ conda build .conda --output-folder build -c conda-forge -c nvidia -c https://con To install the local package: ``` -conda create -n sleap_0 -c conda-forge -c nvidia -c ./build -c https://conda.anaconda.org/sleap/ -c anaconda sleap=x.x.x +mamba create -n sleap_0 -c conda-forge -c nvidia -c ./build -c https://conda.anaconda.org/sleap/ -c anaconda sleap=x.x.x ``` replacing x.x.x with the version of SLEAP that you just built. diff --git a/.conda/build.sh b/.conda/build.sh index 620cd127a..86ab5af73 100644 --- a/.conda/build.sh +++ b/.conda/build.sh @@ -12,4 +12,12 @@ pip install --no-cache-dir -r ./requirements.txt # Install sleap itself. This does not install the requirements, but will list which # requirements are missing (see "install_requires") when user attempts to install. -python setup.py install --single-version-externally-managed --record=record.txt \ No newline at end of file +python setup.py install --single-version-externally-managed --record=record.txt + +# Copy the activate scripts to $PREFIX/etc/conda/activate.d. +# This will allow them to be run on environment activation. +for CHANGE in "activate" "deactivate" +do + mkdir -p "${PREFIX}/etc/conda/${CHANGE}.d" + cp "${RECIPE_DIR}/${PKG_NAME}_${CHANGE}.sh" "${PREFIX}/etc/conda/${CHANGE}.d/${PKG_NAME}_${CHANGE}.sh" +done \ No newline at end of file diff --git a/.conda/sleap_activate.sh b/.conda/sleap_activate.sh new file mode 100644 index 000000000..885879a89 --- /dev/null +++ b/.conda/sleap_activate.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +# Remember the old library path for when we deactivate +export SLEAP_OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH +# Help CUDA find GPUs! +export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH \ No newline at end of file diff --git a/.conda/sleap_deactivate.sh b/.conda/sleap_deactivate.sh new file mode 100644 index 000000000..857c0f49c --- /dev/null +++ b/.conda/sleap_deactivate.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Reset to the old library path for when deactivating the environment +export LD_LIBRARY_PATH=$SLEAP_OLD_LD_LIBRARY_PATH \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 24c20c513..8c95f28dc 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -28,7 +28,7 @@ Please include information about how you installed. - OS: - Version(s): - + - SLEAP installation method (listed [here](https://sleap.ai/installation.html#)): - [ ] [Conda from package](https://sleap.ai/installation.html#conda-package) - [ ] [Conda from source](https://sleap.ai/installation.html#conda-from-source) diff --git a/docs/conf.py b/docs/conf.py index b1e79fcc3..572e73ea0 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -28,7 +28,7 @@ copyright = f"2019–{date.today().year}, Talmo Lab" # The short X.Y version -version = "1.3.2" +version = "1.3.3" # Get the sleap version # with open("../sleap/version.py") as f: @@ -36,7 +36,7 @@ # version = re.search("\d.+(?=['\"])", version_file).group(0) # Release should be the full branch name -release = "v1.3.2" +release = "v1.3.3" html_title = f"SLEAP ({release})" html_short_title = "SLEAP" diff --git a/docs/installation.md b/docs/installation.md index ee9dad1ea..c028cd5b1 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -232,7 +232,7 @@ Although you do not need Mambaforge installed to perform a `pip install`, we rec 3. Finally, we can perform the `pip install`: ```bash - pip install sleap[pypi]==1.3.2 + pip install sleap[pypi]==1.3.3 ``` This works on **any OS except Apple silicon** and on **Google Colab**. @@ -343,10 +343,45 @@ python -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU') ````{warning} TensorFlow 2.7+ is currently failing to detect CUDA Toolkit and CuDNN on some systems (see [Issue thread](https://github.com/tensorflow/tensorflow/issues/52988)). -If you run into issues, try downgrading the TensorFlow 2.6: +If you run into issues, either try downgrading the TensorFlow 2.6: ```bash pip install tensorflow==2.6.3 ``` +or follow the note below. +```` + +````{note} +If you are on Linux, have a NVIDIA GPU, but cannot detect your GPU: + +```bash +W tensorflow/stream_executor/platform/default/dso_loader.cc:64 Could not load dynamic +library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object +file: No such file or directory +``` + +then activate the environment: + +```bash +mamba activate sleap +``` + +and run the commands: +```bash +mkdir -p $CONDA_PREFIX/etc/conda/activate.d +echo '#!/bin/sh' >> $CONDA_PREFIX/etc/conda/activate.d/sleap_activate.sh +echo 'export SLEAP_OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH' >> $CONDA_PREFIX/etc/conda/activate.d/sleap_activate.sh +echo 'export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH' >> $CONDA_PREFIX/etc/conda/activate.d/sleap_activate.sh +source $CONDA_PREFIX/etc/conda/activate.d/sleap_activate.sh +``` + +This will set the environment variable `LD_LIBRARY_PATH` each time the environment is activated. The environment variable will remain set in the current terminal even if we deactivate the environment. Although not strictly necessary, if you would also like the environment variable to be reset to the original value when deactivating the environment, we can run the following commands: +```bash +mkdir -p $CONDA_PREFIX/etc/conda/deactivate.d +echo '#!/bin/sh' >> $CONDA_PREFIX/etc/conda/deactivate.d/sleap_deactivate.sh +echo 'export LD_LIBRARY_PATH=$SLEAP_OLD_LD_LIBRARY_PATH' >> $CONDA_PREFIX/etc/conda/deactivate.d/sleap_deactivate.sh +``` + +These commands only need to be run once and will subsequently run automatically upon [de]activating your `sleap` environment. ```` ## Upgrading and uninstalling diff --git a/docs/notebooks/Data_structures.ipynb b/docs/notebooks/Data_structures.ipynb index a3337186c..ff0ea2d3d 100644 --- a/docs/notebooks/Data_structures.ipynb +++ b/docs/notebooks/Data_structures.ipynb @@ -56,7 +56,7 @@ "source": [ "# This should take care of all the dependencies on colab:\n", "!pip uninstall -qqq -y opencv-python opencv-contrib-python\n", - "!pip install -qqq sleap==1.3.1111\n", + "!pip install -qqq \"sleap[pypi]>=1.3.3\"\n", "\n", "# But to do it locally, we'd recommend the conda package (available on Windows + Linux):\n", "# conda create -n sleap -c sleap -c conda-forge -c nvidia sleap" diff --git a/docs/notebooks/Interactive_and_realtime_inference.ipynb b/docs/notebooks/Interactive_and_realtime_inference.ipynb index 5d9c7e33d..4a3b612a2 100644 --- a/docs/notebooks/Interactive_and_realtime_inference.ipynb +++ b/docs/notebooks/Interactive_and_realtime_inference.ipynb @@ -60,7 +60,7 @@ "source": [ "# This should take care of all the dependencies on colab:\n", "!pip uninstall -qqq -y opencv-python opencv-contrib-python\n", - "!pip install -qqq sleap==1.3.1\n", + "!pip install -qqq \"sleap[pypi]>=1.3.3\"\n", "\n", "\n", "# But to do it locally, we'd recommend the conda package (available on Windows + Linux):\n", diff --git a/docs/notebooks/Interactive_and_resumable_training.ipynb b/docs/notebooks/Interactive_and_resumable_training.ipynb index be82c19a5..f30f036f3 100644 --- a/docs/notebooks/Interactive_and_resumable_training.ipynb +++ b/docs/notebooks/Interactive_and_resumable_training.ipynb @@ -62,7 +62,7 @@ "source": [ "# This should take care of all the dependencies on colab:\n", "!pip uninstall -qqq -y opencv-python opencv-contrib-python\n", - "!pip install -qqq sleap==1.3.1\n", + "!pip install -qqq \"sleap[pypi]>=1.3.3\"\n", "\n", "\n", "# But to do it locally, we'd recommend the conda package (available on Windows + Linux):\n", diff --git a/docs/notebooks/Model_evaluation.ipynb b/docs/notebooks/Model_evaluation.ipynb index 62bf3935a..41ca6568c 100644 --- a/docs/notebooks/Model_evaluation.ipynb +++ b/docs/notebooks/Model_evaluation.ipynb @@ -40,7 +40,7 @@ ], "source": [ "!pip uninstall -qqq -y opencv-python opencv-contrib-python\n", - "!pip install -qqq sleap==1.3.1\n", + "!pip install -qqq \"sleap[pypi]>=1.3.3\"\n", "!apt -qq install tree\n", "!wget -q https://storage.googleapis.com/sleap-data/reference/flies13/td_fast.210505_012601.centered_instance.n%3D1800.zip\n", "!unzip -qq -o -d \"td_fast.210505_012601.centered_instance.n=1800\" \"td_fast.210505_012601.centered_instance.n=1800.zip\"" diff --git a/docs/notebooks/Post_inference_tracking.ipynb b/docs/notebooks/Post_inference_tracking.ipynb index 106c7ae88..239176bdb 100644 --- a/docs/notebooks/Post_inference_tracking.ipynb +++ b/docs/notebooks/Post_inference_tracking.ipynb @@ -61,7 +61,7 @@ "source": [ "# This should take care of all the dependencies on colab:\n", "!pip uninstall -qqq -y opencv-python opencv-contrib-python\n", - "!pip install -qqq sleap==1.3.1\n", + "!pip install -qqq \"sleap[pypi]>=1.3.3\"\n", "\n", "# But to do it locally, we'd recommend the conda package (available on Windows + Linux):\n", "# conda create -n sleap -c sleap -c conda-forge -c nvidia sleap" diff --git a/docs/notebooks/Training_and_inference_on_an_example_dataset.ipynb b/docs/notebooks/Training_and_inference_on_an_example_dataset.ipynb index 22c4193f7..b0211bbca 100644 --- a/docs/notebooks/Training_and_inference_on_an_example_dataset.ipynb +++ b/docs/notebooks/Training_and_inference_on_an_example_dataset.ipynb @@ -62,7 +62,7 @@ ], "source": [ "!pip uninstall -qqq -y opencv-python opencv-contrib-python\n", - "!pip install -qqq sleap==1.3.1" + "!pip install -qqq \"sleap[pypi]>=1.3.3\"" ] }, { diff --git a/docs/notebooks/Training_and_inference_using_Google_Drive.ipynb b/docs/notebooks/Training_and_inference_using_Google_Drive.ipynb index 96374982d..1e871861d 100644 --- a/docs/notebooks/Training_and_inference_using_Google_Drive.ipynb +++ b/docs/notebooks/Training_and_inference_using_Google_Drive.ipynb @@ -59,7 +59,7 @@ ], "source": [ "!pip uninstall -qqq -y opencv-python opencv-contrib-python\n", - "!pip install -qqq sleap==1.3.1" + "!pip install -qqq \"sleap[pypi]>=1.3.3\"" ] }, { diff --git a/environment.yml b/environment.yml index 9f9ff903d..67ed39d01 100644 --- a/environment.yml +++ b/environment.yml @@ -46,3 +46,4 @@ dependencies: - pip: - "--editable=.[conda_dev]" + \ No newline at end of file diff --git a/pypi_requirements.txt b/pypi_requirements.txt index b18637c37..33f419c9c 100644 --- a/pypi_requirements.txt +++ b/pypi_requirements.txt @@ -12,24 +12,34 @@ jsonpickle==1.2 networkx numpy>=1.19.5,<1.23.0 opencv-python>=4.2.0,<=4.6.0 -# opencv-python-headless>=4.2.0.34,<=4.5.5.62 pandas pillow>=8.3.1,<=8.4.0 psutil pykalman==0.9.5 PySide2>=5.13.2,<=5.14.1; platform_machine != 'arm64' PySide6; sys_platform == 'darwin' and platform_machine == 'arm64' -python-rapidjson +# Otherwise error: Microsoft Visual C++ 14.0 is required. +python-rapidjson <=1.10; sys_platform == 'win32' +python-rapidjson; sys_platform != 'win32' pyyaml pyzmq qtpy>=2.0.1 rich==10.16.1 -imageio<=2.15.0 imgaug==0.4.0 scipy>=1.4.1,<=1.9.0 scikit-image scikit-learn ==1.0.* scikit-video seaborn -tensorflow -tensorflow-hub +tensorflow>=2.6.3,<2.9; platform_machine != 'arm64' +tensorflow-hub<=0.14.0 +# These dependencies are untested since we do not offer a wheel for apple silicon atm. +tensorflow-macos==2.9.2; sys_platform == 'darwin' and platform_machine == 'arm64' +tensorflow-metal==0.5.0; sys_platform == 'darwin' and platform_machine == 'arm64' + +# Dependencies of dependencies +# google-auth 2.23.0 has requirement urllib3<2.0 +urllib3<2.0 # Not a 'noticed' runtime-dependency +# tensorboard 2.11.2 has requirement protobuf<4,>=3.9.2 +# tensorflow 2.11.0 has requirement protobuf<3.20,>=3.9.2 +protobuf<3.20 # Makes GUI work in windows \ No newline at end of file diff --git a/sleap/gui/overlays/base.py b/sleap/gui/overlays/base.py index 019f87355..d27b069ac 100644 --- a/sleap/gui/overlays/base.py +++ b/sleap/gui/overlays/base.py @@ -8,13 +8,13 @@ so that current frame must be redrawn). """ -from qtpy import QtWidgets - -import attr import abc -import numpy as np +import logging from typing import Sequence, Union, Optional, List +import attr +import numpy as np +from qtpy import QtWidgets from qtpy.QtWidgets import QGraphicsItem from sleap import Labels, Video @@ -22,6 +22,8 @@ from sleap.nn.data.providers import VideoReader from sleap.nn.inference import VisualPredictor +logger = logging.getLogger(__name__) + @attr.s(auto_attribs=True) class BaseOverlay(abc.ABC): @@ -64,7 +66,15 @@ def remove_from_scene(self): if self.items is None: return for item in self.items: - self.player.scene.removeItem(item) + try: + self.player.scene.removeItem(item) + + except RuntimeError as e: # Internal C++ object (PySide2.QtWidgets.QGraphicsPathItem) already deleted. + logger.debug(e) + pass + + # Stop tracking the items after they been removed from the scene + self.items = [] def redraw(self, video, frame_idx, *args, **kwargs): """Remove all items from the scene before adding new items to the scene. diff --git a/sleap/version.py b/sleap/version.py index ffa7b55b9..437e17fba 100644 --- a/sleap/version.py +++ b/sleap/version.py @@ -12,7 +12,7 @@ """ -__version__ = "1.3.2" +__version__ = "1.3.3" def versions():