From 1fdb05d6b5c97371652341d5c5a15d59b5e23426 Mon Sep 17 00:00:00 2001 From: Sierra Guequierre Date: Wed, 13 Nov 2024 10:43:22 -0500 Subject: [PATCH 1/3] improve infer and metadata examples --- services/mlmodel/mlmodel.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/services/mlmodel/mlmodel.go b/services/mlmodel/mlmodel.go index 6c53758ace3..59db4da0df2 100644 --- a/services/mlmodel/mlmodel.go +++ b/services/mlmodel/mlmodel.go @@ -35,12 +35,26 @@ func init() { // // Infer example: // -// input_tensors := ml.Tensors{"0": tensor.New(tensor.WithShape(1, 2, 3), tensor.WithBacking([]int{1, 2, 3, 4, 5, 6}))} +// import ( +// "go.viam.com/rdk/ml" +// "gorgonia.org/tensor" +// ) +// +// myMLModel, err := mlmodel.FromRobot(machine, "mlmodel-1") +// +// input_tensors := ml.Tensors{ +// "image": tensor.New( +// tensor.Of(tensor.Uint8), +// tensor.WithShape(1, 384, 384, 3), +// tensor.WithBacking(make([]uint8, 1*384*384*3)), +// ), +// } // // output_tensors, err := myMLModel.Infer(context.Background(), input_tensors) // // Metadata example: // +// myMLModel, err := mlmodel.FromRobot(machine, "mlmodel-1") // metadata, err := myMLModel.Metadata(context.Background()) // // [ML model service docs]: https://docs.viam.com/services/ml/deploy/ From 843603ce3f5c38717f57b026a839068d751127e4 Mon Sep 17 00:00:00 2001 From: Sierra Guequierre Date: Wed, 13 Nov 2024 10:45:53 -0500 Subject: [PATCH 2/3] Update services/mlmodel/mlmodel.go --- services/mlmodel/mlmodel.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/mlmodel/mlmodel.go b/services/mlmodel/mlmodel.go index 59db4da0df2..fd2de1bc7e3 100644 --- a/services/mlmodel/mlmodel.go +++ b/services/mlmodel/mlmodel.go @@ -46,7 +46,7 @@ func init() { // "image": tensor.New( // tensor.Of(tensor.Uint8), // tensor.WithShape(1, 384, 384, 3), -// tensor.WithBacking(make([]uint8, 1*384*384*3)), +// tensor.WithBacking(make([]uint8, 1*384*384*3)), // ), // } // From ba764d424a778e3a260d738726e38d5e1a18d3d2 Mon Sep 17 00:00:00 2001 From: Sierra Guequierre Date: Mon, 25 Nov 2024 12:09:16 -0500 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Naomi Pentrel <5212232+npentrel@users.noreply.github.com> --- services/mlmodel/mlmodel.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/mlmodel/mlmodel.go b/services/mlmodel/mlmodel.go index fd2de1bc7e3..7b5562174c3 100644 --- a/services/mlmodel/mlmodel.go +++ b/services/mlmodel/mlmodel.go @@ -40,7 +40,7 @@ func init() { // "gorgonia.org/tensor" // ) // -// myMLModel, err := mlmodel.FromRobot(machine, "mlmodel-1") +// myMLModel, err := mlmodel.FromRobot(machine, "my_mlmodel") // // input_tensors := ml.Tensors{ // "image": tensor.New( @@ -54,7 +54,7 @@ func init() { // // Metadata example: // -// myMLModel, err := mlmodel.FromRobot(machine, "mlmodel-1") +// myMLModel, err := mlmodel.FromRobot(machine, "my_mlmodel") // metadata, err := myMLModel.Metadata(context.Background()) // // [ML model service docs]: https://docs.viam.com/services/ml/deploy/