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

RSDK-9945: edits for inline docs #10

Merged
merged 3 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,14 @@ The following attributes are available to configure your module:
| `model_path` | string | **Required** | | Path to **standalone** model file |
| `label_path` | string | Optional | | Path to file with class labels. |

### Example configuration

```json
{
"model_path": "${packages.ml_model.myMLModel}/my_model.pt",
"label_path": "${packages.ml_model.myMLModel}/labels.txt"
}
```


# Methods
Expand Down
8 changes: 5 additions & 3 deletions meta.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"module_id": "viam:torch-cpu",
"visibility": "public",
"url": "https://github.com/viam-labs/torch",
"url": "https://github.com/viam-modules/torch",
"description": "Viam ML Module service serving PyTorch models.",
"models": [
{
"api": "rdk:service:mlmodel",
"model": "viam:mlmodel:torch-cpu"
"model": "viam:mlmodel:torch-cpu",
"markdown_link": "README.md#example-configuration",
"short_description": "An ML Model Service that can run PyTorch models in a standard format"
}
],
"build": {
Expand All @@ -19,4 +21,4 @@
]
},
"entrypoint": "dist/main"
}
}

Choose a reason for hiding this comment

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

👍 Hooray, having POSIX-compliant newlines at the end of files! I believe @Rob1in's IDE is configured to put them in from now on, at which point we should have fewer of these spurious diffs.

1 change: 0 additions & 1 deletion src/test_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,3 @@ def test_infer_method(self):

if __name__ == "__main__":
unittest.main()

13 changes: 11 additions & 2 deletions src/torch_mlmodel_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ def get_attribute_from_config(attribute_name: str, default, of_type=None):
self._metadata = self.inspector.find_metadata(label_file)

async def infer(
self, input_tensors: Dict[str, NDArray], *, timeout: Optional[float]
self,
input_tensors: Dict[str, NDArray],
*,
extra: Optional[Mapping[str, ValueTypes]],
timeout: Optional[float],
) -> Dict[str, NDArray]:
"""Take an already ordered input tensor as an array,
make an inference on the model, and return an output tensor map.
Expand All @@ -110,7 +114,12 @@ async def infer(
"""
return self.torch_model.infer(input_tensors)

async def metadata(self, *, timeout: Optional[float]) -> Metadata:
async def metadata(
self,
*,
extra: Optional[Mapping[str, ValueTypes]],
timeout: Optional[float],
) -> Metadata:
"""Get the metadata (such as name, type, expected tensor/array shape,
inputs, and outputs) associated with the ML model.

Expand Down