-
Notifications
You must be signed in to change notification settings - Fork 3
feat(modelsindex): read the model_labels from the models_index.yaml
#22
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
7 commits
Select commit
Hold shift + click to select a range
454ecb3
feat(models): add model_labels field and update test data for models
dido18 e3eec7b
refactor(tests): update model index tests for clarity and accuracy
dido18 1e19ef0
fix(tests): correct model retrieval order in TestGenerateModelsIndexF…
dido18 0dfbbc2
Update internal/orchestrator/modelsindex/modelsindex_test.go
dido18 c8cae04
refactor(tests): streamline model index test structure for clarity
dido18 e972973
refactor(tests): simplify model retrieval tests for clarity and consi…
dido18 a5bf3f4
refactor(tests): rename TestGenerateModelsIndexFromFile to TestModels…
dido18 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| package modelsindex | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/arduino/go-paths-helper" | ||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestModelsIndex(t *testing.T) { | ||
| modelsIndex, err := GenerateModelsIndexFromFile(paths.New("testdata")) | ||
| require.NoError(t, err) | ||
| require.NotNil(t, modelsIndex) | ||
|
|
||
| t.Run("it parses a valid model-list.yaml", func(t *testing.T) { | ||
| models := modelsIndex.GetModels() | ||
| assert.Len(t, models, 2, "Expected 2 models to be parsed") | ||
| }) | ||
|
|
||
| t.Run("it gets a model by ID", func(t *testing.T) { | ||
| model, found := modelsIndex.GetModelByID("not-existing-model") | ||
| assert.False(t, found) | ||
| assert.Nil(t, model) | ||
|
|
||
| model, found = modelsIndex.GetModelByID("face-detection") | ||
| assert.Equal(t, "brick", model.Runner) | ||
| require.True(t, found, "face-detection should be found") | ||
| assert.Equal(t, "face-detection", model.ID) | ||
| assert.Equal(t, "Lightweight-Face-Detection", model.Name) | ||
| assert.Equal(t, "Face bounding box detection. This model is trained on the WIDER FACE dataset and can detect faces in images.", model.ModuleDescription) | ||
| assert.Equal(t, []string{"face"}, model.ModelLabels) | ||
| assert.Equal(t, "/models/ootb/ei/lw-face-det.eim", model.ModelConfiguration["EI_OBJ_DETECTION_MODEL"]) | ||
| assert.Equal(t, []string{"arduino:object_detection", "arduino:video_object_detection"}, model.Bricks) | ||
| assert.Equal(t, "qualcomm-ai-hub", model.Metadata["source"]) | ||
| assert.Equal(t, "false", model.Metadata["ei-gpu-mode"]) | ||
| assert.Equal(t, "face-det-lite", model.Metadata["source-model-id"]) | ||
| assert.Equal(t, "https://aihub.qualcomm.com/models/face_det_lite", model.Metadata["source-model-url"]) | ||
| }) | ||
|
|
||
| t.Run("it fails if model-list.yaml does not exist", func(t *testing.T) { | ||
| nonExistentPath := paths.New("nonexistentdir") | ||
| modelsIndex, err := GenerateModelsIndexFromFile(nonExistentPath) | ||
| assert.Error(t, err) | ||
| assert.Nil(t, modelsIndex) | ||
| }) | ||
|
|
||
| t.Run("it gets models by a brick", func(t *testing.T) { | ||
| model := modelsIndex.GetModelsByBrick("not-existing-brick") | ||
| assert.Nil(t, model) | ||
|
|
||
| model = modelsIndex.GetModelsByBrick("arduino:object_detection") | ||
| assert.Len(t, model, 1) | ||
| assert.Equal(t, "face-detection", model[0].ID) | ||
| }) | ||
|
|
||
| t.Run("it gets models by bricks", func(t *testing.T) { | ||
| models := modelsIndex.GetModelsByBricks([]string{"arduino:non_existing"}) | ||
| assert.Len(t, models, 0) | ||
| assert.Nil(t, models) | ||
|
|
||
| models = modelsIndex.GetModelsByBricks([]string{"arduino:video_object_detection"}) | ||
| assert.Len(t, models, 2) | ||
| assert.Equal(t, "face-detection", models[0].ID) | ||
| assert.Equal(t, "yolox-object-detection", models[1].ID) | ||
|
|
||
| models = modelsIndex.GetModelsByBricks([]string{"arduino:object_detection", "arduino:video_object_detection"}) | ||
| assert.Len(t, models, 2) | ||
| assert.Equal(t, "face-detection", models[0].ID) | ||
| assert.Equal(t, "yolox-object-detection", models[1].ID) | ||
| }) | ||
| } | ||
111 changes: 111 additions & 0 deletions
111
internal/orchestrator/modelsindex/testdata/models-list.yaml
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,111 @@ | ||
| models: | ||
| - face-detection: | ||
| runner: brick | ||
| name : "Lightweight-Face-Detection" | ||
| description: "Face bounding box detection. This model is trained on the WIDER FACE dataset and can detect faces in images." | ||
| model_configuration: | ||
| "EI_OBJ_DETECTION_MODEL": "/models/ootb/ei/lw-face-det.eim" | ||
| model_labels: | ||
| - face | ||
| bricks: | ||
| - arduino:object_detection | ||
| - arduino:video_object_detection | ||
| metadata: | ||
| source: "qualcomm-ai-hub" | ||
| ei-gpu-mode: false | ||
| source-model-id: "face-det-lite" | ||
| source-model-url: "https://aihub.qualcomm.com/models/face_det_lite" | ||
| - yolox-object-detection: | ||
| runner: brick | ||
| name : "General purpose object detection - YoloX" | ||
| description: "General purpose object detection model based on YoloX Nano. This model is trained on the COCO dataset and can detect 80 different object classes." | ||
| model_configuration: | ||
| "EI_OBJ_DETECTION_MODEL": "/models/ootb/ei/yolo-x-nano.eim" | ||
| model_labels: | ||
| - airplane | ||
| - apple | ||
| - backpack | ||
| - banana | ||
| - baseball bat | ||
| - baseball glove | ||
| - bear | ||
| - bed | ||
| - bench | ||
| - bicycle | ||
| - bird | ||
| - boat | ||
| - book | ||
| - bottle | ||
| - bowl | ||
| - broccoli | ||
| - bus | ||
| - cake | ||
| - car | ||
| - carrot | ||
| - cat | ||
| - cell phone | ||
| - chair | ||
| - clock | ||
| - couch | ||
| - cow | ||
| - cup | ||
| - dining table | ||
| - dog | ||
| - donut | ||
| - elephant | ||
| - fire hydrant | ||
| - fork | ||
| - frisbee | ||
| - giraffe | ||
| - hair drier | ||
| - handbag | ||
| - hot dog | ||
| - horse | ||
| - keyboard | ||
| - kite | ||
| - knife | ||
| - laptop | ||
| - microwave | ||
| - motorcycle | ||
| - mouse | ||
| - orange | ||
| - oven | ||
| - parking meter | ||
| - person | ||
| - pizza | ||
| - potted plant | ||
| - refrigerator | ||
| - remote | ||
| - sandwich | ||
| - scissors | ||
| - sheep | ||
| - sink | ||
| - skateboard | ||
| - skis | ||
| - snowboard | ||
| - spoon | ||
| - sports ball | ||
| - stop sign | ||
| - suitcase | ||
| - surfboard | ||
| - teddy bear | ||
| - tennis racket | ||
| - tie | ||
| - toaster | ||
| - toilet | ||
| - toothbrush | ||
| - traffic light | ||
| - train | ||
| - truck | ||
| - tv | ||
| - umbrella | ||
| - vase | ||
| - wine glass | ||
| - zebra | ||
| metadata: | ||
| source: "edgeimpulse" | ||
| ei-project-id: 717280 | ||
| source-model-id: "YOLOX-Nano" | ||
| source-model-url: "https://github.com/Megvii-BaseDetection/YOLOX" | ||
| bricks: | ||
| - arduino:video_object_detection |
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.