Skip to content

Commit

Permalink
it'll work
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam948-byte committed Jan 12, 2025
1 parent 2d19908 commit 9354864
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ public HashMap<String, ArrayList<String>> getModels() {
return modelMap;
}

public void rescanModels(File modelsDirectory) {
models = null;
discoverModels(modelsDirectory);
}

/**
* Retrieves the model with the specified name, assuming it is available under a supported
* backend.
Expand Down Expand Up @@ -243,7 +248,8 @@ public void discoverModels(File modelsFolder) {
logger.error("Failed to discover models at " + modelsFolder.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 @@ -604,7 +604,7 @@ public static void onObjectDetectionModelImportRequest(Context ctx) {
}

NeuralNetworkModelManager.getInstance()
.discoverModels(ConfigManager.getInstance().getModelsDirectory());
.rescanModels(ConfigManager.getInstance().getModelsDirectory());

ctx.status(200).result("Successfully uploaded object detection model");
} catch (Exception e) {
Expand Down

0 comments on commit 9354864

Please sign in to comment.