Skip to main content

Sinapsis tool to convert models from one framework to another and can be used in AOT and JIT modes

Project description




Sinapsis Framework Converter

Templates for conversion between deep learning frameworks.

🐍 Installation🚀 Features 📙 Documentation🔍 License

The sinapsis-framework-converter module allows for the conversion between some of the most popular deep learning frameworks in the community:

  • Keras -> Tensorflow
  • Tensorflow -> ONNX
  • Pytorch -> TensorRT
  • Pytorch -> ONNX
  • ONNX -> TensorRT

🐍 Installation

[!NOTE] CUDA-based templates in Sinapsis-framework-converter require NVIDIA driver version to be 550 or higher.

Install using your package manager of choice. We encourage the use of uv

Example with uv:

uv pip install sinapsis-framework-converter --extra-index-url https://pypi.sinapsis.tech

or with raw pip:

pip install sinapsis-framework-converter --extra-index-url https://pypi.sinapsis.tech

[!IMPORTANT] Templates in each package may require extra dependencies. For development, we recommend installing the package with all the optional dependencies:

Example with uv:

uv pip install sinapsis-framework-converter[all] --extra-index-url https://pypi.sinapsis.tech

or with raw pip:

pip install sinapsis-framework-converter[all] --extra-index-url https://pypi.sinapsis.tech

[!IMPORTANT] To enable tensorflow with cuda support please install tensorflow as follows:

uv pip install tensorflow[and-cuda]==2.18.0

or

pip install tensorflow[and-cuda]==2.18.0

🚀 Features

Templates Supported

The Sinapsis Framework Converter module provides multiple templates for deep learning framework conversion.

  • KerasTensorFlowConverter: Converts Keras models to TensorFlow.
  • ONNXTRTConverter: Converts ONNX models to TensorRT.
  • TensorFlowONNXConverter: Converts TensorFlow models to ONNX.
  • TorchONNXConverter: Converts PyTorch models to ONNX.
  • TorchTRTConverter: Converts PyTorch models to TensorRT.
▶️ Example Usage

The following example demonstrates how to use the TorchONNXConverter template to convert a PyTorch model into the ONNX format. The configuration sets up an agent with the necessary templates to load a model, convert it, and store the converted file. Below is the full YAML configuration, followed by a breakdown of each component.

agent:
  name: conversion_agent

templates:
- template_name: InputTemplate
  class_name: InputTemplate
  attributes: {}

- template_name: TorchONNXConverter
  class_name: TorchONNXConverter
  template_input: InputTemplate
  attributes:
    model_name: resnet50
    save_model_path: true
    force_compilation: true
    opset_version: 12
    height: 224
    width: 224

This configuration defines an agent and a sequence of templates to perform model conversion.

  1. Input Handling (InputTemplate): This serves as the initial template.
  2. Model Conversion (TorchONNXConverter): Loads a PyTorch model (e.g., resnet50) and converts it to ONNX format. The template:
    • Uses the model_name attribute to specify which PyTorch model to convert.
    • Applies the opset_version attribute to define the ONNX operator set version (e.g., 12).
    • Adjusts the input tensor dimensions using height and width.
    • Enables force_compilation to ensure the model is recompiled if needed.
  3. Saving the Converted Model: The save_model_path attribute is set to true, ensuring that the output ONNX model path is saved in the DataContainer.

📙 Documentation

Documentation is available on the sinapsis website

Tutorials for different projects within sinapsis are available at sinapsis tutorials page

🔍 License

This project is licensed under the AGPLv3 license, which encourages open collaboration and sharing. For more details, please refer to the LICENSE file.

For commercial use, please refer to our official Sinapsis website for information on obtaining a commercial license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sinapsis_framework_converter-0.1.7.tar.gz (28.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sinapsis_framework_converter-0.1.7-py3-none-any.whl (34.4 kB view details)

Uploaded Python 3

File details

Details for the file sinapsis_framework_converter-0.1.7.tar.gz.

File metadata

File hashes

Hashes for sinapsis_framework_converter-0.1.7.tar.gz
Algorithm Hash digest
SHA256 e0b1fcb24ee4decd7ccd0b4896e11eb78519a6754de803b2641e5844e43cc553
MD5 5d8be4c2fd3b8b5e1d204ce6b0a7d6e0
BLAKE2b-256 94805f281273c2fc56b4dd372ba3ed73542b0d862ce3c1c4e28b658eedd8ff1e

See more details on using hashes here.

File details

Details for the file sinapsis_framework_converter-0.1.7-py3-none-any.whl.

File metadata

File hashes

Hashes for sinapsis_framework_converter-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 d93728884c865036522f947a9679e710c1e9a0733d4d8fc1ca017cf2f29a338b
MD5 8c6f17e8a34545e3325c707cfd349205
BLAKE2b-256 3bb0f3516691474a0b83d8e54d128b9bba55b86e53b883886c0b655e62f34918

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page