tract-python


Nametract-python JSON
Version 0.2.12 PyPI version JSON
download
home_pageNone
Summarybindings of sonos/tract rust NN inference enging for python
upload_time2023-09-23 11:16:12
maintainerNone
docs_urlNone
authorJulien Balian <julien.balian@sonos.com>
requires_python>=3.7
licenseNone
keywords tract neural network engine deep learning
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # tract-python

Project Archived: tract now maintains it's own Python package [here](https://github.com/sonos/tract/tree/main/api/py).

 [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
 [![PyPI version](https://badge.fury.io/py/tract_python.svg)](https://badge.fury.io/py/tract_python)
 [![CI](https://github.com/DreamerMind/tract-python/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/DreamerMind/tract-python/actions/workflows/CI.yml)



[tract inference engine](https://github.com/sonos/tract) bindings in Python via FFI.
It support Neural Network inference from NNEF or ONNX.

## Why

No need to compile tract or have cargo installed, fast install.

`tract-cli` is very feature-full but reloading a model each time you wish
to do an inference is computationaly costy and slow.

Think `onnxruntime` except it support NNEF, and it is based on tract.

## Install

Install using pip:
```
pip install tract_python
```


## Usage

```python
import tract_python

print(tract_python.TRACT_VERSION)
# "X.X.X"

tract_model = tract_python.TractModel.load_from_path(
  # This parameter can be an ONNX or NNEF filepath (in case of NNEF it can be a dir or a tgz)
  './tests/assets/test_simple_nnef/' # simple graph that mul input by 2
)
# .run take as argument names the name of input nodes in your neural network
results = tract_model.run(input_0=np.arange(6).reshape(1, 2, 3).astype(np.float32))
print(results)
#{'output_0': array([[[ 0.,  2.,  4.],
#       [ 6.,  8., 10.]]], dtype=float32)}

```

## Status

This project is maintained with latest tract version.

## Scope

Our personnal usecase is to be able to run +10M inferences with 'tract' engine.
So loading/running NNEF or ONNX is sufficient.

We would be happy to support some others `tract-cli` features:
- [ ] computing: number of FMA operations
- [ ] computing: profiling infos

(Thought it would be better to extract from `tract-cli` a `tract-profile` crate first in original repo to avoid code duplicate)
We do not have the bandwith to do more and welcome any contributor that would wish to add more features.


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "tract-python",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "tract,neural network engine,deep learning",
    "author": "Julien Balian <julien.balian@sonos.com>",
    "author_email": "Julien Balian <julien.balian@sonos.com>",
    "download_url": "https://files.pythonhosted.org/packages/f7/6f/4c31e906ab50bd42a97f404de57c0fc75eb6d1d63dfbb9a7a96bd7239091/tract_python-0.2.12.tar.gz",
    "platform": null,
    "description": "# tract-python\n\nProject Archived: tract now maintains it's own Python package [here](https://github.com/sonos/tract/tree/main/api/py).\n\n [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n [![PyPI version](https://badge.fury.io/py/tract_python.svg)](https://badge.fury.io/py/tract_python)\n [![CI](https://github.com/DreamerMind/tract-python/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/DreamerMind/tract-python/actions/workflows/CI.yml)\n\n\n\n[tract inference engine](https://github.com/sonos/tract) bindings in Python via FFI.\nIt support Neural Network inference from NNEF or ONNX.\n\n## Why\n\nNo need to compile tract or have cargo installed, fast install.\n\n`tract-cli` is very feature-full but reloading a model each time you wish\nto do an inference is computationaly costy and slow.\n\nThink `onnxruntime` except it support NNEF, and it is based on tract.\n\n## Install\n\nInstall using pip:\n```\npip install tract_python\n```\n\n\n## Usage\n\n```python\nimport tract_python\n\nprint(tract_python.TRACT_VERSION)\n# \"X.X.X\"\n\ntract_model = tract_python.TractModel.load_from_path(\n  # This parameter can be an ONNX or NNEF filepath (in case of NNEF it can be a dir or a tgz)\n  './tests/assets/test_simple_nnef/' # simple graph that mul input by 2\n)\n# .run take as argument names the name of input nodes in your neural network\nresults = tract_model.run(input_0=np.arange(6).reshape(1, 2, 3).astype(np.float32))\nprint(results)\n#{'output_0': array([[[ 0.,  2.,  4.],\n#       [ 6.,  8., 10.]]], dtype=float32)}\n\n```\n\n## Status\n\nThis project is maintained with latest tract version.\n\n## Scope\n\nOur personnal usecase is to be able to run +10M inferences with 'tract' engine.\nSo loading/running NNEF or ONNX is sufficient.\n\nWe would be happy to support some others `tract-cli` features:\n- [ ] computing: number of FMA operations\n- [ ] computing: profiling infos\n\n(Thought it would be better to extract from `tract-cli` a `tract-profile` crate first in original repo to avoid code duplicate)\nWe do not have the bandwith to do more and welcome any contributor that would wish to add more features.\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "bindings of sonos/tract rust NN inference enging for python",
    "version": "0.2.12",
    "project_urls": {
        "Homepage": "https://github.com/DreamerMind/tract-python"
    },
    "split_keywords": [
        "tract",
        "neural network engine",
        "deep learning"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "8f96220b8ac2c50e64b3d90b833259abb4558385053865a54ceab6c8ca4e1c2b",
                "md5": "dd159667fc936611629232656b1c3fe6",
                "sha256": "fc44f4de94544facdbd02626cb659555c908486da42ab24c72f5baa66796c630"
            },
            "downloads": -1,
            "filename": "tract_python-0.2.12-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl",
            "has_sig": false,
            "md5_digest": "dd159667fc936611629232656b1c3fe6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 11477307,
            "upload_time": "2023-09-23T11:16:04",
            "upload_time_iso_8601": "2023-09-23T11:16:04.909397Z",
            "url": "https://files.pythonhosted.org/packages/8f/96/220b8ac2c50e64b3d90b833259abb4558385053865a54ceab6c8ca4e1c2b/tract_python-0.2.12-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "dd795b11dca2daba98cbe5df032be593dfbbff58121653dc0ddb2dc6b3311bd3",
                "md5": "b0e6be90231944982ef1263893af6d17",
                "sha256": "7e8df16661ec37b07b3f2d97cc03de39be814dc5665bfe930cdd1e7013aeed32"
            },
            "downloads": -1,
            "filename": "tract_python-0.2.12-py3-none-manylinux_2_35_x86_64.whl",
            "has_sig": false,
            "md5_digest": "b0e6be90231944982ef1263893af6d17",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 7897511,
            "upload_time": "2023-09-23T11:16:08",
            "upload_time_iso_8601": "2023-09-23T11:16:08.299549Z",
            "url": "https://files.pythonhosted.org/packages/dd/79/5b11dca2daba98cbe5df032be593dfbbff58121653dc0ddb2dc6b3311bd3/tract_python-0.2.12-py3-none-manylinux_2_35_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "587dbe1fffb3d2ff920244771aa1492fabd10a9029cf9f4e9e113b98e12fe7d1",
                "md5": "5e4403286b90919bfbf1ac3dd44287b5",
                "sha256": "8520afeee35d1279421a53757380eb171864fd7701254411e68de18fe4d0b60e"
            },
            "downloads": -1,
            "filename": "tract_python-0.2.12-py3-none-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "5e4403286b90919bfbf1ac3dd44287b5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 5357319,
            "upload_time": "2023-09-23T11:16:10",
            "upload_time_iso_8601": "2023-09-23T11:16:10.739108Z",
            "url": "https://files.pythonhosted.org/packages/58/7d/be1fffb3d2ff920244771aa1492fabd10a9029cf9f4e9e113b98e12fe7d1/tract_python-0.2.12-py3-none-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "f76f4c31e906ab50bd42a97f404de57c0fc75eb6d1d63dfbb9a7a96bd7239091",
                "md5": "72708befd759a98be7fe92b1845efae7",
                "sha256": "f68ec403b95b3a78664b96fe98314711a2a4c48d6b35d597364864593c757e87"
            },
            "downloads": -1,
            "filename": "tract_python-0.2.12.tar.gz",
            "has_sig": false,
            "md5_digest": "72708befd759a98be7fe92b1845efae7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 21786,
            "upload_time": "2023-09-23T11:16:12",
            "upload_time_iso_8601": "2023-09-23T11:16:12.420389Z",
            "url": "https://files.pythonhosted.org/packages/f7/6f/4c31e906ab50bd42a97f404de57c0fc75eb6d1d63dfbb9a7a96bd7239091/tract_python-0.2.12.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-23 11:16:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "DreamerMind",
    "github_project": "tract-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "tract-python"
}
        
Elapsed time: 4.79452s