onnxruntime_extensions 0.12.0__cp38-cp38-win_amd64.whl → 0.13.0__cp38-cp38-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- onnxruntime_extensions/_extensions_pydll.cp38-win_amd64.pyd +0 -0
- onnxruntime_extensions/_hf_cvt.py +3 -2
- onnxruntime_extensions/_version.py +1 -1
- onnxruntime_extensions/pp_api.py +70 -2
- {onnxruntime_extensions-0.12.0.dist-info → onnxruntime_extensions-0.13.0.dist-info}/METADATA +4 -16
- {onnxruntime_extensions-0.12.0.dist-info → onnxruntime_extensions-0.13.0.dist-info}/RECORD +9 -9
- {onnxruntime_extensions-0.12.0.dist-info → onnxruntime_extensions-0.13.0.dist-info}/WHEEL +1 -1
- {onnxruntime_extensions-0.12.0.dist-info → onnxruntime_extensions-0.13.0.dist-info}/LICENSE +0 -0
- {onnxruntime_extensions-0.12.0.dist-info → onnxruntime_extensions-0.13.0.dist-info}/top_level.txt +0 -0
|
Binary file
|
|
@@ -48,8 +48,9 @@ class HFTokenizerConverter(CustomOpConverter):
|
|
|
48
48
|
model_dir = hf_tokenizer.name_or_path
|
|
49
49
|
else:
|
|
50
50
|
model_dir = os.path.dirname(vocab_file)
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
f = open(os.path.join(model_dir, tokenizer_file), "r", encoding="utf-8")
|
|
52
|
+
tokenizer_json = json.load(f)
|
|
53
|
+
f.close()
|
|
53
54
|
# get vocab object from json file
|
|
54
55
|
vocab = tokenizer_json.get("model", {}).get("vocab", {})
|
|
55
56
|
sorted_merges = tokenizer_json.get("model", {}).get("merges", [])
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
# Generated by setup.py, DON'T MANUALLY UPDATE IT!
|
|
2
|
-
__version__ = "0.
|
|
2
|
+
__version__ = "0.13.0"
|
onnxruntime_extensions/pp_api.py
CHANGED
|
@@ -3,11 +3,79 @@
|
|
|
3
3
|
# license information.
|
|
4
4
|
###############################################################################
|
|
5
5
|
|
|
6
|
+
import os
|
|
6
7
|
from . import _extensions_pydll as _C
|
|
7
|
-
if not hasattr(_C, "
|
|
8
|
-
raise ImportError(
|
|
8
|
+
if not hasattr(_C, "delete_object"):
|
|
9
|
+
raise ImportError(
|
|
10
|
+
"onnxruntime_extensions is not built with pre-processing C API\n"
|
|
11
|
+
"To enable it, please build the package with --ortx-user-option=pp_api")
|
|
9
12
|
|
|
10
13
|
create_processor = _C.create_processor
|
|
11
14
|
load_images = _C.load_images
|
|
12
15
|
image_pre_process = _C.image_pre_process
|
|
13
16
|
tensor_result_get_at = _C.tensor_result_get_at
|
|
17
|
+
|
|
18
|
+
create_tokenizer = _C.create_tokenizer
|
|
19
|
+
batch_tokenize = _C.batch_tokenize
|
|
20
|
+
batch_detokenize = _C.batch_detokenize
|
|
21
|
+
|
|
22
|
+
delete_object = _C.delete_object
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class Tokenizer:
|
|
26
|
+
def __init__(self, tokenizer_dir):
|
|
27
|
+
self.tokenizer = None
|
|
28
|
+
if os.path.isdir(tokenizer_dir):
|
|
29
|
+
self.tokenizer = create_tokenizer(tokenizer_dir)
|
|
30
|
+
else:
|
|
31
|
+
try:
|
|
32
|
+
from transformers.utils import cached_file
|
|
33
|
+
resolved_full_file = cached_file(
|
|
34
|
+
tokenizer_dir, "tokenizer.json")
|
|
35
|
+
resolved_config_file = cached_file(
|
|
36
|
+
tokenizer_dir, "tokenizer_config.json")
|
|
37
|
+
except ImportError:
|
|
38
|
+
raise ValueError(
|
|
39
|
+
f"Directory '{tokenizer_dir}' not found and transformers is not available")
|
|
40
|
+
if not os.path.exists(resolved_full_file):
|
|
41
|
+
raise FileNotFoundError(
|
|
42
|
+
f"Downloaded HF file '{resolved_full_file}' cannot be found")
|
|
43
|
+
if (os.path.dirname(resolved_full_file) != os.path.dirname(resolved_config_file)):
|
|
44
|
+
raise FileNotFoundError(
|
|
45
|
+
f"Downloaded HF files '{resolved_full_file}' "
|
|
46
|
+
f"and '{resolved_config_file}' are not in the same directory")
|
|
47
|
+
|
|
48
|
+
tokenizer_dir = os.path.dirname(resolved_full_file)
|
|
49
|
+
self.tokenizer = create_tokenizer(tokenizer_dir)
|
|
50
|
+
|
|
51
|
+
def tokenize(self, text):
|
|
52
|
+
return batch_tokenize(self.tokenizer, [text])[0]
|
|
53
|
+
|
|
54
|
+
def detokenize(self, tokens):
|
|
55
|
+
return batch_detokenize(self.tokenizer, [tokens])[0]
|
|
56
|
+
|
|
57
|
+
def __del__(self):
|
|
58
|
+
if delete_object and self.tokenizer:
|
|
59
|
+
delete_object(self.tokenizer)
|
|
60
|
+
self.tokenizer = None
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class ImageProcessor:
|
|
64
|
+
def __init__(self, processor_json):
|
|
65
|
+
self.processor = create_processor(processor_json)
|
|
66
|
+
|
|
67
|
+
def pre_process(self, images):
|
|
68
|
+
if isinstance(images, str):
|
|
69
|
+
images = [images]
|
|
70
|
+
if isinstance(images, list):
|
|
71
|
+
images = load_images(images)
|
|
72
|
+
return image_pre_process(self.processor, images)
|
|
73
|
+
|
|
74
|
+
@staticmethod
|
|
75
|
+
def to_numpy(result):
|
|
76
|
+
return tensor_result_get_at(result, 0)
|
|
77
|
+
|
|
78
|
+
def __del__(self):
|
|
79
|
+
if delete_object and self.processor:
|
|
80
|
+
delete_object(self.processor)
|
|
81
|
+
self.processor = None
|
{onnxruntime_extensions-0.12.0.dist-info → onnxruntime_extensions-0.13.0.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: onnxruntime_extensions
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.13.0
|
|
4
4
|
Summary: ONNXRuntime Extensions
|
|
5
5
|
Home-page: https://github.com/microsoft/onnxruntime-extensions
|
|
6
6
|
Author: Microsoft Corporation
|
|
@@ -25,29 +25,17 @@ License-File: LICENSE
|
|
|
25
25
|
|
|
26
26
|
## What's ONNXRuntime-Extensions
|
|
27
27
|
|
|
28
|
-
Introduction: ONNXRuntime-Extensions is a library that extends the capability of the ONNX models and inference with ONNX Runtime, via ONNX Runtime Custom Operator ABIs. It includes a set of [ONNX Runtime Custom Operator](https://onnxruntime.ai/docs/reference/operators/add-custom-op.html) to support the common pre- and post-processing operators for vision, text, and nlp models. And it supports multiple languages and platforms, like Python on Windows/Linux/macOS, some mobile platforms like Android and iOS, and Web-Assembly etc. The basic workflow is to enhance a ONNX model firstly and then do the model inference with ONNX Runtime and ONNXRuntime-Extensions package.
|
|
28
|
+
Introduction: ONNXRuntime-Extensions is a C/C++ library that extends the capability of the ONNX models and inference with ONNX Runtime, via ONNX Runtime Custom Operator ABIs. It includes a set of [ONNX Runtime Custom Operator](https://onnxruntime.ai/docs/reference/operators/add-custom-op.html) to support the common pre- and post-processing operators for vision, text, and nlp models. And it supports multiple languages and platforms, like Python on Windows/Linux/macOS, some mobile platforms like Android and iOS, and Web-Assembly etc. The basic workflow is to enhance a ONNX model firstly and then do the model inference with ONNX Runtime and ONNXRuntime-Extensions package.
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
## Quickstart
|
|
32
|
+
The library can be utilized as either a C/C++ library or other advance language packages like Python, Java, C#, etc. To build it as a shared library, you can use the `build.bat` or `build.sh` scripts located in the root folder. The CMake build definition is available in the `CMakeLists.txt` file and can be modified by appending options to `build.bat` or `build.sh`, such as `build.bat -DOCOS_BUILD_SHARED_LIB=OFF`. For more details, please refer to the [C API documentation](./docs/c_api.md).
|
|
32
33
|
|
|
33
34
|
### **Python installation**
|
|
34
35
|
```bash
|
|
35
36
|
pip install onnxruntime-extensions
|
|
36
37
|
````
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
### **Nightly Build**
|
|
40
|
-
|
|
41
|
-
#### <strong>on Windows</strong>
|
|
42
|
-
```cmd
|
|
43
|
-
pip install --index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/ORT-Nightly/pypi/simple/ onnxruntime-extensions
|
|
44
|
-
```
|
|
45
|
-
Please ensure that you have met the prerequisites of onnxruntime-extensions (e.g., onnx and onnxruntime) in your Python environment.
|
|
46
|
-
#### <strong>on Linux/macOS</strong>
|
|
47
|
-
Please make sure the compiler toolkit like gcc(later than g++ 8.0) or clang are installed before the following command
|
|
48
|
-
```bash
|
|
49
|
-
python -m pip install git+https://github.com/microsoft/onnxruntime-extensions.git
|
|
50
|
-
```
|
|
38
|
+
The nightly build is also available for the latest features, please refer to [nightly build](./docs/development.md#nightly-build)
|
|
51
39
|
|
|
52
40
|
|
|
53
41
|
## Usage
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
onnxruntime_extensions/__init__.py,sha256=GMnMIHJ-uqvJGPn5fpCZOi7OG16kFVpfOTTO88kYJWY,2387
|
|
2
2
|
onnxruntime_extensions/_cuops.py,sha256=SUD2NhEWHeMem8ylCtCGBKutSuZQs4WMj1ke65-52vA,16193
|
|
3
|
-
onnxruntime_extensions/_extensions_pydll.cp38-win_amd64.pyd,sha256=
|
|
3
|
+
onnxruntime_extensions/_extensions_pydll.cp38-win_amd64.pyd,sha256=OEPzg22-fhVPxJYurDncDJaIwZ7WSqFDMoaeYyZabyU,3379712
|
|
4
4
|
onnxruntime_extensions/_extensions_pydll.pyi,sha256=mYXkqNaCgAbs161RDKgDjxIX9vWdYdVPDC-0X9cieco,1070
|
|
5
|
-
onnxruntime_extensions/_hf_cvt.py,sha256=
|
|
5
|
+
onnxruntime_extensions/_hf_cvt.py,sha256=3RDEr4uga_FYBReSDgqLqvj_2-7HgVOk073BRT8lK_E,14082
|
|
6
6
|
onnxruntime_extensions/_ocos.py,sha256=OlDOlCH_vWFOBkjbp6Pujgw6rgk8Fd3_2Mi5ev1eeS0,4193
|
|
7
7
|
onnxruntime_extensions/_ortapi2.py,sha256=Tfrf9fQMQ0e7Wa4R8s4SHdwMNBdmj33wH3y5vMkVVQE,9951
|
|
8
8
|
onnxruntime_extensions/_torch_cvt.py,sha256=hGOiw24QuFpK_3CLjg8Fs2GD_cCdM049xcJxkHVRbAk,10185
|
|
9
|
-
onnxruntime_extensions/_version.py,sha256=
|
|
9
|
+
onnxruntime_extensions/_version.py,sha256=uFV2Hf2pKZgA12fk8O9oCxhl_fUheVDYuvrK3A-Vjnc,76
|
|
10
10
|
onnxruntime_extensions/cmd.py,sha256=eIiNNY0ohbUCPgmr9RwOfi0Gzw7nWL17i625L-ZKezI,2428
|
|
11
11
|
onnxruntime_extensions/cvt.py,sha256=XMz0CZXBJQ9IwnixjzJwz-utKyu9HREIEUCviZg6v8A,3977
|
|
12
|
-
onnxruntime_extensions/pp_api.py,sha256
|
|
12
|
+
onnxruntime_extensions/pp_api.py,sha256=MpW3frODcWXOmYaoTQiYWiM807rC8GjlWgpIYc-CDy8,3051
|
|
13
13
|
onnxruntime_extensions/util.py,sha256=KxNFY0-5CG1i9HADcCc4V33PNukTO46Os_KIL8pj-l8,7394
|
|
14
14
|
onnxruntime_extensions/onnxprocess/__init__.py,sha256=BnveHXnu2nTQNbCLeZujZgZwO9A3yWFbQGTDthCFbIc,534
|
|
15
15
|
onnxruntime_extensions/onnxprocess/_builder.py,sha256=L_afKeE7Wc4mWJ47eVXQ2stvmal_37QVTQZgKmt0ZK8,1844
|
|
@@ -36,8 +36,8 @@ onnxruntime_extensions/tools/pre_post_processing/steps/__init__.py,sha256=pdVRZB
|
|
|
36
36
|
onnxruntime_extensions/tools/pre_post_processing/steps/general.py,sha256=fF_XVFSKOCu482Sqjp-nVPbs-ZVGpPal2ekbO1gUO_4,13781
|
|
37
37
|
onnxruntime_extensions/tools/pre_post_processing/steps/nlp.py,sha256=ZCxRNxqfANplxCe0I-6BfHziM1jDYJsNQKbHdM3Y1I0,15173
|
|
38
38
|
onnxruntime_extensions/tools/pre_post_processing/steps/vision.py,sha256=BM6CGylOSu4l6UarPfW0I2tgkJDa1Q-gYz__CxZle-k,53183
|
|
39
|
-
onnxruntime_extensions-0.
|
|
40
|
-
onnxruntime_extensions-0.
|
|
41
|
-
onnxruntime_extensions-0.
|
|
42
|
-
onnxruntime_extensions-0.
|
|
43
|
-
onnxruntime_extensions-0.
|
|
39
|
+
onnxruntime_extensions-0.13.0.dist-info/LICENSE,sha256=mQaUD2Gx8LUz-n2ZuvVReLKAj74RPqUd-_rYVyzNXys,1162
|
|
40
|
+
onnxruntime_extensions-0.13.0.dist-info/METADATA,sha256=MmpoFbjh5Etph2BR7msz-Nrg6QNh56wtGqL46NUSiaE,4483
|
|
41
|
+
onnxruntime_extensions-0.13.0.dist-info/WHEEL,sha256=BiKefS7XHc6W0zY4ROW4fxXTZBRH27JLKtM6pqE4hBs,99
|
|
42
|
+
onnxruntime_extensions-0.13.0.dist-info/top_level.txt,sha256=XyAgQDKyXsf6_0MJb58kRdHwigpTn7A7kl9diBEjs8M,23
|
|
43
|
+
onnxruntime_extensions-0.13.0.dist-info/RECORD,,
|
|
File without changes
|
{onnxruntime_extensions-0.12.0.dist-info → onnxruntime_extensions-0.13.0.dist-info}/top_level.txt
RENAMED
|
File without changes
|