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.2.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.2.0-py3-none-any.whl (2.6 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: untool-0.2.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.2.0.tar.gz
Algorithm Hash digest
SHA256 df4ae8755707bfcaf35b9c7c15dac2cf9d40d91c8ce4506a8ed4b1ed05d99e66
MD5 62cbe80532e4da5cb9440f236fd8aa1a
BLAKE2b-256 eb83565cf0bff16fe4614a3370af137a637766d1e49505cd65a9dc70135bde2b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: untool-0.2.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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aff756b1b17398e3b86248a5d4ae29a4d816bb09779bff68ea85b0b782f8b0b6
MD5 1338e821e222d227842926cc92d2945e
BLAKE2b-256 1a09f03d0251c1da2d383eb5a71700e724e68fad14df6b066a2d85fe8f7814e5

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