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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
28 changes: 24 additions & 4 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")

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

Choose a reason for hiding this comment

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

indentation is off

}
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")
metadata, err := myMLModel.Metadata(context.Background())
```

Expand Down Expand Up @@ -206,7 +226,7 @@ Get the `ResourceName` for this instance of the ML model service with the given
**Example:**

```python {class="line-numbers linkable-line-numbers"}
my_mlmodel_svc_name = MLModelClient.get_resource_name("my_mlmodel_svc")
my_mlmodel_svc_name = my_mlmodel.get_resource_name("my_mlmodel_svc")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

created this ticket to fix that in automation

Copy link
Collaborator

Choose a reason for hiding this comment

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

why?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oh you're right it's a class method, sorry for my misunderstanding. I did look into it originally and became confused thinking this was wrong but now that I look at the python sdk docs again it is at the same level as 'FromRobot', which makes sense as to why it should not be changed. editing ticket now and will fix this here

sguequierre marked this conversation as resolved.
Show resolved Hide resolved
```

For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/services/mlmodel/client/index.html#viam.services.mlmodel.client.MLModelClient.get_resource_name).
Expand Down
Loading