Skip to content

Commit 93c5fad

Browse files
committed
download model within main
1 parent 1c3e7d0 commit 93c5fad

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/main/java/io/bioimage/modelrunner/pytorch/PytorchInterface.java

+11-6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
*/
2121
package io.bioimage.modelrunner.pytorch;
2222

23+
import io.bioimage.modelrunner.bioimageio.BioimageioRepo;
24+
import io.bioimage.modelrunner.bioimageio.download.DownloadTracker;
25+
import io.bioimage.modelrunner.bioimageio.download.DownloadTracker.TwoParameterConsumer;
2326
import io.bioimage.modelrunner.engine.DeepLearningEngineInterface;
2427
import io.bioimage.modelrunner.exceptions.LoadModelException;
2528
import io.bioimage.modelrunner.exceptions.RunModelException;
@@ -39,7 +42,6 @@
3942

4043
import java.io.BufferedReader;
4144
import java.io.File;
42-
import java.io.FileWriter;
4345
import java.io.IOException;
4446
import java.io.InputStreamReader;
4547
import java.io.UnsupportedEncodingException;
@@ -568,13 +570,16 @@ private static String padSpecialJavaBin(String javaBin) {
568570
* @throws LoadModelException if there is any error loading the model
569571
* @throws IOException if there is any error reading or writing any file or with the paths
570572
* @throws RunModelException if there is any error running the model
573+
* @throws InterruptedException
571574
*/
572-
public static void main(String[] args) throws LoadModelException, IOException, RunModelException {
575+
public static void main(String[] args) throws LoadModelException, IOException, RunModelException, InterruptedException {
573576
if (args.length == 0) {
574-
575-
String modelFolder = "C:\\Users\\carlos\\OneDrive\\Documentos\\pasteur\\git"
576-
+ "\\deep-icy\\models\\MitchondriaEMSegmentation2D_31102023_214027";
577-
String modelSourc = modelFolder + "\\weights-torchscript.pt";
577+
// Create an instance of the BioimageRepo object
578+
BioimageioRepo br = BioimageioRepo.connect();
579+
String aa = br.downloadByNickame("hiding-blowfish", "models");
580+
581+
String modelFolder = aa;
582+
String modelSourc = modelFolder + "/weights-torchscript.pt";
578583
PytorchInterface pi = new PytorchInterface();
579584
pi.loadModel(modelFolder, modelSourc);
580585
RandomAccessibleInterval<FloatType> rai = ArrayImgs.floats(new long[] {1, 1, 512, 512});

0 commit comments

Comments
 (0)