API fix + try with resources (close file stream + buffered)

Signed-off-by: Alex Black <blacka101@gmail.com>
master
Alex Black 2020-03-31 11:34:43 +11:00
parent 2e52f0217f
commit 3f49d646fc
2 changed files with 8 additions and 2 deletions

View File

@ -54,7 +54,11 @@ public class ModelGuesser {
* @return the loaded normalizer
*/
public static Normalizer<?> loadNormalizer(String path) {
return ModelSerializer.restoreNormalizerFromFile(new File(path));
try {
return ModelSerializer.restoreNormalizerFromFile(new File(path));
} catch (IOException e){
throw new RuntimeException(e);
}
}

View File

@ -218,7 +218,9 @@ public class ModelSerializer {
*/
public static MultiLayerNetwork restoreMultiLayerNetwork(@NonNull File file, boolean loadUpdater)
throws IOException {
return restoreMultiLayerNetwork(new FileInputStream(file), loadUpdater);
try(InputStream is = new BufferedInputStream(new FileInputStream(file))){
return restoreMultiLayerNetwork(is, loadUpdater);
}
}