Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ ext {
javalinVersion = "5.6.2"
libcameraDriverVersion = "v2025.0.3"
rknnVersion = "dev-v2025.0.0-1-g33b6263"
rubikVersion = "v2025.1.0"
rubikVersion = "dev-v2025.1.0-8-g067a316"
frcYear = "2025"
mrcalVersion = "v2025.0.0";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ public RknnObjectDetector(RknnModel model, Size inputSize) {
if (objPointer <= 0) {
throw new RuntimeException(
"Failed to create detector from path " + model.modelFile.getPath());
} else if (!RknnJNI.isQuantized(objPointer)) {
throw new UnsupportedOperationException("Model must be quantized.");
}

logger.debug("Created detector for model " + model.modelFile.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public RubikObjectDetector(RubikModel model, Size inputSize) {
+ ". Please ensure the model is valid and compatible with the Rubik backend.");
throw new RuntimeException(
"Failed to create detector from path " + model.modelFile.getPath());
} else if (!RubikJNI.isQuantized(ptr)) {
throw new UnsupportedOperationException("Model must be quantized.");
}

logger.debug("Created detector for model " + model.modelFile.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
import org.photonvision.vision.calibration.CameraCalibrationCoefficients;
import org.photonvision.vision.camera.CameraQuirk;
import org.photonvision.vision.camera.PVCameraInfo;
import org.photonvision.vision.objects.ObjectDetector;
import org.photonvision.vision.objects.RknnModel;
import org.photonvision.vision.objects.RubikModel;
import org.photonvision.vision.processes.VisionSourceManager;
import org.zeroturnaround.zip.ZipUtil;

Expand Down Expand Up @@ -659,18 +662,38 @@ public static void onImportObjectDetectionModelRequest(Context ctx) {
modelFile.content().transferTo(out);
Comment thread
boomermath marked this conversation as resolved.
}

ModelProperties modelProperties =
new ModelProperties(
modelPath,
modelFile.filename().replaceAll("." + modelFileExtension, ""),
labels,
width,
height,
family,
version);

ObjectDetector objDetector = null;

try {
objDetector =
switch (family) {
case RUBIK -> new RubikModel(modelProperties).load();
case RKNN -> new RknnModel(modelProperties).load();
};
} catch (RuntimeException e) {
ctx.status(400);
Comment thread
boomermath marked this conversation as resolved.
ctx.result("Failed to load object detection model: " + e.getMessage());
logger.error("Failed to load object detection model", e);
} finally {
Comment thread
boomermath marked this conversation as resolved.
if (objDetector != null) {
objDetector.release();
}
}

ConfigManager.getInstance()
.getConfig()
.neuralNetworkPropertyManager()
.addModelProperties(
new ModelProperties(
modelPath,
modelFile.filename().replaceAll("." + modelFileExtension, ""),
labels,
width,
height,
family,
version));
.addModelProperties(modelProperties);

logger.debug(
ConfigManager.getInstance().getConfig().neuralNetworkPropertyManager().toString());
Expand Down
Loading