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

Taxonomy rollup cutoff with a threshold #37

Merged
merged 53 commits into from
Nov 20, 2024

Conversation

jtklein
Copy link
Contributor

@jtklein jtklein commented Nov 1, 2024

This adds a customizable threshold to the computer vision workflow during frame processing.

During the recursive aggregation of scores for the inner taxonomic nodes a threshold is applied and every node with a lower computer vision score is excluded from the set of nodes on which to find the best predictions from.

Technically there is a breaking change in the structure of the returned dictionary for predictions from file but neither Seek nor iNat has destructured the uri param, so I will not bump major version.

@alexshepard can you please double check I took the rollup changes on iOS correctly, and how to set the threshold from outside the VCPTaxonomy class.
P.S: I realized that main is broken atm, so I merge this into a previous stable commit.

alexshepard and others added 30 commits October 28, 2024 13:46
from 550ms per frame to 120ms per frame on my iPhone 13 pro
This enables us to set a threshold of 0 for not filtering out any nodes at all.
When setting a taxon filter and removing it the frame processor was not removing the filter internally. This should fix that.
from 550ms per frame to 120ms per frame on my iPhone 13 pro
This enables us to set a threshold of 0 for not filtering out any nodes at all.
ios/Classifier/VCPTaxonomy.h Outdated Show resolved Hide resolved
ios/Classifier/VCPTaxonomy.m Outdated Show resolved Hide resolved
@jtklein jtklein requested a review from alexshepard November 1, 2024 21:44
Copy link
Contributor

@alexshepard alexshepard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have only reviewed the objective-c code.

I would suggest two changes:

  • move the cutoff property into the header file so you don't have to make a custom setter method - this is how we normally do things in Objective-C, instead of making our own setters and getters,
  • add time to process CV frames to the response so that could can either log it or do something more clever on the react side of things.

@jtklein jtklein merged commit 643cd9a into 4.0.5-stable Nov 20, 2024
@jtklein jtklein deleted the taxonomy-rollup-cutoff-2 branch November 20, 2024 11:22
@jtklein jtklein restored the taxonomy-rollup-cutoff-2 branch November 20, 2024 11:22
jtklein added a commit that referenced this pull request Nov 20, 2024
* Update Podfile.lock

* Taxonomy rollup cutoff with a threshold (#37)

* apply a cutoff before taxonomy cutoff

from 550ms per frame to 120ms per frame on my iPhone 13 pro

* On Android Implement taxonomy rollup only for nodes with wanted scores

* Expose taxonomy cutoff threshold to JS side

* Destructure taxonomyRollupCutoff out of options

* Update VCPTaxonomy.m

* Set taxonomy rollup cutoff value from plugin

* Update comment

* Stub for option validation

* Include node also if exactly on the threshold score

This enables us to set a threshold of 0 for not filtering out any nodes at all.

* Default threshold to 0 on iOS

* Comments

* Also attach options to the stored result

* Log number of nodes that are in the final aggregated set

* Default to 0.0 on Android

* Inclusive check of threshold on Android

* Log number of nodes in aggregate scores on Android

* Remove unnecessary null checks

* Fix bug with taxon filter on Android

When setting a taxon filter and removing it the frame processor was not removing the filter internally. This should fix that.

* Use null in example app instead of undefined as we do in Seek

* If a taxon filter is applied do not aggregate scores of filtered out nodes

Should improve cv speed on Android

* Do not include inner nodes if their summed score is 0

* apply a cutoff before taxonomy cutoff

from 550ms per frame to 120ms per frame on my iPhone 13 pro

* On Android Implement taxonomy rollup only for nodes with wanted scores

* Expose taxonomy cutoff threshold to JS side

* Destructure taxonomyRollupCutoff out of options

* Update VCPTaxonomy.m

* Set taxonomy rollup cutoff value from plugin

* Update comment

* Stub for option validation

* Include node also if exactly on the threshold score

This enables us to set a threshold of 0 for not filtering out any nodes at all.

* Default threshold to 0 on iOS

* Comments

* Also attach options to the stored result

* Log number of nodes that are in the final aggregated set

* Default to 0.0 on Android

* Inclusive check of threshold on Android

* Log number of nodes in aggregate scores on Android

* Remove unnecessary null checks

* Fix bug with taxon filter on Android

When setting a taxon filter and removing it the frame processor was not removing the filter internally. This should fix that.

* Use null in example app instead of undefined as we do in Seek

* If a taxon filter is applied do not aggregate scores of filtered out nodes

Should improve cv speed on Android

* Do not include inner nodes if their summed score is 0

* Refactor checking of option

* Fix log

* Also send back full options dict for predictions from image

* Fix comment

* Remove assert because validation happens on JS side

* Only add scores higher 0 also on iOS

* Move property taxonomyRollupCutoff to header file

* Return timeElapsed to caller

* Add timeElapsed to all possible cv results

* Add timeElapsed to result interface

---------

Co-authored-by: Alex Shepard <[email protected]>

---------

Co-authored-by: Alex Shepard <[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