-
Notifications
You must be signed in to change notification settings - Fork 2
Share the generic parts of a node #94
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
Merged
Merged
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
d00d97c
Add AGENTS.md and re-sync the shared CONTRIBUTING block
klangenk 2456d63
Improve AGENTS.md
klangenk a004efe
Keep AGENTS.md free of private repository names
klangenk 7747813
Share detector postprocessing across nodes
klangenk fa8505c
Share the node entry point boilerplate
klangenk f3b3ca9
Share the framework-agnostic parts of a trainer
klangenk 13c7793
Resolve a disagreeing environment variable instead of giving up
klangenk 8e402d6
Document what a disagreeing alias resolves to
klangenk d358da5
Move the category lookups out of postprocess
klangenk d4009f2
Merge remote-tracking branch 'origin/main' into share-generic-node-code
klangenk e19e448
Use a generic prefix in the legacy_env_prefix example
klangenk b73af70
Put the public functions first in the two moved modules
klangenk dd582ce
Log through the module logger, not the root one
klangenk c638660
Read a renamed setting under the name its prefix actually gave it
klangenk 943959a
Carry main's improvements to the moved files into the library copies
klangenk 8641a8a
Apply the conventions review to the code this branch adds
jfrieli 915bedb
Refactor docstring in postprocess.py to simplify and clarify the purp…
jfrieli 75208ba
Drop the centre-anchored clipping helper
klangenk b8e9294
Share the trainer's GPU memory budgeting
klangenk f2f4c82
Remove the pointer to a guide that does not exist
klangenk 944c64a
Spawn the iterator process explicitly, on every platform
klangenk 4ae56a5
Resolve uploaded categories through the shared lookup
klangenk f167834
Test the unit suite on every supported Python version
klangenk f40ee9f
Name the model's output Prediction, and round its corners once
klangenk 74b914f
Run every suite on both ends of the supported range
klangenk 4dfe4de
Share the torch side of a batch-size probe, not just the search
klangenk d9068a9
Put the callers first, and cut the prose to what the code cannot say
klangenk 6ad79cf
Run the slow suites on the version the nodes actually ship
klangenk a01534e
Release the probe's margin on every exit, and log the bound the searc…
jfrieli ada6161
Gate the branch on one check name the matrix cannot change
klangenk db9b8ea
Merge remote-tracking branch 'origin/main' into share-generic-node-code
klangenk 7916d63
Merge branch 'main' into share-generic-node-code
klangenk 7eaaa53
Merge remote-tracking branch 'origin/share-generic-node-code' into sh…
klangenk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| """Resolving the class indices or names a model emits against ``ModelInformation.categories``.""" | ||
|
|
||
| from ..data_classes import Category, ModelInformation | ||
|
|
||
|
|
||
| def category_by_index(model_information: ModelInformation, index: int) -> Category: | ||
| """Resolve the category a model's class index refers to. | ||
|
|
||
| :raises ValueError: If the index is outside the model's category list. | ||
| """ | ||
| categories = model_information.categories | ||
| if not 0 <= index < len(categories): | ||
| raise ValueError( | ||
| f'category index {index} is out of range for a model with {len(categories)} categories') | ||
| return categories[index] | ||
|
|
||
|
|
||
| def category_by_name(model_information: ModelInformation, name: str) -> Category: | ||
| """Resolve a category by name, for models whose outputs are named rather than indexed. | ||
|
|
||
| :raises ValueError: If no category of that name exists. | ||
| """ | ||
| for category in model_information.categories: | ||
| if category.name == name: | ||
| return category | ||
| known = ', '.join(category.name for category in model_information.categories) | ||
| raise ValueError(f'unknown category name {name!r}; the model knows: {known}') | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| """Box and point clipping shared by every detector node. | ||
|
|
||
| The loop stores a box as its top-left corner plus a size, which is the form :func:`clip_box` | ||
| takes and produces. | ||
| """ | ||
|
|
||
|
|
||
| def clip_box( | ||
|
jfrieli marked this conversation as resolved.
|
||
| *, | ||
| x1: float, | ||
| y1: float, | ||
| width: float, | ||
| height: float, | ||
| img_width: int, | ||
| img_height: int, | ||
| ) -> tuple[int, int, int, int]: | ||
| """Clip a top-left-anchored box to the image bounds. | ||
|
|
||
| :return: The clipped ``(x1, y1, width, height)``; the size is never negative. | ||
| """ | ||
| x2 = x1 + width | ||
| y2 = y1 + height | ||
|
|
||
| clipped_x1 = round(max(0.0, x1)) | ||
| clipped_y1 = round(max(0.0, y1)) | ||
| clipped_x2 = round(min(float(img_width), x2)) | ||
| clipped_y2 = round(min(float(img_height), y2)) | ||
|
|
||
| clipped_width = max(clipped_x2 - clipped_x1, 0) | ||
| clipped_height = max(clipped_y2 - clipped_y1, 0) | ||
|
|
||
| return clipped_x1, clipped_y1, clipped_width, clipped_height | ||
|
|
||
|
|
||
| def clip_point(x: float, y: float, img_width: int, img_height: int) -> tuple[float, float]: | ||
| """Clamp a point into the image bounds.""" | ||
| x = min(max(0, x), img_width) | ||
| y = min(max(0, y), img_height) | ||
| return x, y | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.