Union Tool for inference on Sophgo chips
Project description
UnTool
UnTool是一个用于Sophon芯片推理的Python工具包,支持x86_64和aarch64架构,以及SOC和PCIE两种模式。
安装
pip install untool
使用示例
创建yourfile.py:
- 接口0:
from untool import LLMBasePipeline, MiniCPMVPipeline
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-m', '--model_path', type=str, required=True, help='path to the bmodel file')
parser.add_argument('-t', '--tokenizer_path', type=str, required=True, help='tokenizer or processor')
parser.add_argument('-d', '--devid', type=int, default=0, help='device ID to use')
parser.add_argument('--generation_mode', type=str, choices=["greedy", "penalty_sample"], default="greedy", help='mode for generating next token')
parser.add_argument('--enable_history', action='store_true', help="if set, enables storing of history memory")
args = parser.parse_args()
# pipline = LLMBasePipeline(args)
pipline = MiniCPMVPipeline(args)
pipline.chat()
- 接口1:
from untool import EngineLLM
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-m', '--model_path', type=str, required=True, help='path to the bmodel file')
parser.add_argument('-t', '--tokenizer_path', type=str, required=True, help='path to the tokenizer file')
parser.add_argument('-d', '--devid', type=int, default=0, help='device ID to use')
parser.add_argument('--generation_mode', type=str, choices=["greedy", "penalty_sample"], default="greedy", help='mode for generating next token')
parser.add_argument('--enable_history', action='store_true', help="if set, enables storing of history memory")
args = parser.parse_args()
engine = EngineLLM(args)
engine.chat()
- 接口2:
from untool import EngineOV
net = EngineOV("rmbg.bmodel", device_id=0)
# Prepare input
image = preprocess_image(orig_image, model_input_size)
# Inference
result = net([image])[0]
# Post process
result_image = postprocess_image(result, orig_im_size)
运行:
python youfile.py -m xxx.bmodel -t tokenizer_path -d 0
其他
详见源代码仓库https://www.modelscope.cn/wlc952/UnTool.git
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
untool-0.1.2.tar.gz
(2.6 MB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file untool-0.1.2.tar.gz.
File metadata
- Download URL: untool-0.1.2.tar.gz
- Upload date:
- Size: 2.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34f697f26aebb68b6b8d230aabd29279eb88779187058b3e62eb253e5f8d1304
|
|
| MD5 |
0fda42842ab199e6636543ffe20defd9
|
|
| BLAKE2b-256 |
39fa2ec2367c73a161b5d814876904516f789b43883537268b441ddf40d6102b
|
File details
Details for the file untool-0.1.2-py3-none-any.whl.
File metadata
- Download URL: untool-0.1.2-py3-none-any.whl
- Upload date:
- Size: 2.6 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62d9defbc37435a44b695ea7f07ff700056c36bbc31ac525e49d72b0988a93df
|
|
| MD5 |
afcad9959e20eb27247b57ee5d42d3ed
|
|
| BLAKE2b-256 |
986551eacb77788b791ae41601031787e22026c4878735b0a8bc54d2fe8278b3
|