Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix conversion to numpy array when last frame(s) do not have labels #1307

Merged
merged 1 commit into from
May 17, 2023

Conversation

talmo
Copy link
Collaborator

@talmo talmo commented May 9, 2023

Description

Fix conversion to numpy array when last frame(s) do not have labels. This is a regression that occurred at some point.

Labels.numpy(all_frames=True) should return an array with length n_frames where n_frames == len(video), but right now it's just building that array up to the last LabeledFrame associated with that video. This can result in truncated arrays if we're missing predictions at the end of the video.

The behavior works as expected if frames are missing at the beginning of the video, however. This PR fixes it for missing frames at the end of the video.

Types of changes

  • Bugfix
  • New feature
  • Refactor / Code style update (no logical changes)
  • Build / CI changes
  • Documentation Update
  • Other (explain)

Does this address any currently open issues?

[list open issues here]

Outside contributors checklist

  • Review the guidelines for contributing to this repository
  • Read and sign the CLA and add yourself to the authors list
  • Make sure you are making a pull request against the develop branch (not main). Also you should start your branch off develop
  • Add tests that prove your fix is effective or that your feature works
  • Add necessary documentation (if appropriate)

Thank you for contributing to SLEAP!

❤️

@talmo talmo requested a review from roomrys May 9, 2023 23:50
@codecov
Copy link

codecov bot commented May 10, 2023

Codecov Report

Merging #1307 (525ec4d) into develop (b5aab0e) will decrease coverage by 0.02%.
The diff coverage is 100.00%.

@@             Coverage Diff             @@
##           develop    #1307      +/-   ##
===========================================
- Coverage    72.36%   72.34%   -0.02%     
===========================================
  Files          133      133              
  Lines        23662    23663       +1     
===========================================
- Hits         17123    17119       -4     
- Misses        6539     6544       +5     
Impacted Files Coverage Δ
sleap/gui/app.py 74.80% <100.00%> (ø)
sleap/gui/widgets/docks.py 94.69% <100.00%> (+0.37%) ⬆️
sleap/io/dataset.py 83.57% <100.00%> (+0.01%) ⬆️

... and 2 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@roomrys roomrys merged commit 1e9026d into develop May 17, 2023
@roomrys roomrys deleted the talmo/fix_labels_numpy_end_case branch May 17, 2023 18:01
roomrys added a commit that referenced this pull request Jun 30, 2023
* Disable data caching by default for SingleImageVideos (#1243)

* Disable data caching by default for SingleImageVideos

* Remove a couple things that shouldn't be in this PR :)

* Centralize video extensions (#1244)

* Add video extension support lists to io.video module

* Use centralized extension definitions

* Remove some unused code

* Add some coverage for indirect coverage reduction

* Fix single frame GUI increment (#1254)

* Fix frame increment for single frame videos

* Add test and lint

* Add video search to "robustify" (excessively) fragile test (#1262)

Add video search to fix fragile test

* Organize docks (#1265)

* Add `DockWidget` class and subclasses

* Create docks in `MainWindow` using `DockWidget` classes

* Remove unused imports

* Fix references in existing tests

* Fix intermittent bug (file-corruption) that has snuck into the tests (#1267)

* Remove corrupted test file

* Add non-corrupted copy of test file

* Rename the file so tests run

* Layout docks in a tab configuration (instead of stacked) (#1289)

* Add tab with to docks (and use `self.model` in table)

* Use `self.model_type` in `create_models`

* Increase GUI crop size range from 512 to 832 (#1295)

* Fix conversion to numpy array when last frame(s) do not have labels (#1307)

* Ensure frames to predict list is unique (#1293)

* Ensure frames to predict list is unique

* Ensure frames to predict on are ordered correctly

* Better frame sorting

* Fix GUI resume training (#1314)

* Do not choose `top_k` instances if `max_instances` < num centroids (#1313)

* Use max_instances as a max without any minimum requirement

* Create test (that fails)

* Fix test by re-init inference model each call

* Do not compute top k if max is greater

* Add `--max_instances` to `sleap-track` and GUI (#1305)

* Expose --max_instances to sleap-track and in GUI

* Lint

* Change shorthand to `-n` for both `sleap-export` and `sleap-track`

* Add test for creating predictor from cli

* Add max instances support to bottom up model (#1306)

* Add max instances support to bottom up model

* Remove unnecessary attribute setter in CLI parser

* Edge case

* Expose max_instances for BU to train/infer GUI

---------

Co-authored-by: roomrys <[email protected]>

* Update docs for `--max_instances` command

* Add test for BU `--max_instances`

---------

Co-authored-by: Talmo Pereira <[email protected]>

* Remove `--labels` and redundant `data_path` (#1326)

* Create copy of config info to modify (gui) (#1325)

* Fixes GPU memory polling using environment variable filtering (#1272)

* add cuda visible gpus to nvidia smi CLI

* tests masked none, single and multiple GPUs

* deal with comma separated lists and test 2 gpus

* clean up system script and better test that actually works

* add a case for cuda_visible_devices = []

* add test for gpu order and length in nvidia and tf

* test nvidia smi indices and checking gpu memory

* fix spaces

* fix linting with Black

* put skips in tests for git not having nvidia-smi

* add doc strings to get_gpu_memory

* set CUDA device order to PCI BUS ID

* test with no nvidia smi + invalid visible devices

* fixed linting again

* remove pci env variable, move to other issue

---------

Co-authored-by: Eric Leonardis <[email protected]>

* Set `split_by_inds`, `test_labels`, and `validation_labels` to default (GUI) (#1331)

* Allow returning PAF graph during low level inference (#1329)

* allow returning the paf graph during low level inference

* reformatted with black

* Fix `SingleImageVideo` caching (#1330)

* Set `SingleImageVideo.caching` as a class attribute

* Modify tests for `SingleImageVideo.caching`

* Add caching as a preference and menu checkbox

* Test `SingleImageVideo.toggle_caching`

* Remove GUI elements for `SingleImageVideo.CACHING`

* Remove remaining prefs for `SingleImageVideo.CACHING`

* Add depreciated comment

* Clean-up

* Update comments

* Bump to 1.3.1 (#1335)

* Bump to 1.3.1

* Test build to dev label

* Update environment creation (#1366)

* First 'working' env for 1.3.1, no GPU...

* First working 1.3.1 w/gpu

* Sorry, this is the first gpu working env

* Fix `imgstore` version-dependent bug

* Build and entry points work, but pip packages not installed

* Add default channels in condarc.yaml

* Rename environment.yaml to .yml

* Working build no gpu (documented)

* Env working w/gpu using tensorflow from pypi

* Working build with GPU! And pip dep

* Attempt to fix cannot find wheel ~= 0.35 issue

* Run constrain everything

* Use minimal conda req for install_requires, inc build number to get it working

* Ubuntu build and environments working

* Env creation working on M2

* Build and env working on windows (again)

* Apple silicon (M2) build working

* Pip package working (M2)

* Exclude tests and docs from pypi wheel

* Add comments to requirements

* Get ready for manual build

* Update os images, trigger dev build

* Retry manual build win and mac

* Retry mac manual build (to upload)

* Require latest pynwb, remove setuptools

* Remove old mac environment

* Add twine as a build dependency

* Add comments to manual build

* Update build.yml

* Rename "apple_silicon" to "mac"

* Update installation docs (#1365)

* Update installation docs

* Trigger website build

* Update quick install and build docs

* Add Mambaforge links

* Remove comment about experimental apple silicon support

Co-authored-by: Talmo Pereira <[email protected]>

* Fix minor typo

* Change installation docs to reference universal mac env

---------

Co-authored-by: Talmo Pereira <[email protected]>

* More flexible with python version ~=3.7

* Pin py3.7.12 for host and run (good on win)

* Add comments for why python ~=3.7

* Update ci workflow (#1371)

* Update CI workflow to include mac

* Trigger CI workflow

* Remove verbose? python version

* Migrate to micromamba

* Explicitly state environment name

* Remove environment chaching (for now)

* Use different environment file for mac

* Use correct syntax

* Add `env_hash` and `bash -l {0}`

* Remove env_file

* Try different nested variable call via format

* Use correct syntax

* Update env file reference AS -> mac

* Different path to environment file

* Checkout repo

* Use default shells

* Remove unused comments

* Fix caching attempt by changing caching key

* Remove environment caching

* Increase python in no_cuda to 3.7.17

* Less restrictive with python ~3.7 version

* More direct installation docs 🤞

* Increase build numbers for develop branch build

---------

Co-authored-by: Talmo Pereira <[email protected]>

---------

Co-authored-by: Talmo Pereira <[email protected]>
Co-authored-by: Eric Leonardis <[email protected]>
Co-authored-by: Eric Leonardis <[email protected]>
Co-authored-by: Caleb Weinreb <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants