Skip to content
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

Yolo duplication fix #1713

Merged
merged 78 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
d918862
update references in docs to 2025
Sam948-byte Jan 6, 2025
e16b700
update plans for object detection model
Sam948-byte Jan 6, 2025
aa50079
update documentation for object detection in 2025
Sam948-byte Jan 6, 2025
3aac868
fix broken link
Sam948-byte Jan 6, 2025
89bbdd3
update procedure for uploading custom model
Sam948-byte Jan 6, 2025
3e88185
fix lint
Sam948-byte Jan 7, 2025
0904fd6
Merge branch 'main' into main
Sam948-byte Jan 7, 2025
a7aced6
Merge pull request #1 from PhotonVision/main
Sam948-byte Jan 7, 2025
56902f3
GUI changes
Sam948-byte Jan 7, 2025
57cd5b9
add object detection import handler
Sam948-byte Jan 7, 2025
0f534f4
Merge branch 'main' into main
Sam948-byte Jan 7, 2025
4be0434
writing files to the models directory
Sam948-byte Jan 7, 2025
2b5188d
Merge branch 'main' of github.com:Sam948-byte/photonvision
Sam948-byte Jan 7, 2025
35b5b00
Merge branch 'PhotonVision:main' into add-custom-models
Sam948-byte Jan 7, 2025
46f9f76
Merge pull request #2 from Sam948-byte/main
Sam948-byte Jan 7, 2025
93209ea
change docs to reflect modifications
Sam948-byte Jan 7, 2025
798854a
fix formatting
Sam948-byte Jan 7, 2025
1ecfaea
fix formatting
Sam948-byte Jan 7, 2025
8b57917
Merge branch 'add-custom-models' of github.com:Sam948-byte/photonvisi…
Sam948-byte Jan 7, 2025
a542c03
more formatting fix
Sam948-byte Jan 7, 2025
fab9399
preliminary GUI restructuring
Sam948-byte Jan 7, 2025
eae2dbf
preliminary GUI restructuring
Sam948-byte Jan 7, 2025
aa3b466
Merge branch 'add-custom-models' of github.com:Sam948-byte/photonvisi…
Sam948-byte Jan 7, 2025
892756e
finalize GUI restructuring
Sam948-byte Jan 7, 2025
dfcaa5f
make it look pretty
Sam948-byte Jan 7, 2025
283afc6
Merge branch 'main' into add-custom-models
Sam948-byte Jan 7, 2025
ce79463
make it look pretty
Sam948-byte Jan 7, 2025
56f7eab
Merge branch 'add-custom-models' of github.com:Sam948-byte/photonvisi…
Sam948-byte Jan 7, 2025
2712dbc
Merge branch 'add-custom-models' of github.com:Sam948-byte/photonvisi…
Sam948-byte Jan 7, 2025
4309c8c
Merge branch 'add-custom-models' of github.com:Sam948-byte/photonvisi…
Sam948-byte Jan 7, 2025
f9e1986
Merge branch 'add-custom-models' of github.com:Sam948-byte/photonvisi…
Sam948-byte Jan 7, 2025
f01afc8
Merge branch 'add-custom-models' of github.com:Sam948-byte/photonvisi…
Sam948-byte Jan 7, 2025
f451fb2
remove mock testing models
Sam948-byte Jan 7, 2025
9eb655b
add naming convention checking
Sam948-byte Jan 7, 2025
54d22c5
add naming convention checking
Sam948-byte Jan 7, 2025
b325ff3
Merge branch 'add-custom-models' of github.com:Sam948-byte/photonvisi…
Sam948-byte Jan 7, 2025
51abbc6
Merge branch 'add-custom-models' of github.com:Sam948-byte/photonvisi…
Sam948-byte Jan 7, 2025
d5fa684
Merge branch 'add-custom-models' of github.com:Sam948-byte/photonvisi…
Sam948-byte Jan 8, 2025
60793c7
linting again
Sam948-byte Jan 8, 2025
7479c0c
some imports got lost in the efforts to lint
Sam948-byte Jan 8, 2025
8293427
some imports got lost in the efforts to lint
Sam948-byte Jan 8, 2025
3d37f89
Merge branch 'add-custom-models' of github.com:Sam948-byte/photonvisi…
Sam948-byte Jan 8, 2025
75ca415
delete button
Sam948-byte Jan 8, 2025
5e7f3b4
backend implementation
Sam948-byte Jan 8, 2025
f3ad102
add editing as well, not working yet
Sam948-byte Jan 8, 2025
06156ee
Update photon-server/src/main/java/org/photonvision/server/RequestHan…
Sam948-byte Jan 8, 2025
d657997
add checks of rknn files, and more info about naming convention
Sam948-byte Jan 8, 2025
8f69005
Merge branch 'main' into add-custom-models
Sam948-byte Jan 8, 2025
6b43e2c
Merge pull request #3 from Sam948-byte/add-custom-models
Sam948-byte Jan 8, 2025
6b960e8
add delete confirmation
Sam948-byte Jan 8, 2025
e11f107
update name checking
Sam948-byte Jan 8, 2025
7e54d55
Merge pull request #4 from Sam948-byte/add-custom-models
Sam948-byte Jan 8, 2025
5f289a9
move logic to neuralNetworkManager
Sam948-byte Jan 8, 2025
1e2cc86
formatting and
Sam948-byte Jan 8, 2025
4368ef6
Merge branch 'main' into main
Sam948-byte Jan 8, 2025
0f52b25
formatting 2 electric boogaloo
Sam948-byte Jan 8, 2025
63f1ecb
formatting 2 electric boogaloo
Sam948-byte Jan 8, 2025
167e052
Merge branch 'main' of github.com:Sam948-byte/photonvision
Sam948-byte Jan 8, 2025
23c2c10
Merge branch 'main' into main
Sam948-byte Jan 9, 2025
9d88f3d
note
Sam948-byte Jan 10, 2025
2fd0253
rediscover button
Sam948-byte Jan 10, 2025
73f21ef
formatting
Sam948-byte Jan 10, 2025
a8c0acc
Revert "rediscover button"
Sam948-byte Jan 10, 2025
23196c8
Merge branch 'PhotonVision:main' into main
Sam948-byte Jan 12, 2025
85daeef
Merge branch 'PhotonVision:main' into main
Sam948-byte Jan 12, 2025
0d5d160
Merge branch 'PhotonVision:main' into main
Sam948-byte Jan 12, 2025
3d5f2ad
duplication fix
Sam948-byte Jan 12, 2025
a95c531
clean it up
Sam948-byte Jan 12, 2025
c4d67fb
Update Server.java
Sam948-byte Jan 12, 2025
96381e7
same thing, different branch
Sam948-byte Jan 12, 2025
b692ffa
it'll work
Sam948-byte Jan 12, 2025
9354864
it'll work
Sam948-byte Jan 12, 2025
3870263
Merge branch 'yolo-duplication-fix' of github.com:Sam948-byte/photonv…
Sam948-byte Jan 12, 2025
8cd1a2a
Merge branch 'yolo-duplication-fix' of github.com:Sam948-byte/photonv…
Sam948-byte Jan 12, 2025
850046b
integrate clear into discoverModels
Sam948-byte Jan 12, 2025
0e226cd
Merge branch 'main' into yolo-duplication-fix
Sam948-byte Jan 12, 2025
62a1183
Merge branch 'main' into yolo-duplication-fix
gerth2 Jan 12, 2025
0c1e882
fix it up
Sam948-byte Jan 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions photon-client/src/components/settings/ObjectDetectionCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import axios from "axios";
import { useStateStore } from "@/stores/StateStore";
import { useSettingsStore } from "@/stores/settings/GeneralSettingsStore";

const showObjectDetectionImportDialog = ref(false);
const showImportDialog = ref(false);
const importRKNNFile = ref<File | null>(null);
const importLabelsFile = ref<File | null>(null);

const handleObjectDetectionImport = () => {
// TODO gray out the button when model is uploading
const handleImport = async () => {
if (importRKNNFile.value === null || importLabelsFile.value === null) return;

const formData = new FormData();
Expand Down Expand Up @@ -50,7 +51,8 @@ const handleObjectDetectionImport = () => {
}
});

showObjectDetectionImportDialog.value = false;
showImportDialog.value = false;

importRKNNFile.value = null;
importLabelsFile.value = null;
};
Expand All @@ -68,12 +70,12 @@ const supportedModels = computed(() => {
<div class="pa-6 pt-0">
<v-row>
<v-col cols="12 ">
<v-btn color="secondary" @click="() => (showObjectDetectionImportDialog = true)" class="justify-center">
<v-btn color="secondary" @click="() => (showImportDialog = 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"
v-model="showImportDialog"
width="600"
@input="
() => {
Expand Down Expand Up @@ -105,7 +107,7 @@ const supportedModels = computed(() => {
<v-btn
color="secondary"
:disabled="importRKNNFile === null || importLabelsFile === null"
@click="handleObjectDetectionImport"
@click="handleImport"
>
<v-icon left class="open-icon"> mdi-import </v-icon>
<span class="open-label">Import Object Detection Model</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,29 +221,28 @@ private void loadModel(File model) {
/**
* Discovers DNN models from the specified folder.
*
* @param modelsFolder The folder where the models are stored
* @param modelsDirectory The folder where the models are stored
*/
public void discoverModels(File modelsFolder) {
public void discoverModels(File modelsDirectory) {
logger.info("Supported backends: " + supportedBackends);

if (!modelsFolder.exists()) {
logger.error("Models folder " + modelsFolder.getAbsolutePath() + " does not exist.");
if (!modelsDirectory.exists()) {
logger.error("Models folder " + modelsDirectory.getAbsolutePath() + " does not exist.");
return;
}

if (models == null) {
models = new HashMap<>();
}
models = new HashMap<>();

try {
Files.walk(modelsFolder.toPath())
Files.walk(modelsDirectory.toPath())
.filter(Files::isRegularFile)
.forEach(path -> loadModel(path.toFile()));
} catch (IOException e) {
logger.error("Failed to discover models at " + modelsFolder.getAbsolutePath(), e);
logger.error("Failed to discover models at " + modelsDirectory.getAbsolutePath(), e);
}

// After loading all of the models, sort them by name to ensure a consistent ordering
// After loading all of the models, sort them by name to ensure a consistent
// ordering
models.forEach(
(backend, backendModels) ->
backendModels.sort((a, b) -> a.getName().compareTo(b.getName())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
import org.photonvision.common.dataflow.DataChangeDestination;
import org.photonvision.common.dataflow.DataChangeService;
import org.photonvision.common.dataflow.events.IncomingWebSocketEvent;
import org.photonvision.common.dataflow.events.OutgoingUIEvent;
import org.photonvision.common.dataflow.networktables.NetworkTablesManager;
import org.photonvision.common.dataflow.websocket.UIPhotonConfiguration;
import org.photonvision.common.hardware.HardwareManager;
import org.photonvision.common.hardware.Platform;
import org.photonvision.common.logging.LogGroup;
Expand Down Expand Up @@ -546,7 +548,7 @@ public static void onProgramRestartRequest(Context ctx) {
restartProgram();
}

public static void onObjectDetectionModelImportRequest(Context ctx) {
public static void onImportObjectDetectionModelRequest(Context ctx) {
try {
// Retrieve the uploaded files
var modelFile = ctx.uploadedFile("rknn");
Expand Down Expand Up @@ -579,7 +581,11 @@ public static void onObjectDetectionModelImportRequest(Context ctx) {
Pattern.compile("^[a-zA-Z0-9]+-\\d+-\\d+-yolov[58][a-z]*-labels\\.txt$");

if (!modelPattern.matcher(modelFile.filename()).matches()
|| !labelsPattern.matcher(labelsFile.filename()).matches()) {
|| !labelsPattern.matcher(labelsFile.filename()).matches()
|| !(modelFile
.filename()
.substring(0, modelFile.filename().indexOf("-"))
.equals(labelsFile.filename().substring(0, labelsFile.filename().indexOf("-"))))) {
ctx.status(400);
ctx.result("The uploaded files were not named correctly.");
logger.error("The uploaded object detection model files were not named correctly.");
Expand Down Expand Up @@ -610,6 +616,12 @@ public static void onObjectDetectionModelImportRequest(Context ctx) {
} catch (Exception e) {
ctx.status(500).result("Error processing files: " + e.getMessage());
}

DataChangeService.getInstance()
.publishEvent(
new OutgoingUIEvent<>(
"fullsettings",
UIPhotonConfiguration.programStateToUi(ConfigManager.getInstance().getConfig())));
}

public static void onDeviceRestartRequest(Context ctx) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private static void start(int port) {
});
});

/*Web Socket Events for Data Exchange */
/* Web Socket Events for Data Exchange */
var dsHandler = DataSocketHandler.getInstance();
app.ws(
"/websocket_data",
Expand All @@ -112,7 +112,7 @@ private static void start(int port) {
ws.onBinaryMessage(dsHandler::onBinaryMessage);
});

/*API Events*/
/* API Events */
// Settings
app.post("/api/settings", RequestHandler::onSettingsImportRequest);
app.get("/api/settings/photonvision_config.zip", RequestHandler::onSettingsExportRequest);
Expand All @@ -129,7 +129,7 @@ private static void start(int port) {
app.post("/api/utils/offlineUpdate", RequestHandler::onOfflineUpdateRequest);
app.post(
"/api/utils/importObjectDetectionModel",
RequestHandler::onObjectDetectionModelImportRequest);
RequestHandler::onImportObjectDetectionModelRequest);
app.get("/api/utils/photonvision-journalctl.txt", RequestHandler::onLogExportRequest);
app.post("/api/utils/restartProgram", RequestHandler::onProgramRestartRequest);
app.post("/api/utils/restartDevice", RequestHandler::onDeviceRestartRequest);
Expand Down
Loading