-
Notifications
You must be signed in to change notification settings - Fork 291
Update Allowed Naming Conventions For Object Detection Models #1749
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
32 commits
Select commit
Hold shift + click to select a range
c5dc14a
add periods and underscores to allowed characters in object detection…
samfreund 37cc78c
add periods and underscores to allowed characters in object detection…
samfreund c82ee14
idk man
samfreund 617c394
move logic to NNMhandler
samfreund 0b5e9ec
add test for names
samfreund 8f3c268
add test for names
samfreund f587308
Merge branch 'regexxxxx' of github.com:Sam948-byte/photonvision into …
samfreund df14bca
linting?
samfreund b312650
istg linting will be the death of me
samfreund afcc1d7
Update ObjectDetectionTest.java
samfreund 40e06af
Update ObjectDetectionTest.java
samfreund 11f4b91
add comment explaining regex
samfreund 87a81b5
Merge branch 'main' into regexxxxx
samfreund 8d38ffc
adjust comments and parameterize tests
samfreund 8ba9b73
formatting
samfreund 34f34fd
broken, but changing computers
samfreund 96b14f3
I think this should work
samfreund 5ace06a
rewrite tests
samfreund 7b4a073
fix tests
samfreund 604b3f4
fix tests
samfreund ea89bf0
Merge branch 'regexxxxx' of github.com:Sam948-byte/photonvision into …
samfreund 553d56d
linting
samfreund 91250c8
linting 2 eletric boogaloo
samfreund 94d1aa8
fix typo in the docs
samfreund 6fe6be0
Merge branch 'main' into regexxxxx
samfreund 93c7484
Merge branch 'main' into regexxxxx
samfreund 3705847
Merge branch 'main' into regexxxxx
samfreund 78dfefb
update regex for 11
samfreund 9fe0dec
linting
samfreund 2f56cc4
docs update
samfreund f9c0dc2
linting
samfreund 5675369
add x support for yolo size
samfreund 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
134 changes: 134 additions & 0 deletions
134
photon-core/src/test/java/org/photonvision/vision/pipeline/ObjectDetectionTest.java
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,134 @@ | ||
| /* | ||
| * Copyright (C) Photon Vision. | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| package org.photonvision.vision.pipeline; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertArrayEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
|
||
| import java.util.LinkedList; | ||
| import java.util.stream.Stream; | ||
| import org.junit.jupiter.params.ParameterizedTest; | ||
| import org.junit.jupiter.params.provider.Arguments; | ||
| import org.junit.jupiter.params.provider.MethodSource; | ||
| import org.photonvision.common.configuration.NeuralNetworkModelManager; | ||
|
|
||
| public class ObjectDetectionTest { | ||
| private static LinkedList<String[]> passNames = | ||
| new LinkedList<String[]>( | ||
| java.util.Arrays.asList( | ||
| new String[] {"note-640-640-yolov5s.rknn", "note-640-640-yolov5s-labels.txt"}, | ||
| new String[] {"object-640-640-yolov8n.rknn", "object-640-640-yolov8n-labels.txt"}, | ||
| new String[] { | ||
| "example_1.2-640-640-yolov5l.rknn", "example_1.2-640-640-yolov5l-labels.txt" | ||
| }, | ||
| new String[] {"demo_3.5-640-640-yolov8m.rknn", "demo_3.5-640-640-yolov8m-labels.txt"}, | ||
| new String[] {"sample-640-640-yolov5x.rknn", "sample-640-640-yolov5x-labels.txt"}, | ||
| new String[] { | ||
| "test_case-640-640-yolov8s.rknn", "test_case-640-640-yolov8s-labels.txt" | ||
| }, | ||
| new String[] { | ||
| "model_ABC-640-640-yolov5n.rknn", "model_ABC-640-640-yolov5n-labels.txt" | ||
| }, | ||
| new String[] {"my_model-640-640-yolov8x.rknn", "my_model-640-640-yolov8x-labels.txt"}, | ||
| new String[] {"name_1.0-640-640-yolov5n.rknn", "name_1.0-640-640-yolov5n-labels.txt"}, | ||
| new String[] { | ||
| "valid_name-640-640-yolov8s.rknn", "valid_name-640-640-yolov8s-labels.txt" | ||
| }, | ||
| new String[] { | ||
| "test.model-640-640-yolov5l.rknn", "test.model-640-640-yolov5l-labels.txt" | ||
| }, | ||
| new String[] { | ||
| "case1_test-640-640-yolov8m.rknn", "case1_test-640-640-yolov8m-labels.txt" | ||
| }, | ||
| new String[] {"A123-640-640-yolov5x.rknn", "A123-640-640-yolov5x-labels.txt"}, | ||
| new String[] { | ||
| "z_y_test.model-640-640-yolov8n.rknn", "z_y_test.model-640-640-yolov8n-labels.txt" | ||
| })); | ||
| private static LinkedList<String[]> parsedPassNames = | ||
| new LinkedList<String[]>( | ||
| java.util.Arrays.asList( | ||
| new String[] {"note", "640", "640", "yolov5s"}, | ||
| new String[] {"object", "640", "640", "yolov8n"}, | ||
| new String[] {"example_1.2", "640", "640", "yolov5l"}, | ||
| new String[] {"demo_3.5", "640", "640", "yolov8m"}, | ||
| new String[] {"sample", "640", "640", "yolov5x"}, | ||
| new String[] {"test_case", "640", "640", "yolov8s"}, | ||
| new String[] {"model_ABC", "640", "640", "yolov5n"}, | ||
| new String[] {"my_model", "640", "640", "yolov8x"}, | ||
| new String[] {"name_1.0", "640", "640", "yolov5n"}, | ||
| new String[] {"valid_name", "640", "640", "yolov8s"}, | ||
| new String[] {"test.model", "640", "640", "yolov5l"}, | ||
| new String[] {"case1_test", "640", "640", "yolov8m"}, | ||
| new String[] {"A123", "640", "640", "yolov5x"}, | ||
| new String[] {"z_y_test.model", "640", "640", "yolov8n"})); | ||
| private static LinkedList<String[]> failNames = | ||
| new LinkedList<String[]>( | ||
| java.util.Arrays.asList( | ||
| new String[] {"note-yolov5s.rknn", "note-640-640-yolov5s-labels.txt"}, | ||
| new String[] {"640-640-yolov8n.rknn", "object-640-640-yolov8n-labels.txt"}, | ||
| new String[] {"example_1.2.rknn", "example_1.2-640-640-yolov5l-labels.txt"}, | ||
| new String[] {"demo_3.5-640-yolov8m.rknn", "demo_3.5-640-640-yolov8m-labels.txt"}, | ||
| new String[] {"sample-640.rknn", "sample-640-640-yolov5x-labels.txt"}, | ||
| new String[] {"test_case.txt", "test_case-640-640-yolov8s-labels.txt"}, | ||
| new String[] {"model_ABC.onnx", "model_ABC-640-640-yolov5n-labels.txt"}, | ||
| new String[] {"my_model", "my_model-640-640-yolov8x-labels.txt"}, | ||
| new String[] {"name_1.0-yolov5n.rknn", "wrong-labels.txt"}, | ||
| new String[] {"", "valid_name-640-640-yolov8s-labels.txt"}, | ||
| new String[] {null, "test.model-640-640-yolov5l-labels.txt"}, | ||
| new String[] {"case1_test-640-640-yolov8m.rknn", null}, | ||
| new String[] {"A123-640-640.rknn", "different-labels.txt"}, | ||
| new String[] {"z_y_test.model", ""})); | ||
|
|
||
| // Test the model name validation for names that ought to pass | ||
| @ParameterizedTest | ||
| @MethodSource("verifyPassNameProvider") | ||
| public void testRKNNVerificationPass(String[] names) { | ||
| NeuralNetworkModelManager.verifyRKNNNames(names[0], names[1]); | ||
| } | ||
|
|
||
| // // Test the model name validation for names that ought to fail | ||
| @ParameterizedTest | ||
| @MethodSource("verifyFailNameProvider") | ||
| public void testRNNVerificationFail(String[] names) { | ||
| assertThrows( | ||
| IllegalArgumentException.class, | ||
| () -> NeuralNetworkModelManager.verifyRKNNNames(names[0], names[1])); | ||
| } | ||
|
|
||
| // Test the model name parsing | ||
| @ParameterizedTest | ||
| @MethodSource("parseNameProvider") | ||
| public void testRKNNNameParsing(String[] expected, String name) { | ||
| String[] parsed = NeuralNetworkModelManager.parseRKNNName(name); | ||
mcm001 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| assertArrayEquals(expected, parsed); | ||
| } | ||
|
|
||
| static Stream<Arguments> verifyPassNameProvider() { | ||
| return passNames.stream().map(array -> Arguments.of((Object) array)); | ||
| } | ||
|
|
||
| static Stream<Arguments> verifyFailNameProvider() { | ||
| return failNames.stream().map(array -> Arguments.of((Object) array)); | ||
| } | ||
|
|
||
| static Stream<Arguments> parseNameProvider() { | ||
| // return a stream of parsed pass names, and the first element of each pass name | ||
| return passNames.stream() | ||
| .map(name -> Arguments.of(parsedPassNames.get(passNames.indexOf(name)), name[0])); | ||
| } | ||
| } | ||
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.
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.