refactor(netrans)

This commit is contained in:
xujiao 2025-11-25 20:22:51 +08:00
parent ec1894ef91
commit 894665c48a
3 changed files with 6 additions and 4 deletions

View File

@ -105,6 +105,8 @@ from netrans import Netrans
# 定义模型路径,模型路径默认为工作路径。
model_path='~/app/netrans/examples/infer_with_pre_post_process/yolov8s'
import sys
model_path=sys.argv[1]
# 初始化netrans
net = Netrans()
@ -113,7 +115,7 @@ net.load(model_path, mean=[128,128,128] ,scale=[1,1,1] )
# 模型量化
net.quantize("asymu8", pre = False, post= False)
# 前后处理添加进推理
net.add_prepost_to_graph("asymu8")
net.add_pre_post("asymu8")
# 模型导出
net.export("asymu8")
```

View File

@ -322,7 +322,7 @@ def handle_add_prepost(args):
model = Netrans()
# 使用Python API添加前后处理
model.add_prepost_to_graph(
model.add_pre_post(
args.quant_type,
model_path=args.model_path,
pre=pre,

View File

@ -225,7 +225,7 @@ class Netrans():
in_out_quantized,
)
if pre or post :
self.add_prepost_to_graph(quantized, pre, post)
self.add_pre_post(quantized, pre, post)
@_ensure_meta
@chdir
@ -299,7 +299,7 @@ class Netrans():
@_ensure_meta
@chdir
def add_prepost_to_graph(self,
def add_pre_post(self,
quantized,
*,
model_path: Optional[str] = None,