gjhhust / YOLOFT

A code base for the official XS-VID dataset baseline method YOLOFT
GNU Affero General Public License v3.0
6 stars 1 forks source link

conver to onnx error #1

Closed assertdebug closed 3 days ago

assertdebug commented 1 month ago
Details

yolo export model=yoloft-S.pt imgsz=480,640 format=onnx opset=12 /home/user/data/Devon/YOLOFT/ultralytics/nn/modules/ops_dcnv3/modules/dcnv3.py:20: UserWarning: Now, we support DCNv4 in InternImage. warnings.warn('Now, we support DCNv4 in InternImage.') using DCNv3 ERROR: No DCNv4 now flow_conv: Traceback (most recent call last): File "/home/user/anaconda3/envs/ultr/bin/yolo", line 33, in sys.exit(load_entry_point('ultralytics', 'console_scripts', 'yolo')()) File "/home/user/anaconda3/envs/ultr/bin/yolo", line 25, in importlib_load_entry_point return next(matches).load() File "/home/user/anaconda3/envs/ultr/lib/python3.8/importlib/metadata.py", line 77, in load module = import_module(match.group('module')) File "/home/user/anaconda3/envs/ultr/lib/python3.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 961, in _find_and_load_unlocked File "", line 219, in _call_with_frames_removed File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 975, in _find_and_load_unlocked File "", line 671, in _load_unlocked File "", line 843, in exec_module File "", line 219, in _call_with_frames_removed File "/home/user/data/Devon/YOLOFT/ultralytics/__init__.py", line 5, in from ultralytics.hub import start File "/home/user/data/Devon/YOLOFT/ultralytics/hub/__init__.py", line 5, in from ultralytics.data.utils import HUBDatasetStats File "/home/user/data/Devon/YOLOFT/ultralytics/data/__init__.py", line 3, in from .base import BaseDataset File "/home/user/data/Devon/YOLOFT/ultralytics/data/base.py", line 20, in from .utils import HELP_URL, IMG_FORMATS File "/home/user/data/Devon/YOLOFT/ultralytics/data/utils.py", line 20, in from ultralytics.nn.autobackend import check_class_names File "/home/user/data/Devon/YOLOFT/ultralytics/nn/__init__.py", line 3, in from .tasks import (BaseModel, ClassificationModel, DetectionModel, MOVEDetectionModel,SegmentationModel, attempt_load_one_weight, File "/home/user/data/Devon/YOLOFT/ultralytics/nn/tasks.py", line 10, in from ultralytics.nn.modules import * File "/home/user/data/Devon/YOLOFT/ultralytics/nn/modules/__init__.py", line 16, in from .block import * File "/home/user/data/Devon/YOLOFT/ultralytics/nn/modules/block.py", line 1647, in from ultralytics.nn.modules.ops.modules import MSDeformAttn ModuleNotFoundError: No module named 'ultralytics.nn.modules.ops'

gjhhust commented 1 month ago

You can try commenting out this import to make sure it doesn't report an error! “ModuleNotFoundError: No module named 'ultralytics.nn.modules.ops'” or try to install deformable detr‘s ops

assertdebug commented 1 month ago

image There are still other misreporting issues

gjhhust commented 1 month ago

Can you show your full action script? I will try it on my device and fix the bugs

gjhhust commented 1 month ago

I fixed the bug, please re-pull the new library after pip install -e . Reinstall, then re-download the weights file for testing

assertdebug commented 1 month ago

I've updated all your new code submissions and model files, but it's still wrong.

gjhhust commented 1 month ago

I've updated all your new code submissions and model files, but it's still wrong.

Can you send me your script commands and errors?

assertdebug commented 1 month ago

I've updated all your new code submissions and model files, but it's still wrong.

=====================================

yolo export model=yoloft-S.pt imgsz=640,640 format=onnx opset=12

================================= using DCNv3 ERROR: No DCNv4 now flow_conv: <class 'ultralytics.nn.modules.conv.Conv_onany'> Ultralytics YOLOv8.0.143 🚀 Python-3.8.19 torch-1.12.1+cu113 CPU (Intel Xeon Gold 6346 3.10GHz) error model number: 1 flowS_baseline3_start4 summary (fused): 244 layers, 13357455 parameters, 0 gradients

PyTorch: starting from 'yoloft-S.pt' with input shape (1, 3, 640, 640) BCHW and output shape(s) ((1, 13, 8400), ()) (25.7 MB)

ONNX: starting export with onnx 1.16.1 opset 12... ONNX: export failure ❌ 3.9s: output 1 (0.1 [ CPUDoubleType{} ]) of traced region did not have observable data dependence with trace inputs; this probably indicates your program cannot be understood by the tracer. Traceback (most recent call last): File "/home/user/anaconda3/envs/ultr/bin/yolo", line 33, in sys.exit(load_entry_point('ultralytics', 'console_scripts', 'yolo')()) File "/home/user/data/Devon/YOLOFT/ultralytics/cfg/init.py", line 425, in entrypoint getattr(model, mode)(overrides) # default args from model File "/home/user/data/Devon/YOLOFT/ultralytics/engine/model.py", line 344, in export return Exporter(overrides=args, _callbacks=self.callbacks)(model=self.model) File "/home/user/anaconda3/envs/ultr/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decoratecontext return func(*args, **kwargs) File "/home/user/data/Devon/YOLOFT/ultralytics/engine/exporter.py", line 243, in call f[2], = self.export_onnx() File "/home/user/data/Devon/YOLOFT/ultralytics/engine/exporter.py", line 119, in outer_func raise e File "/home/user/data/Devon/YOLOFT/ultralytics/engine/exporter.py", line 114, in outer_func f, model = inner_func(*args, kwargs) File "/home/user/data/Devon/YOLOFT/ultralytics/engine/exporter.py", line 322, in export_onnx torch.onnx.export( File "/home/user/anaconda3/envs/ultr/lib/python3.8/site-packages/torch/onnx/init.py", line 350, in export return utils.export( File "/home/user/anaconda3/envs/ultr/lib/python3.8/site-packages/torch/onnx/utils.py", line 163, in export _export( File "/home/user/anaconda3/envs/ultr/lib/python3.8/site-packages/torch/onnx/utils.py", line 1074, in _export graph, params_dict, torch_out = _model_to_graph( File "/home/user/anaconda3/envs/ultr/lib/python3.8/site-packages/torch/onnx/utils.py", line 727, in _model_to_graph graph, params, torch_out, module = _create_jit_graph(model, args) File "/home/user/anaconda3/envs/ultr/lib/python3.8/site-packages/torch/onnx/utils.py", line 602, in _create_jit_graph graph, torch_out = _trace_and_get_graph_from_model(model, args) File "/home/user/anaconda3/envs/ultr/lib/python3.8/site-packages/torch/onnx/utils.py", line 517, in _trace_and_get_graph_from_model trace_graph, torch_out, inputs_states = torch.jit._get_trace_graph( File "/home/user/anaconda3/envs/ultr/lib/python3.8/site-packages/torch/jit/_trace.py", line 1175, in _get_trace_graph outs = ONNXTracedModule(f, strict, _force_outplace, return_inputs, _return_inputs_states)(*args, *kwargs) File "/home/user/anaconda3/envs/ultr/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(input, **kwargs) File "/home/user/anaconda3/envs/ultr/lib/python3.8/site-packages/torch/jit/_trace.py", line 127, in forward graph, out = torch._C._create_graph_by_tracing( RuntimeError: output 1 (0.1 [ CPUDoubleType{} ]) of traced region did not have observable data dependence with trace inputs; this probably indicates your program cannot be understood by the tracer.

gjhhust commented 1 month ago

I've updated all your new code submissions and model files, but it's still wrong.

=====================================

yolo export model=yoloft-S.pt imgsz=640,640 format=onnx opset=12

================================= using DCNv3 ERROR: No DCNv4 now flow_conv: <class 'ultralytics.nn.modules.conv.Conv_onany'> Ultralytics YOLOv8.0.143 🚀 Python-3.8.19 torch-1.12.1+cu113 CPU (Intel Xeon Gold 6346 3.10GHz) error model number: 1 flowS_baseline3_start4 summary (fused): 244 layers, 13357455 parameters, 0 gradients

PyTorch: starting from 'yoloft-S.pt' with input shape (1, 3, 640, 640) BCHW and output shape(s) ((1, 13, 8400), ()) (25.7 MB)

ONNX: starting export with onnx 1.16.1 opset 12... ONNX: export failure ❌ 3.9s: output 1 (0.1 [ CPUDoubleType{} ]) of traced region did not have observable data dependence with trace inputs; this probably indicates your program cannot be understood by the tracer. Traceback (most recent call last): File "/home/user/anaconda3/envs/ultr/bin/yolo", line 33, in sys.exit(load_entry_point('ultralytics', 'console_scripts', 'yolo')()) File "/home/user/data/Devon/YOLOFT/ultralytics/cfg/init.py", line 425, in entrypoint getattr(model, mode)(overrides) # default args from model File "/home/user/data/Devon/YOLOFT/ultralytics/engine/model.py", line 344, in export return Exporter(overrides=args, _callbacks=self.callbacks)(model=self.model) File "/home/user/anaconda3/envs/ultr/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decoratecontext return func(*args, kwargs) File "/home/user/data/Devon/YOLOFT/ultralytics/engine/exporter.py", line 243, in call** f[2], = self.export_onnx() File "/home/user/data/Devon/YOLOFT/ultralytics/engine/exporter.py", line 119, in outer_func raise e File "/home/user/data/Devon/YOLOFT/ultralytics/engine/exporter.py", line 114, in outer_func f, model = inner_func(*args, kwargs) File "/home/user/data/Devon/YOLOFT/ultralytics/engine/exporter.py", line 322, in export_onnx torch.onnx.export( File "/home/user/anaconda3/envs/ultr/lib/python3.8/site-packages/torch/onnx/init.py", line 350, in export return utils.export( File "/home/user/anaconda3/envs/ultr/lib/python3.8/site-packages/torch/onnx/utils.py", line 163, in export _export( File "/home/user/anaconda3/envs/ultr/lib/python3.8/site-packages/torch/onnx/utils.py", line 1074, in _export graph, params_dict, torch_out = _model_to_graph( File "/home/user/anaconda3/envs/ultr/lib/python3.8/site-packages/torch/onnx/utils.py", line 727, in _model_to_graph graph, params, torch_out, module = _create_jit_graph(model, args) File "/home/user/anaconda3/envs/ultr/lib/python3.8/site-packages/torch/onnx/utils.py", line 602, in _create_jit_graph graph, torch_out = _trace_and_get_graph_from_model(model, args) File "/home/user/anaconda3/envs/ultr/lib/python3.8/site-packages/torch/onnx/utils.py", line 517, in _trace_and_get_graph_from_model trace_graph, torch_out, inputs_states = torch.jit._get_trace_graph( File "/home/user/anaconda3/envs/ultr/lib/python3.8/site-packages/torch/jit/_trace.py", line 1175, in _get_trace_graph outs = ONNXTracedModule(f, strict, _force_outplace, return_inputs, _return_inputs_states)(*args, *kwargs) File "/home/user/anaconda3/envs/ultr/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(input, **kwargs) File "/home/user/anaconda3/envs/ultr/lib/python3.8/site-packages/torch/jit/_trace.py", line 127, in forward graph, out = torch._C._create_graph_by_tracing( RuntimeError: output 1 (0.1 [ CPUDoubleType{} ]) of traced region did not have observable data dependence with trace inputs; this probably indicates your program cannot be understood by the tracer.

OK, I will fix this bug later.

gjhhust commented 1 month ago

I've updated all your new code submissions and model files, but it's still wrong.

=====================================

yolo export model=yoloft-S.pt imgsz=640,640 format=onnx opset=12

================================= using DCNv3 ERROR: No DCNv4 now flow_conv: <class 'ultralytics.nn.modules.conv.Conv_onany'> Ultralytics YOLOv8.0.143 🚀 Python-3.8.19 torch-1.12.1+cu113 CPU (Intel Xeon Gold 6346 3.10GHz) error model number: 1 flowS_baseline3_start4 summary (fused): 244 layers, 13357455 parameters, 0 gradients

PyTorch: starting from 'yoloft-S.pt' with input shape (1, 3, 640, 640) BCHW and output shape(s) ((1, 13, 8400), ()) (25.7 MB)

ONNX: starting export with onnx 1.16.1 opset 12... ONNX: export failure ❌ 3.9s: output 1 (0.1 [ CPUDoubleType{} ]) of traced region did not have observable data dependence with trace inputs; this probably indicates your program cannot be understood by the tracer. Traceback (most recent call last): File "/home/user/anaconda3/envs/ultr/bin/yolo", line 33, in sys.exit(load_entry_point('ultralytics', 'console_scripts', 'yolo')()) File "/home/user/data/Devon/YOLOFT/ultralytics/cfg/init.py", line 425, in entrypoint getattr(model, mode)(overrides) # default args from model File "/home/user/data/Devon/YOLOFT/ultralytics/engine/model.py", line 344, in export return Exporter(overrides=args, _callbacks=self.callbacks)(model=self.model) File "/home/user/anaconda3/envs/ultr/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decoratecontext return func(*args, kwargs) File "/home/user/data/Devon/YOLOFT/ultralytics/engine/exporter.py", line 243, in call** f[2], = self.export_onnx() File "/home/user/data/Devon/YOLOFT/ultralytics/engine/exporter.py", line 119, in outer_func raise e File "/home/user/data/Devon/YOLOFT/ultralytics/engine/exporter.py", line 114, in outer_func f, model = inner_func(*args, kwargs) File "/home/user/data/Devon/YOLOFT/ultralytics/engine/exporter.py", line 322, in export_onnx torch.onnx.export( File "/home/user/anaconda3/envs/ultr/lib/python3.8/site-packages/torch/onnx/init.py", line 350, in export return utils.export( File "/home/user/anaconda3/envs/ultr/lib/python3.8/site-packages/torch/onnx/utils.py", line 163, in export _export( File "/home/user/anaconda3/envs/ultr/lib/python3.8/site-packages/torch/onnx/utils.py", line 1074, in _export graph, params_dict, torch_out = _model_to_graph( File "/home/user/anaconda3/envs/ultr/lib/python3.8/site-packages/torch/onnx/utils.py", line 727, in _model_to_graph graph, params, torch_out, module = _create_jit_graph(model, args) File "/home/user/anaconda3/envs/ultr/lib/python3.8/site-packages/torch/onnx/utils.py", line 602, in _create_jit_graph graph, torch_out = _trace_and_get_graph_from_model(model, args) File "/home/user/anaconda3/envs/ultr/lib/python3.8/site-packages/torch/onnx/utils.py", line 517, in _trace_and_get_graph_from_model trace_graph, torch_out, inputs_states = torch.jit._get_trace_graph( File "/home/user/anaconda3/envs/ultr/lib/python3.8/site-packages/torch/jit/_trace.py", line 1175, in _get_trace_graph outs = ONNXTracedModule(f, strict, _force_outplace, return_inputs, _return_inputs_states)(*args, *kwargs) File "/home/user/anaconda3/envs/ultr/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(input, **kwargs) File "/home/user/anaconda3/envs/ultr/lib/python3.8/site-packages/torch/jit/_trace.py", line 127, in forward graph, out = torch._C._create_graph_by_tracing( RuntimeError: output 1 (0.1 [ CPUDoubleType{} ]) of traced region did not have observable data dependence with trace inputs; this probably indicates your program cannot be understood by the tracer.

I have fixed this bug in transforming to onnx format, This bug is due to the model intermediate values we used dictionary, but the model intermediate values can't use dictionary when onnx conversion, we modified the model structure, which makes the old checkpoint can't be used directly, so we will retrain it, please look forward to it!

gjhhust commented 3 days ago

I've fixed the turn onnx bug and trained the new checkpoint uploads,For more information, please read readme.md