@@ -24,9 +24,10 @@ First we create an "image" tensor composed entirely of pixel value [42](https://
24
24
``` scala
25
25
import java .nio .file .{Files , Paths }
26
26
import org .emergentorder .onnx .Tensors ._
27
+ import org .emergentorder .onnx .Tensors .Tensor ._
27
28
import org .emergentorder .onnx .backends ._
28
29
import org .emergentorder .compiletime ._
29
- import io .kjaer .compiletime ._
30
+ import org . emergentorder . io .kjaer .compiletime ._
30
31
31
32
val squeezenetBytes = Files .readAllBytes(Paths .get(" squeezenet1.0-12.onnx" ))
32
33
val squeezenet = new ORTModelBackend (squeezenetBytes)
@@ -57,16 +58,18 @@ val out = squeezenet.fullModel[Float,
57
58
// val out:
58
59
// Tensor[Float,("ImageNetClassification",
59
60
// "Batch" ##: "Class" ##: TSNil,
60
- // 1 #: 1000 #: SNil)] = (Array(0.8230729,
61
+ // 1 #: 1000 #: 1 #: 1 SNil)] = IO(...)
61
62
// ...
62
63
63
64
// The output shape
64
- out.shape
65
- // val res0: Array[Int] = Array(1, 1000)
65
+ out.shape.unsafeRunSync()
66
+ // val res0: Array[Int] = Array(1, 1000, 1, 1 )
66
67
68
+ val data = out.data.unsafeRunSync()
69
+ // val data: Array[Float] = Array(1.786191E-4, ...)
67
70
68
71
// The highest scoring and thus highest probability (predicted) class
69
- out. data.indices.maxBy(out. data)
72
+ data.indices.maxBy(data)
70
73
// val res1: Int = 549
71
74
```
72
75
0 commit comments