29
29
import java .nio .charset .StandardCharsets ;
30
30
import java .security .ProtectionDomain ;
31
31
import java .util .ArrayList ;
32
- import java .util .Arrays ;
33
32
import java .util .HashMap ;
34
33
import java .util .LinkedHashMap ;
35
34
import java .util .LinkedList ;
58
57
import io .bioimage .modelrunner .tensor .Tensor ;
59
58
import io .bioimage .modelrunner .tensor .shm .SharedMemoryArray ;
60
59
import io .bioimage .modelrunner .utils .CommonUtils ;
61
- import net .imglib2 .Cursor ;
62
60
import net .imglib2 .RandomAccessibleInterval ;
63
61
import net .imglib2 .type .NativeType ;
64
62
import net .imglib2 .type .numeric .RealType ;
65
63
import net .imglib2 .util .Cast ;
66
64
import net .imglib2 .util .Util ;
67
- import net .imglib2 .view .Views ;
68
65
69
66
/**
70
67
* This class implements an interface that allows the main plugin to interact in
@@ -190,11 +187,11 @@ private void launchModelLoadOnProcess() throws IOException, InterruptedException
190
187
if (task .status == TaskStatus .CANCELED )
191
188
throw new RuntimeException ();
192
189
else if (task .status == TaskStatus .FAILED )
193
- throw new RuntimeException ();
190
+ throw new RuntimeException (task . error );
194
191
else if (task .status == TaskStatus .CRASHED ) {
195
192
this .runner .close ();
196
193
runner = null ;
197
- throw new RuntimeException ();
194
+ throw new RuntimeException (task . error );
198
195
}
199
196
}
200
197
@@ -245,7 +242,6 @@ protected void runFromShmas(List<String> inputs, List<String> outputs) throws IO
245
242
IValueVector inputsVector = new IValueVector ();
246
243
for (String ee : inputs ) {
247
244
Map <String , Object > decoded = Types .decode (ee );
248
- System .out .println ("MM: -> " + ee );
249
245
SharedMemoryArray shma = SharedMemoryArray .read ((String ) decoded .get (MEM_NAME_KEY ));
250
246
org .bytedeco .pytorch .Tensor inT = TensorBuilder .build (shma );
251
247
inputsVector .put (new IValue (inT ));
@@ -310,7 +306,7 @@ else if (task.status == TaskStatus.FAILED)
310
306
else if (task .status == TaskStatus .CRASHED ) {
311
307
this .runner .close ();
312
308
runner = null ;
313
- throw new RuntimeException ();
309
+ throw new RuntimeException (task . error );
314
310
}
315
311
for (int i = 0 ; i < outputTensors .size (); i ++) {
316
312
String name = (String ) Types .decode (encOuts .get (i )).get (MEM_NAME_KEY );
@@ -321,30 +317,7 @@ else if (task.status == TaskStatus.CRASHED) {
321
317
shmaOutputList .add (shm );
322
318
}
323
319
RandomAccessibleInterval <T > rai = shm .getSharedRAI ();
324
- System .out .println ("Output size: " + Arrays .toString (rai .dimensionsAsLongArray ()));
325
- // TODO remove
326
- double max0 = 0 ;
327
- Cursor <T > iter0 = Views .iterable (rai ).cursor ();
328
- while (iter0 .hasNext ()) {
329
- iter0 .next ();
330
- double doub = iter0 .get ().getRealDouble ();
331
- if (doub > max0 )
332
- max0 = doub ;
333
- }
334
- System .out .println ("Output SHM " + i + " max value: " + max0 );
335
- // TODO remove
336
320
outputTensors .get (i ).setData (Tensor .createCopyOfRaiInWantedDataType (Cast .unchecked (rai ), Util .getTypeFromInterval (Cast .unchecked (rai ))));
337
- // TODO remove
338
- double max = 0 ;
339
- Cursor <R > iter = Views .iterable (outputTensors .get (i ).getData ()).cursor ();
340
- while (iter .hasNext ()) {
341
- iter .next ();
342
- double doub = iter .get ().getRealDouble ();
343
- if (doub > max )
344
- max = doub ;
345
- }
346
- System .out .println ("Copied ouput " + i + " max value: " + max );
347
- // TODO remove
348
321
}
349
322
} catch (Exception e ) {
350
323
closeShmas ();
@@ -385,11 +358,11 @@ public void closeModel() {
385
358
if (task .status == TaskStatus .CANCELED )
386
359
throw new RuntimeException ();
387
360
else if (task .status == TaskStatus .FAILED )
388
- throw new RuntimeException ();
361
+ throw new RuntimeException (task . error );
389
362
else if (task .status == TaskStatus .CRASHED ) {
390
363
this .runner .close ();
391
364
runner = null ;
392
- throw new RuntimeException ();
365
+ throw new RuntimeException (task . error );
393
366
}
394
367
this .runner .close ();
395
368
this .runner = null ;
@@ -432,16 +405,6 @@ private <T extends RealType<T> & NativeType<T>> List<String> encodeInputs(List<T
432
405
List <String > encodedInputTensors = new ArrayList <String >();
433
406
Gson gson = new Gson ();
434
407
for (Tensor <T > tt : inputTensors ) {
435
- System .out .println ("Input size: " + Arrays .toString (tt .getData ().dimensionsAsLongArray ()));
436
- double max0 = 0 ;
437
- Cursor <T > iter0 = Views .iterable (tt .getData ()).cursor ();
438
- while (iter0 .hasNext ()) {
439
- iter0 .next ();
440
- double doub = iter0 .get ().getRealDouble ();
441
- if (doub > max0 )
442
- max0 = doub ;
443
- }
444
- System .out .println ("Input max: " + max0 );
445
408
SharedMemoryArray shma = SharedMemoryArray .createSHMAFromRAI (tt .getData (), false , true );
446
409
shmaInputList .add (shma );
447
410
HashMap <String , Object > map = new HashMap <String , Object >();
0 commit comments