You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
642 B
23 lines
642 B
from ultralytics import YOLO
|
|
import os
|
|
|
|
print("开始导出过程...")
|
|
|
|
# 检查文件是否存在
|
|
model_path = 'd:/apysoftware/ultralytics-8.1.25/runs/detect/train6/weights/best.pt'
|
|
print(f"检查模型文件: {model_path}")
|
|
print(f"文件存在: {os.path.exists(model_path)}")
|
|
|
|
try:
|
|
print("正在加载模型...")
|
|
model = YOLO(model_path)
|
|
print("模型加载成功!")
|
|
|
|
print("开始ONNX转换...")
|
|
result = model.export(format='onnx', imgsz=640, optimize=True)
|
|
print(f"转换完成!结果: {result}")
|
|
|
|
except Exception as e:
|
|
print(f"发生错误: {e}")
|
|
import traceback
|
|
traceback.print_exc() |