Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

export yolov8-lite-s and yolov8-lite-t error #9

Open
pcb9382 opened this issue Aug 3, 2023 · 2 comments
Open

export yolov8-lite-s and yolov8-lite-t error #9

pcb9382 opened this issue Aug 3, 2023 · 2 comments

Comments

@pcb9382
Copy link

pcb9382 commented Aug 3, 2023

yolo mode=export model=yolov8-lite-s.pt format=onnx simplify=True batch=1
Traceback (most recent call last):
File "/home/pcb/.local/bin/yolo", line 8, in
sys.exit(entrypoint())
File "/home/pcb/.local/lib/python3.8/site-packages/ultralytics/yolo/cfg/init.py", line 378, in entrypoint
model = YOLO(model, task=task)
File "/home/pcb/.local/lib/python3.8/site-packages/ultralytics/yolo/engine/model.py", line 107, in init
self._load(model, task)
File "/home/pcb/.local/lib/python3.8/site-packages/ultralytics/yolo/engine/model.py", line 156, in _load
self.model, self.ckpt = attempt_load_one_weight(weights)
File "/home/pcb/.local/lib/python3.8/site-packages/ultralytics/nn/tasks.py", line 578, in attempt_load_one_weight
ckpt, weight = torch_safe_load(weight) # load ckpt
File "/home/pcb/.local/lib/python3.8/site-packages/ultralytics/nn/tasks.py", line 518, in torch_safe_load
return torch.load(file, map_location='cpu'), file # load
File "/home/pcb/.local/lib/python3.8/site-packages/torch/serialization.py", line 607, in load
return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
File "/home/pcb/.local/lib/python3.8/site-packages/torch/serialization.py", line 882, in _load
result = unpickler.load()
File "/home/pcb/.local/lib/python3.8/site-packages/torch/serialization.py", line 875, in find_class
return super().find_class(mod_name, name)
AttributeError: Can't get attribute 'StemBlock' on <module 'ultralytics.nn.modules' from '/home/pcb/.local/lib/python3.8/site-packages/ultralytics/nn/modules/init.py'>

@yantianj
Copy link

yantianj commented Dec 1, 2023

hi, [pcb9382]

我也尝试导出模型到ONNX
I also tried exporting the model to ONNX.
期间报了好几个错
During this period, several errors were reported.

1. AttributeError: Can't get attribute 'StemBlock' on <module 'ultralytics.nn.modules' from '/home/pcb/.local/lib/python3.8/site-packages/ultralytics/nn/modules/init.py'>

在作者自己的ultralytics里是有StemBlock这个函数得,但导出时我们安装使用是官方的包 来自于 命令“pip install ultralytics”
There is a function called StemBlock in the author's own ultralytics, but when exporting, we install and use an official package from the command "pip install ultralytics"

解决办法:
solution:

copy :
xxx\yolov8-face\ultralytics\nn\modules\block.py
xxx\yolov8-face\ultralytics\nn\modules_init_.py
to :
xxx\anaconda\envs\yolov8\Lib\site-packages\ultralytics\nn\modules\block.py
xxx\anaconda\envs\yolov8\Lib\site-packages\ultralytics\nn\modules_init_.py

@yantianj
Copy link

yantianj commented Dec 1, 2023

I want to export the model as onnx opset 11

I succeeded, and all the steps to try are as follows:

  1. pip install torch==1.8.1 torchvision==0.9.1 torchaudio==0.8.1 -i https://pypi.doubanio.com/simple
    answer from: TypeError: conv2d() received an invalid combination of arguments - got (Tensor, Parameter, NoneType, tuple, tuple, tuple, int), but expected one of: we0091234/yolov8-plate#2
  1. pip install ultralytics==8.0.134 -i https://pypi.tuna.tsinghua.edu.cn/simple
    version from: xxx/yolov8-face/ultralytics/init.py

copy :
xxx\yolov8-face\ultralytics\nn\modules\block.py
xxx\yolov8-face\ultralytics\nn\modules_init_.py
to :
xxx\anaconda\envs\yolov8\Lib\site-packages\ultralytics\nn\modules\block.py
xxx\anaconda\envs\yolov8\Lib\site-packages\ultralytics\nn\modules_init_.py

  1. code:

export.py

from ultralytics import YOLO

model = YOLO("xxx/yolov8n-face.pt")
success = model.export(format="onnx", opset=11, simplify=True)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants