Skip to content

Commit 1702730

Browse files
committed
improve unzipping
1 parent 3f73081 commit 1702730

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

Diff for: src/main/java/io/bioimage/modelrunner/tensorflow/v2/api020/Tensorflow2Interface.java

+14-3
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,17 @@ private void unzipTfWeights(ModelDescriptor descriptor) throws LoadModelExceptio
278278
String source = descriptor.getWeights().gettAllSupportedWeightObjects().stream()
279279
.filter(ww -> ww.getFramework().equals(EngineInfo.getBioimageioTfKey()))
280280
.findFirst().get().getSource();
281-
source = DownloadModel.getFileNameFromURLString(source);
282-
System.out.println("Unzipping model...");
283-
ZipUtils.unzipFolder(modelFolder + File.separator + source, modelFolder);
281+
if (new File(source).isFile()) {
282+
System.out.println("Unzipping model...");
283+
ZipUtils.unzipFolder(new File(source).getAbsolutePath(), modelFolder);
284+
} else if (new File(modelFolder, source).isFile()) {
285+
System.out.println("Unzipping model...");
286+
ZipUtils.unzipFolder(new File(modelFolder, source).getAbsolutePath(), modelFolder);
287+
} else {
288+
source = DownloadModel.getFileNameFromURLString(source);
289+
System.out.println("Unzipping model...");
290+
ZipUtils.unzipFolder(modelFolder + File.separator + source, modelFolder);
291+
}
284292
} else {
285293
throw new LoadModelException("No model file was found in the model folder");
286294
}
@@ -498,6 +506,9 @@ public static String getModelOutputName(String outputName, int i) {
498506
* @throws RunModelException if there is any error running the model
499507
*/
500508
public static void main(String[] args) throws LoadModelException, IOException, RunModelException {
509+
Tensorflow2Interface tt = new Tensorflow2Interface(false);
510+
511+
tt.loadModel("/home/carlos/Desktop/Fiji.app/models/model_03bioimageio", null);
501512
// Unpack the args needed
502513
if (args.length < 4)
503514
throw new IllegalArgumentException("Error exectuting Tensorflow 2, "

0 commit comments

Comments
 (0)