-
Notifications
You must be signed in to change notification settings - Fork 41
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
``` | ||
|
@@ -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)), | ||
), | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
``` | ||
|
@@ -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()) | ||
``` | ||
|
||
|
@@ -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") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. created this ticket to fix that in automation There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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). | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation is off