File tree Expand file tree Collapse file tree 2 files changed +23
-12
lines changed
photon-core/src/main/java/org/photonvision/common/configuration
photon-server/src/main/java/org/photonvision/server Expand file tree Collapse file tree 2 files changed +23
-12
lines changed Original file line number Diff line number Diff line change @@ -226,8 +226,18 @@ public static NeuralNetworkModelManager getInstance() {
226
226
private static final Logger logger = new Logger (NeuralNetworkModelManager .class , LogGroup .Config );
227
227
228
228
public enum Family {
229
- RKNN ,
230
- RUBIK
229
+ RKNN (".rknn" ),
230
+ RUBIK (".tflite" );
231
+
232
+ private final String fileExtension ;
233
+
234
+ private Family (String fileExtension ) {
235
+ this .fileExtension = fileExtension ;
236
+ }
237
+
238
+ public String extension () {
239
+ return fileExtension ;
240
+ }
231
241
}
232
242
233
243
public enum Version {
@@ -358,7 +368,11 @@ public void discoverModels() {
358
368
try {
359
369
Files .walk (modelsDirectory .toPath ())
360
370
.filter (Files ::isRegularFile )
361
- .forEach (path -> loadModel (path ));
371
+ .filter (
372
+ path ->
373
+ supportedBackends .stream ()
374
+ .anyMatch (family -> path .toString ().endsWith (family .extension ())))
375
+ .forEach (this ::loadModel );
362
376
} catch (IOException e ) {
363
377
logger .error ("Failed to discover models at " + modelsDirectory .getAbsolutePath (), e );
364
378
}
Original file line number Diff line number Diff line change @@ -605,16 +605,13 @@ public static void onImportObjectDetectionModelRequest(Context ctx) {
605
605
return ;
606
606
}
607
607
608
- String modelFileExtension = "" ;
609
608
NeuralNetworkModelManager .Family family ;
610
609
611
610
switch (Platform .getCurrentPlatform ()) {
612
611
case LINUX_QCS6490 :
613
- modelFileExtension = "tflite" ;
614
612
family = NeuralNetworkModelManager .Family .RUBIK ;
615
613
break ;
616
614
case LINUX_RK3588_64 :
617
- modelFileExtension = "rknn" ;
618
615
family = NeuralNetworkModelManager .Family .RKNN ;
619
616
break ;
620
617
default :
@@ -625,19 +622,19 @@ public static void onImportObjectDetectionModelRequest(Context ctx) {
625
622
}
626
623
627
624
// If adding additional platforms, check platform matches
628
- if (!modelFile .extension ().contains (modelFileExtension )) {
625
+ if (!modelFile .extension ().contains (family . extension () )) {
629
626
ctx .status (400 );
630
627
ctx .result (
631
628
"The uploaded file was not of type '"
632
- + modelFileExtension
629
+ + family . extension ()
633
630
+ "'. The uploaded file should be a ."
634
- + modelFileExtension
631
+ + family . extension ()
635
632
+ " file." );
636
633
logger .error (
637
634
"The uploaded file was not of type '"
638
- + modelFileExtension
635
+ + family . extension ()
639
636
+ "'. The uploaded file should be a ."
640
- + modelFileExtension
637
+ + family . extension ()
641
638
+ " file." );
642
639
return ;
643
640
}
@@ -665,7 +662,7 @@ public static void onImportObjectDetectionModelRequest(Context ctx) {
665
662
.addModelProperties (
666
663
new ModelProperties (
667
664
modelPath ,
668
- modelFile .filename ().replaceAll ("." + modelFileExtension , "" ),
665
+ modelFile .filename ().replaceAll ("." + family . extension () , "" ),
669
666
labels ,
670
667
width ,
671
668
height ,
You can’t perform that action at this time.
0 commit comments