Skip to main content

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


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.0.tar.gz (2.6 MB view details)

Uploaded Source

Built Distribution

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

untool-0.1.0-py3-none-any.whl (2.6 MB view details)

Uploaded Python 3

File details

Details for the file untool-0.1.0.tar.gz.

File metadata

  • Download URL: untool-0.1.0.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

Hashes for untool-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a4dc670343e3391dc4043fff780158e4e992ce541596b9d19f26eb6a1c670f59
MD5 4c199a4aa4cd61ea55110379604c8512
BLAKE2b-256 a898271d5fedfc7ab67494b400eded88f2dc5a44ad8fe9736ae45689126a9cb8

See more details on using hashes here.

File details

Details for the file untool-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: untool-0.1.0-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

Hashes for untool-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 571b9335e2c68f9020d65637af73f135dc926a84f2c6b3c9e1e1958af1b03872
MD5 b753ec40a9cf400249ae17cb4c63044e
BLAKE2b-256 b62241b9fcf09ee378e67e3558d8ac0a1e48764ca37e0de04a9eb657f1eab32d

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