A PyTorch processing support module for HERMES
Project description
HERMES - PyTorch
Support package to inject PyTorch AI models in the sensing-processing closed-loop of HERMES.
[!NOTE] In principle, any PyTorch model that runs in your existing AI workflow (e.g. on your laptop, single-board computer, server, edge device, etc.) is runnable via this wrapper.
- Classifier model wrapper, via
TorchClassifierPipeline. - Regression model wrapper.
- ...
Installation
Nodes available under the same HERMES namespace of hermes.torch, such as TorchClassifierPipeline.
[!NOTE] On Windows, sometimes Visual Studio Redistributable and Runtime are not installed, which would throw dynamic library load errors when importing
torch. Make sure to download it if you have a clean system and are running into issues importing PyTorch on your system.
From PyPI
pip install pysio-hermes-torch
From source
git clone https://github.com/maximyudayev/hermes-torch.git
pip install -e hermes-torch
Usage
Using PyTorch AI models follows the standard configuration file specification process of HERMES nodes.
- Prepare your PyTorch model in a regular workflow - design, train, and export a
.pthcheckpoint. - Provide the path in the HERMES config file to both, the checkpoint file and the module containing the
nn.Modulearchitecture. - Specify the input modalities the AI model should receive for its computations under
stream_in_specs. - Override
forwardand (optionally)load_state_dictmethods on your customnn.Moduleclass, where needed. Realtime TCN example implementation for the freezing-of-gait proof-of-concept uses internal logic for non-torch filtering and normalization, and contains non-torch object parameters: it required a method override for successful loading of the model's state dictionary from a trained checkpoint file.
[!IMPORTANT] Ensure that the state dictionary of the
.pthcan be successfully loaded into the model: provide the same model hyperparameters as the ones used to construct the model for training understream_out_spec.module_params.
[!IMPORTANT] HERMES will push data from the middleware to the model input in
process_datain an event-driven way. Samples from one or more modalities may be available in each iteration of the call. It is currently the responsibility of the user to buffer or fuse the incoming multi-modal samples within thenn.Moduleto build up receptive fields of desired function.
(Optional) Dedicated Node
You can optionally inherit from TorchClassifierPipeline, or Pipeline directly, to create a dedicated (hardcoded) Node for the target AI algorithm, similar to the HERMES extension process with support for new sensors (e.g. a TorchRegressionPipeline, TorchEmbeddingPipeline, etc., some of which are on the current development roadmap).
This will simplify the YAML file structure, especially for big models.
In that case, make sure to override the required abstract methods to enable auto-discovery and connection of the custom node to the rest of HERMES.
Citation
When using any parts of this repository outside of its intended use, please cite the parent project HERMES.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pysio_hermes_torch-0.0.1.tar.gz.
File metadata
- Download URL: pysio_hermes_torch-0.0.1.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4dbe9a6c07ef362d574b270fbbebc28298b3ae9791f22d7f8396ebb3ce2c60bb
|
|
| MD5 |
3ec858976f3b91a378059666ccc9654d
|
|
| BLAKE2b-256 |
c22caf8919c2ce9c7ed422e239b981978ec11a0ecd44b54393aeee9b77e78c88
|
File details
Details for the file pysio_hermes_torch-0.0.1-py3-none-any.whl.
File metadata
- Download URL: pysio_hermes_torch-0.0.1-py3-none-any.whl
- Upload date:
- Size: 11.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
efa9d188d40ecfbe84ef9d9c09674bc02351cab20722c3fe49d980fc59e6437e
|
|
| MD5 |
7aca0e54dd03f5091e3f1344777b5f1d
|
|
| BLAKE2b-256 |
db53f78900ea0cc0d143df6a94be9311816e3bc01b861b611106add28127eeac
|