HRNet / Lite-HRNet

This is an official pytorch implementation of Lite-HRNet: A Lightweight High-Resolution Network.
Apache License 2.0
819 stars 126 forks source link

onnx problem #50

Open jxncyym opened 3 years ago

jxncyym commented 3 years ago

how to convert to onnx, I meet the problem, assert target.dim() == 4 and target_weight.dim() == 3 AttributeError: 'NoneType' object has no attribute 'dim'

code: model = build_posenet(cfg.model) load_checkpoint(model, args.checkpoint, map_location='cpu') model = model.eval()

x = torch.randn((1,3,384,288))
target = torch.randn((1,4,384,288))
target_weight = torch.randn((1,4,1))
output_path = "onnx/lite_HRNet_960_1280.onnx"
torch.onnx.export(model,               # model being run
                x,                         # model input (or a tuple for multiple inputs)
                output_path,   # where to save the model (can be a file or file-like object)
                export_params=True,        # store the trained parameter weights inside the model file
                opset_version=11,          # the ONNX version to export the model to
                do_constant_folding=True,  # whether to execute constant folding for optimization
                input_names = ['inputx'],   # the model's input names
                output_names = ['outputy'], # the model's output names
                verbose=True,
                )

the error can refer: https://github.com/HRNet/Lite-HRNet/issues/23 @ycszen

jxncyym commented 3 years ago

another problem: RuntimeError: Only tuples, lists and Variables supported as JIT inputs/outputs. Dictionaries and strings are also accepted but their usage is not recommended. But got unsupported type float

AlexMinhao commented 2 years ago

Hi,

Have you solved this problem?

so0c commented 2 years ago

Hi, i faced same problem. have you solved this problem?

AnasArram commented 2 years ago

same issue here, any thoughts?

viet-hoang-99 commented 1 year ago

I have a repo that implement another way of Lite Hrnet (not dependent on mmpose apis) and i can convert model to onnx format. See my repo: https://github.com/viet-hoang-99/Lite_HRnet_vh