Skip to content

Commit 65b4ed6

Browse files
committed
increase robustness sending to other process
1 parent b04a279 commit 65b4ed6

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/main/java/io/bioimage/modelrunner/pytorch/javacpp/JavaWorker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ private void executeScript(String script, Map<String, Object> inputs) {
8787
this.reportLaunch();
8888
try {
8989
if (script.equals("loadModel")) {
90-
pi.loadModel((String) inputs.get("modelFolder"), null);
90+
pi.loadModel((String) inputs.get("modelFolder"), (String) inputs.get("modelSource"));
9191
} else if (script.equals("inference")) {
9292
pi.runFromShmas((List<String>) inputs.get("inputs"), (List<String>) inputs.get("outputs"));
9393
} else if (script.equals("close")) {

src/main/java/io/bioimage/modelrunner/pytorch/javacpp/PytorchJavaCPPInterface.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ public class PytorchJavaCPPInterface implements DeepLearningEngineInterface
9494
*/
9595
private JitModule model;
9696

97+
private String modelFolder;
98+
9799
private String modelSource;
98100

99101
private boolean interprocessing = true;
@@ -157,6 +159,7 @@ private Service getRunner() throws IOException, URISyntaxException {
157159
*/
158160
@Override
159161
public void loadModel(String modelFolder, String modelSource) throws LoadModelException {
162+
this.modelFolder = modelFolder;
160163
this.modelSource = modelSource;
161164
if (interprocessing) {
162165
try {
@@ -177,7 +180,8 @@ public void loadModel(String modelFolder, String modelSource) throws LoadModelEx
177180

178181
private void launchModelLoadOnProcess() throws IOException, InterruptedException {
179182
HashMap<String, Object> args = new HashMap<String, Object>();
180-
args.put("modelFolder", this.modelSource);
183+
args.put("modelFolder", this.modelFolder);
184+
args.put("modelSource", this.modelSource);
181185
Task task = runner.task("loadModel", args);
182186
task.waitFor();
183187
if (task.status == TaskStatus.CANCELED)

0 commit comments

Comments
 (0)