Skip to content

Commit ad615a7

Browse files
committed
skip load check in test mode
1 parent 15dbc7e commit ad615a7

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

photon-server/src/main/java/org/photonvision/server/RequestHandler.java

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -667,35 +667,36 @@ public static void onImportObjectDetectionModelRequest(Context ctx) {
667667
ModelProperties modelProperties =
668668
new ModelProperties(modelPath, nickname, labels, width, height, family, version);
669669

670-
ObjectDetector objDetector = null;
671-
672-
try {
673-
objDetector =
674-
switch (family) {
675-
case RUBIK -> new RubikModel(modelProperties).load();
676-
case RKNN -> new RknnModel(modelProperties).load();
677-
};
678-
} catch (RuntimeException e) {
679-
ctx.status(400);
680-
ctx.result("Failed to load object detection model: " + e.getMessage());
670+
if (!testMode) {
671+
ObjectDetector objDetector = null;
681672

682673
try {
683-
Files.deleteIfExists(modelPath);
684-
} catch (IOException ex) {
685-
e.addSuppressed(ex);
686-
}
674+
objDetector =
675+
switch (family) {
676+
case RUBIK -> new RubikModel(modelProperties).load();
677+
case RKNN -> new RknnModel(modelProperties).load();
678+
};
679+
} catch (RuntimeException e) {
680+
ctx.status(400);
681+
ctx.result("Failed to load object detection model: " + e.getMessage());
687682

688-
logger.error("Failed to load object detection model", e);
689-
return;
690-
} finally {
691-
// this finally block will run regardless of what happens in try/catch
692-
// please see https://docs.oracle.com/javase/tutorial/essential/exceptions/finally.html
693-
// for a summary on how finally works
694-
if (objDetector != null) {
695-
objDetector.release();
683+
try {
684+
Files.deleteIfExists(modelPath);
685+
} catch (IOException ex) {
686+
e.addSuppressed(ex);
687+
}
688+
689+
logger.error("Failed to load object detection model", e);
690+
return;
691+
} finally {
692+
// this finally block will run regardless of what happens in try/catch
693+
// please see https://docs.oracle.com/javase/tutorial/essential/exceptions/finally.html
694+
// for a summary on how finally works
695+
if (objDetector != null) {
696+
objDetector.release();
697+
}
696698
}
697699
}
698-
699700
ConfigManager.getInstance()
700701
.getConfig()
701702
.neuralNetworkPropertyManager()

0 commit comments

Comments
 (0)