Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOCS-2953: Edit mlmodel service from QA #3672

Merged
merged 5 commits into from
Nov 25, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions static/include/services/apis/generated/mlmodel.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@ import numpy as np

my_mlmodel = MLModelClient.from_robot(robot=machine, name="my_mlmodel_service")

nd_array = np.array([1, 2, 3], dtype=np.float64)
input_tensors = {"0": nd_array}
output_tensors = await my_mlmodel.infer(input_tensors)

image_data = np.zeros((1, 384, 384, 3), dtype=np.uint8)

# Create the input tensors dictionary
input_tensors = {
"image": image_data
}

output_tensors = await my_mlmodel.infer(input_tensors)
```
Expand All @@ -46,7 +52,20 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/
**Example:**

```go {class="line-numbers linkable-line-numbers"}
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")
sguequierre marked this conversation as resolved.
Show resolved Hide resolved

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)),
),
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@npentrel does this look better indentation-wise?


output_tensors, err := myMLModel.Infer(context.Background(), input_tensors)
```
Expand Down Expand Up @@ -97,6 +116,7 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/
**Example:**

```go {class="line-numbers linkable-line-numbers"}
myMLModel, err := mlmodel.FromRobot(machine, "mlmodel-1")
sguequierre marked this conversation as resolved.
Show resolved Hide resolved
metadata, err := myMLModel.Metadata(context.Background())
```

Expand Down
Loading