TypeError: list indices must be integers or slices, not str error while trying to convert using ONNX

Viewed 105

I am trying to convert this PyTorch model into TFLite using ONNX

class PoseHighResolutionNet(nn.Module):

def __init__(self, cfg, **kwargs):
    self.inplanes = 64
    extra = cfg['MODEL']['EXTRA']
    super(PoseHighResolutionNet, self).__init__()

    # stem net
    self.conv1 = nn.Conv2d(3, 64, kernel_size=3, stride=2, padding=1,
                           bias=False)
    self.bn1 = nn.BatchNorm2d(64, momentum=BN_MOMENTUM)
    self.conv2 = nn.Conv2d(64, 64, kernel_size=3, stride=2, padding=1,
                           bias=False)

but I keep getting this error

 Traceback (most recent call last):
  File "pose_hrnet.py", line 504, in <module>
    trained_model=PoseHighResolutionNet()
  File "pose_hrnet.py", line 278, in __init__
    extra = cfg['MODEL']['EXTRA']
TypeError: list indices must be integers or slices, not str

I need to pass some parameters in this

trained_model=PoseHighResolutionNet()
trained_model.load_state_dict(torch.load('pose_hrnet_w32_384x288.pth'))

but I am not sure what.

Any help is appreciated. Thanks in advance.

0 Answers
Related