@@ -22,8 +22,14 @@ import numpy as np
22
22
23
23
my_mlmodel = MLModelClient.from_robot(robot = machine, name = " my_mlmodel_service" )
24
24
25
- nd_array = np.array([1 , 2 , 3 ], dtype = np.float64)
26
- input_tensors = {" 0" : nd_array}
25
+ output_tensors = await my_mlmodel.infer(input_tensors)
26
+
27
+ image_data = np.zeros((1 , 384 , 384 , 3 ), dtype = np.uint8)
28
+
29
+ # Create the input tensors dictionary
30
+ input_tensors = {
31
+ " image" : image_data
32
+ }
27
33
28
34
output_tensors = await my_mlmodel.infer(input_tensors)
29
35
```
@@ -46,7 +52,20 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/
46
52
** Example:**
47
53
48
54
``` go {class="line-numbers linkable-line-numbers"}
49
- input_tensors := ml.Tensors {" 0" : tensor.New (tensor.WithShape (1 , 2 , 3 ), tensor.WithBacking ([]int {1 , 2 , 3 , 4 , 5 , 6 }))}
55
+ import (
56
+ " go.viam.com/rdk/ml"
57
+ " gorgonia.org/tensor"
58
+ )
59
+
60
+ myMLModel , err := mlmodel.FromRobot (machine, " my_mlmodel_service" )
61
+
62
+ input_tensors := ml.Tensors {
63
+ " image" : tensor.New (
64
+ tensor.Of (tensor.Uint8 ),
65
+ tensor.WithShape (1 , 384 , 384 , 3 ),
66
+ tensor.WithBacking (make ([]uint8 , 1 *384 *384 *3 )),
67
+ ),
68
+ }
50
69
51
70
output_tensors , err := myMLModel.Infer (context.Background (), input_tensors)
52
71
```
@@ -97,6 +116,7 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/
97
116
** Example:**
98
117
99
118
``` go {class="line-numbers linkable-line-numbers"}
119
+ myMLModel , err := mlmodel.FromRobot (machine, " my_mlmodel_service" )
100
120
metadata , err := myMLModel.Metadata (context.Background ())
101
121
```
102
122
0 commit comments