-
Notifications
You must be signed in to change notification settings - Fork 291
Add custom models #1687
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
Add custom models #1687
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
d918862
update references in docs to 2025
samfreund e16b700
update plans for object detection model
samfreund aa50079
update documentation for object detection in 2025
samfreund 3aac868
fix broken link
samfreund 89bbdd3
update procedure for uploading custom model
samfreund 3e88185
fix lint
samfreund 0904fd6
Merge branch 'main' into main
samfreund a7aced6
Merge pull request #1 from PhotonVision/main
samfreund 56902f3
GUI changes
samfreund 57cd5b9
add object detection import handler
samfreund 0f534f4
Merge branch 'main' into main
samfreund 4be0434
writing files to the models directory
samfreund 2b5188d
Merge branch 'main' of github.com:Sam948-byte/photonvision
samfreund 35b5b00
Merge branch 'PhotonVision:main' into add-custom-models
samfreund 46f9f76
Merge pull request #2 from Sam948-byte/main
samfreund 93209ea
change docs to reflect modifications
samfreund 798854a
fix formatting
samfreund 1ecfaea
fix formatting
samfreund 8b57917
Merge branch 'add-custom-models' of github.com:Sam948-byte/photonvisi…
samfreund a542c03
more formatting fix
samfreund fab9399
preliminary GUI restructuring
samfreund eae2dbf
preliminary GUI restructuring
samfreund aa3b466
Merge branch 'add-custom-models' of github.com:Sam948-byte/photonvisi…
samfreund 892756e
finalize GUI restructuring
samfreund dfcaa5f
make it look pretty
samfreund 283afc6
Merge branch 'main' into add-custom-models
samfreund ce79463
make it look pretty
samfreund 56f7eab
Merge branch 'add-custom-models' of github.com:Sam948-byte/photonvisi…
samfreund 2712dbc
Merge branch 'add-custom-models' of github.com:Sam948-byte/photonvisi…
samfreund 4309c8c
Merge branch 'add-custom-models' of github.com:Sam948-byte/photonvisi…
samfreund f9e1986
Merge branch 'add-custom-models' of github.com:Sam948-byte/photonvisi…
samfreund f01afc8
Merge branch 'add-custom-models' of github.com:Sam948-byte/photonvisi…
samfreund f451fb2
remove mock testing models
samfreund 9eb655b
add naming convention checking
samfreund 54d22c5
add naming convention checking
samfreund b325ff3
Merge branch 'add-custom-models' of github.com:Sam948-byte/photonvisi…
samfreund 51abbc6
Merge branch 'add-custom-models' of github.com:Sam948-byte/photonvisi…
samfreund d5fa684
Merge branch 'add-custom-models' of github.com:Sam948-byte/photonvisi…
samfreund 60793c7
linting again
samfreund 7479c0c
some imports got lost in the efforts to lint
samfreund 8293427
some imports got lost in the efforts to lint
samfreund 3d37f89
Merge branch 'add-custom-models' of github.com:Sam948-byte/photonvisi…
samfreund 06156ee
Update photon-server/src/main/java/org/photonvision/server/RequestHan…
samfreund d657997
add checks of rknn files, and more info about naming convention
samfreund 8f69005
Merge branch 'main' into add-custom-models
samfreund e11f107
update name checking
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
188 changes: 188 additions & 0 deletions
188
photon-client/src/components/settings/ObjectDetectionCard.vue
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,188 @@ | ||
| <script setup lang="ts"> | ||
| import { ref, computed } from "vue"; | ||
| import axios from "axios"; | ||
| import { useStateStore } from "@/stores/StateStore"; | ||
| import { useSettingsStore } from "@/stores/settings/GeneralSettingsStore"; | ||
|
|
||
| const showObjectDetectionImportDialog = ref(false); | ||
| const importRKNNFile = ref<File | null>(null); | ||
| const importLabelsFile = ref<File | null>(null); | ||
|
|
||
| const handleObjectDetectionImport = () => { | ||
| if (importRKNNFile.value === null || importLabelsFile.value === null) return; | ||
|
|
||
| const formData = new FormData(); | ||
| formData.append("rknn", importRKNNFile.value); | ||
| formData.append("labels", importLabelsFile.value); | ||
|
|
||
| useStateStore().showSnackbarMessage({ | ||
| message: "Importing Object Detection Model...", | ||
| color: "secondary", | ||
| timeout: -1 | ||
| }); | ||
|
|
||
| axios | ||
| .post("/utils/importObjectDetectionModel", formData, { | ||
| headers: { "Content-Type": "multipart/form-data" } | ||
| }) | ||
| .then((response) => { | ||
| useStateStore().showSnackbarMessage({ | ||
| message: response.data.text || response.data, | ||
| color: "success" | ||
| }); | ||
| }) | ||
| .catch((error) => { | ||
| if (error.response) { | ||
| useStateStore().showSnackbarMessage({ | ||
| color: "error", | ||
| message: error.response.data.text || error.response.data | ||
| }); | ||
| } else if (error.request) { | ||
| useStateStore().showSnackbarMessage({ | ||
| color: "error", | ||
| message: "Error while trying to process the request! The backend didn't respond." | ||
| }); | ||
| } else { | ||
| useStateStore().showSnackbarMessage({ | ||
| color: "error", | ||
| message: "An error occurred while trying to process the request." | ||
| }); | ||
| } | ||
| }); | ||
|
|
||
| showObjectDetectionImportDialog.value = false; | ||
| importRKNNFile.value = null; | ||
| importLabelsFile.value = null; | ||
| }; | ||
|
|
||
| // Filters out models that are not supported by the current backend, and returns a flattened list. | ||
| const supportedModels = computed(() => { | ||
| const { availableModels, supportedBackends } = useSettingsStore().general; | ||
| return supportedBackends.flatMap((backend) => availableModels[backend] || []); | ||
| }); | ||
| </script> | ||
|
|
||
| <template> | ||
| <v-card dark class="mb-3" style="background-color: #006492"> | ||
| <v-card-title class="pa-6">Object Detection</v-card-title> | ||
| <div class="pa-6 pt-0"> | ||
| <v-row> | ||
| <v-col cols="12 "> | ||
| <v-btn color="secondary" @click="() => (showObjectDetectionImportDialog = true)" class="justify-center"> | ||
| <v-icon left class="open-icon"> mdi-import </v-icon> | ||
| <span class="open-label">Import New Model</span> | ||
| </v-btn> | ||
| <v-dialog | ||
| v-model="showObjectDetectionImportDialog" | ||
| width="600" | ||
| @input=" | ||
| () => { | ||
| importRKNNFile = null; | ||
| importLabelsFile = null; | ||
| } | ||
| " | ||
| > | ||
| <v-card color="primary" dark> | ||
| <v-card-title>Import New Object Detection Model</v-card-title> | ||
| <v-card-text> | ||
| Upload a new object detection model to this device that can be used in a pipeline. Naming convention | ||
| should be <code>name-verticalResolution-horizontalResolution-modelType</code>. Additionally, the labels | ||
| file ought to have the same name as the RKNN file, with <code>-labels</code> appended to the end. For | ||
| example, if the RKNN file is named <code>note-640-640-yolov5s.rknn</code>, the labels file should be | ||
| named <code>note-640-640-yolov5s-labels.txt</code>. Note that ONLY 640x640 YOLOv5 & YOLOv8 models | ||
| trained and converted to `.rknn` format for RK3588 CPUs are currently supported! | ||
| <v-row class="mt-6 ml-4 mr-8"> | ||
| <v-file-input label="RKNN File" v-model="importRKNNFile" accept=".rknn" /> | ||
| </v-row> | ||
| <v-row class="mt-6 ml-4 mr-8"> | ||
| <v-file-input label="Labels File" v-model="importLabelsFile" accept=".txt" /> | ||
| </v-row> | ||
| <v-row | ||
| class="mt-12 ml-8 mr-8 mb-1" | ||
| style="display: flex; align-items: center; justify-content: center" | ||
| align="center" | ||
| > | ||
| <v-btn | ||
| color="secondary" | ||
| :disabled="importRKNNFile === null || importLabelsFile === null" | ||
| @click="handleObjectDetectionImport" | ||
| > | ||
| <v-icon left class="open-icon"> mdi-import </v-icon> | ||
| <span class="open-label">Import Object Detection Model</span> | ||
| </v-btn> | ||
| </v-row> | ||
| </v-card-text> | ||
| </v-card> | ||
| </v-dialog> | ||
| </v-col> | ||
| </v-row> | ||
| <v-row> | ||
| <v-col cols="12"> | ||
| <v-simple-table fixed-header height="100%" dense dark> | ||
| <thead style="font-size: 1.25rem"> | ||
| <tr> | ||
| <th class="text-left">Available Models</th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| <tr v-for="model in supportedModels" :key="model"> | ||
| <td>{{ model }}</td> | ||
| </tr> | ||
| </tbody> | ||
| </v-simple-table> | ||
| </v-col> | ||
| </v-row> | ||
| </div> | ||
| </v-card> | ||
| </template> | ||
|
|
||
| <style scoped lang="scss"> | ||
| .v-btn { | ||
| width: 100%; | ||
| } | ||
| @media only screen and (max-width: 351px) { | ||
| .open-icon { | ||
| margin: 0 !important; | ||
| } | ||
| .open-label { | ||
| display: none; | ||
| } | ||
| } | ||
| .v-data-table { | ||
| width: 100%; | ||
| height: 100%; | ||
| text-align: center; | ||
| background-color: #006492 !important; | ||
|
|
||
| th, | ||
| td { | ||
| background-color: #006492 !important; | ||
| font-size: 1rem !important; | ||
| color: white !important; | ||
| } | ||
|
|
||
| td { | ||
| font-family: monospace !important; | ||
| } | ||
|
|
||
| tbody :hover td { | ||
| background-color: #005281 !important; | ||
| } | ||
|
|
||
| ::-webkit-scrollbar { | ||
| width: 0; | ||
| height: 0.55em; | ||
| border-radius: 5px; | ||
| } | ||
|
|
||
| ::-webkit-scrollbar-track { | ||
| -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3); | ||
| border-radius: 10px; | ||
| } | ||
|
|
||
| ::-webkit-scrollbar-thumb { | ||
| background-color: #ffd843; | ||
| border-radius: 10px; | ||
| } | ||
| } | ||
| </style> |
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
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.