Skip to content

Commit

Permalink
improve od pipeline error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Alextopher committed Sep 19, 2024
1 parent 2e6265e commit 8868c3b
Showing 1 changed file with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,24 @@ public ObjectDetectionPipeline(ObjectDetectionPipelineSettings settings) {

@Override
protected void setPipeParamsImpl() {
// this needs to be based off of the current backend selected!!
var params = new ObjectDetectionPipeParams();
params.confidence = settings.confidence;
params.nms = settings.nms;
Optional<Model> model = NeuralNetworkModelManager.getInstance().getModel(settings.model);
model.ifPresentOrElse(
m -> params.model = m,
() -> {
params.model =
NeuralNetworkModelManager.getInstance()
.getDefaultModel()
.orElse(NullModel.getInstance());
});
Optional<Model> selectedModel = NeuralNetworkModelManager.getInstance().getModel(settings.model);

// If the desired model couldn't be found, log an error and try to use the default model
if (selectedModel.isEmpty()) {
// logger.error("Model not found: " + settings.model + ". Trying to use default model.");
selectedModel = NeuralNetworkModelManager.getInstance().getDefaultModel();
}

// If the model remains empty, use the NullModel
if (selectedModel.isEmpty()) {
// logger.error("Default Model not found. Using empty NullModel.");
selectedModel = Optional.of(NullModel.getInstance());
}

params.model = selectedModel.get();

objectDetectorPipe.setParams(params);

Expand Down

0 comments on commit 8868c3b

Please sign in to comment.