Skip to main content

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.

  1. Prepare your PyTorch model in a regular workflow - design, train, and export a .pth checkpoint.
  2. Provide the path in the HERMES config file to both, the checkpoint file and the module containing the nn.Module architecture.
  3. Specify the input modalities the AI model should receive for its computations under stream_in_specs.
  4. Override forward and (optionally) load_state_dict methods on your custom nn.Module class, 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 .pth can be successfully loaded into the model: provide the same model hyperparameters as the ones used to construct the model for training under stream_out_spec.module_params.

[!IMPORTANT] HERMES will push data from the middleware to the model input in process_data in 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 the nn.Module to 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.

Metadata

Release files for pysio-hermes-torch 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pysio-hermes-torch 0.0.1
File Size Uploaded
pysio_hermes_torch-0.0.1.tar.gz 9.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pysio-hermes-torch 0.0.1
File Interpreter ABI Platform
pysio_hermes_torch-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 21.6 kB

Release files / pysio_hermes_torch-0.0.1.tar.gz

Download URL pysio_hermes_torch-0.0.1.tar.gz
Size 9.9 kB
Tags Source
SHA-256 checksum
How to use checksums
4dbe9a6c07ef362d574b270fbbebc28298b3ae9791f22d7f8396ebb3ce2c60bb
BLAKE2b-256 checksum
How to use checksums
c22caf8919c2ce9c7ed422e239b981978ec11a0ecd44b54393aeee9b77e78c88
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.11

Release files / pysio_hermes_torch-0.0.1-py3-none-any.whl

Download URL pysio_hermes_torch-0.0.1-py3-none-any.whl
Size 11.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
efa9d188d40ecfbe84ef9d9c09674bc02351cab20722c3fe49d980fc59e6437e
BLAKE2b-256 checksum
How to use checksums
db53f78900ea0cc0d143df6a94be9311816e3bc01b861b611106add28127eeac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.11

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page