Instructions to use CatSnowdrop/universal_onnxruntime with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- TensorRT
How to use CatSnowdrop/universal_onnxruntime with TensorRT:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Download onnxruntime/tools/remove_initializer_from_input.py from CatSnowdrop/universal_onnxruntime: direct link, hf CLI and curl.
- Browser
- Download file 994 Bytes
-
https://huggingface.co/CatSnowdrop/universal_onnxruntime/resolve/main/onnxruntime/tools/remove_initializer_from_input.py
- Command line
-
hf download hf://CatSnowdrop/universal_onnxruntime/onnxruntime/tools/remove_initializer_from_input.py
-
curl -L -o remove_initializer_from_input.py https://huggingface.co/CatSnowdrop/universal_onnxruntime/resolve/main/onnxruntime/tools/remove_initializer_from_input.py
994 Bytes
| import argparse | |
| import onnx | |
| def get_args(): | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("--input", required=True, help="input model") | |
| parser.add_argument("--output", required=True, help="output model") | |
| args = parser.parse_args() | |
| return args | |
| def remove_initializer_from_input(model: onnx.ModelProto) -> bool: | |
| if model.ir_version < 4: | |
| print("Model with ir_version below 4 requires to include initializer in graph input") | |
| return False | |
| inputs = model.graph.input | |
| name_to_input = {} | |
| for input in inputs: | |
| name_to_input[input.name] = input | |
| modified = False | |
| for initializer in model.graph.initializer: | |
| if initializer.name in name_to_input: | |
| modified = True | |
| inputs.remove(name_to_input[initializer.name]) | |
| return modified | |
| if __name__ == "__main__": | |
| args = get_args() | |
| model = onnx.load(args.input) | |
| remove_initializer_from_input(model) | |
| onnx.save(model, args.output) | |