代码拉取完成,页面将自动刷新
同步操作将从 PPOV_NUC/yolov8_openvino 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
from openvino.preprocess import PrePostProcessor, ColorFormat, ResizeAlgorithm
from openvino.runtime import Core, Layout, Type, serialize
# 定义常量
MODEL_NAME = "yolov8n"
# ======== Step 0: read original model =========
core = Core()
model = core.read_model(f"{MODEL_NAME}-cls.xml")
# Step 1: Add Preprocessing steps to a model ==
ppp = PrePostProcessor(model)
# Declare User’s Data Format
ppp.input().tensor() \
.set_element_type(Type.u8) \
.set_spatial_dynamic_shape() \
.set_layout(Layout('NHWC')) \
.set_color_format(ColorFormat.BGR)
# Declaring Model Layout
ppp.input().model().set_layout(Layout('NCHW'))
# Explicit preprocessing steps. Layout conversion will be done automatically as last step
ppp.input().preprocess() \
.convert_element_type() \
.convert_color(ColorFormat.RGB) \
.resize(ResizeAlgorithm.RESIZE_LINEAR) \
.mean([123.675, 116.28, 103.53]) \
.scale([58.624, 57.12, 57.375])
# Integrate preprocessing Steps into a Model
print(f'Dump preprocessor: {ppp}')
model_with_ppp = ppp.build()
# ======== Step 2: Save the model with preprocessor================
serialize(model_with_ppp, f'{MODEL_NAME}-cls_ppp.xml', f'{MODEL_NAME}-cls_ppp.bin')
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。