-
Notifications
You must be signed in to change notification settings - Fork 14
Adding YOLOX native support #226
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
5 commits
Select commit
Hold shift + click to select a range
69f5247
Adding YOLOX native support
klemen1999 2e72763
[Automated] Updated coverage badge
actions-user 5106c6e
fix test
klemen1999 c78812c
Merge branch 'feat/yolox' of https://github.com/luxonis/tools into fe…
klemen1999 9e800f1
adding yolox-nano to representative tests
klemen1999 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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,66 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import zipfile | ||
|
|
||
| import pytest | ||
| import torch | ||
|
|
||
| from tools.utils.constants import Encoding | ||
| from tools.version_detection import YOLOX_CONVERSION, detect_version | ||
| from tools.yolox.yolox_exporter import YoloXExporter, _infer_standard_architecture | ||
|
|
||
|
|
||
| def test_detects_yolox_state_dict_checkpoint(tmp_path) -> None: | ||
| """Recognize YOLOX's state-dict markers without relying on its extension.""" | ||
| checkpoint = tmp_path / "weights.pth" | ||
| markers = ( | ||
| "backbone.backbone.stem.conv.conv backbone.lateral_conv0 " | ||
| "head.stems head.cls_convs head.reg_convs head.cls_preds " | ||
| "head.reg_preds head.obj_preds" | ||
| ) | ||
| with zipfile.ZipFile(checkpoint, "w") as archive: | ||
| archive.writestr("archive/data.pkl", markers) | ||
|
|
||
| assert detect_version(str(checkpoint)) == YOLOX_CONVERSION | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| ("head_channels", "expected"), | ||
| [ | ||
| (64, (0.33, 0.25, True)), | ||
| (96, (0.33, 0.375, False)), | ||
| (128, (0.33, 0.50, False)), | ||
| (192, (0.67, 0.75, False)), | ||
| (256, (1.00, 1.00, False)), | ||
| (320, (1.33, 1.25, False)), | ||
| ], | ||
| ) | ||
| def test_infers_standard_yolox_architecture(head_channels, expected): | ||
| state_dict = {"head.cls_preds.0.weight": torch.empty(80, head_channels, 1, 1)} | ||
|
|
||
| assert _infer_standard_architecture(state_dict) == expected | ||
|
|
||
|
|
||
| def test_yolox_exporter_uses_unscaled_bgr_preprocessing( | ||
| monkeypatch: pytest.MonkeyPatch, | ||
| ) -> None: | ||
| archive_kwargs: dict = {} | ||
|
|
||
| def record_make_nn_archive(_exporter, **kwargs) -> None: | ||
| archive_kwargs.update(kwargs) | ||
|
|
||
| monkeypatch.setattr( | ||
| YoloXExporter, | ||
| "make_nn_archive", | ||
| record_make_nn_archive, | ||
| ) | ||
|
|
||
| exporter = object.__new__(YoloXExporter) | ||
| exporter.names = ["person"] | ||
| exporter.nc = 1 | ||
|
|
||
| exporter.export_nn_archive() | ||
|
|
||
| assert archive_kwargs["encoding"] == Encoding.BGR | ||
| assert archive_kwargs["mean"] == [0, 0, 0] | ||
| assert archive_kwargs["scale"] == [1, 1, 1] |
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
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.