API fix + try with resources (close file stream + buffered)
Signed-off-by: Alex Black <blacka101@gmail.com>master
parent
2e52f0217f
commit
3f49d646fc
|
@ -54,7 +54,11 @@ public class ModelGuesser {
|
||||||
* @return the loaded normalizer
|
* @return the loaded normalizer
|
||||||
*/
|
*/
|
||||||
public static Normalizer<?> loadNormalizer(String path) {
|
public static Normalizer<?> loadNormalizer(String path) {
|
||||||
|
try {
|
||||||
return ModelSerializer.restoreNormalizerFromFile(new File(path));
|
return ModelSerializer.restoreNormalizerFromFile(new File(path));
|
||||||
|
} catch (IOException e){
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -218,7 +218,9 @@ public class ModelSerializer {
|
||||||
*/
|
*/
|
||||||
public static MultiLayerNetwork restoreMultiLayerNetwork(@NonNull File file, boolean loadUpdater)
|
public static MultiLayerNetwork restoreMultiLayerNetwork(@NonNull File file, boolean loadUpdater)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
return restoreMultiLayerNetwork(new FileInputStream(file), loadUpdater);
|
try(InputStream is = new BufferedInputStream(new FileInputStream(file))){
|
||||||
|
return restoreMultiLayerNetwork(is, loadUpdater);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue