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

transfrom_axis = [input[p] for p in perm] IndexError: list index out of range #72

Open
zhang0557kui opened this issue Nov 24, 2021 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@zhang0557kui
Copy link

File "D:\anaconda3\lib\site-packages\tflite2onnx\layout.py", line 27, in transform
output = transform(input, self.source, self.target)
File "D:\anaconda3\lib\site-packages\tflite2onnx\layout.py", line 16, in transform
transfrom_axis = [input[p] for p in perm]
File "D:\anaconda3\lib\site-packages\tflite2onnx\layout.py", line 16, in
transfrom_axis = [input[p] for p in perm]
IndexError: list index out of range
python-BaseException

@zhenhuaw-me
Copy link
Owner

Hi @zhang0557kui thank you for reporting this issue. Could you help to attach the model that triggers the error?
It seems to me that the model raised our semantic assumption somehow.

@zhenhuaw-me zhenhuaw-me added the bug Something isn't working label Dec 20, 2021
@zhenhuaw-me zhenhuaw-me changed the title error transfrom_axis = [input[p] for p in perm] IndexError: list index out of range Dec 21, 2021
@zhang0557kui
Copy link
Author

Hi @zhang0557kui thank you for reporting this issue. Could you help to attach the model that triggers the error? It seems to me that the model raised our semantic assumption somehow.

https://github.com/google/mediapipe/blob/master/mediapipe/modules/palm_detection/palm_detection_full.tflite

@Amadeus-AI
Copy link

Same issue when trying to convert palm_detection_full.

@Amadeus-AI
Copy link

It maybe a PReLu related issue
NVIDIA/TensorRT#310

@crazySyaoran
Copy link

crazySyaoran commented Jun 8, 2022

same issue when converting this model: https://github.com/google/mediapipe/tree/master/mediapipe/modules/face_landmark/face_landmark.tflite

I solved this probelm temporary by changing this two files in your lib code:

# tflite2onnx/tensor.py
...
    def transform(self):
        assert(self.status.parsed)
        assert(self.layout is not None)
        if self.isInitializer:
            data = self.data.reshape(self.shape)
            self.shape = self.layout.transform(self.shape)
            if(len(self.shape)<4):
                self.data = data.transpose([2,0,1])
            else:
                self.data = data.transpose(self.layout.perm)
        else:
            self.shape = self.layout.transform(self.shape)
...

and

# tflite2onnx/layout.py
...
def transform(input, ilayout: str, olayout: str):
    if (ilayout == olayout):
        return input

    perm = getPerm(ilayout, olayout)
    if(len(input) < 4):
        # print(input)
        transfrom_axis = [input[2], input[0], input[1]]
        # transfrom_axis =  [input[0], input[2], input[1]]
    else:
        transfrom_axis = [input[p] for p in perm]
    return transfrom_axis
...

By the way, I have another problem when converting another model: https://github.com/google/mediapipe/tree/master/mediapipe/modules/face_landmark/face_landmark_with_attention.tflite
cuz there's some "CUSTOM" ops, such as No.192, No.193. Is there any solutions to convert this tflite model?

thx.

@zhenhuaw-me
Copy link
Owner

@crazySyaoran Glad to hear that you resolved this issue!

I was assuming the two inputs of PReLU have the same rank, but they should be broadcastable. I think we can share the Binary.fakeBroadcast() with PReLU. Do you have time to try if the fakeBroadcast works for PReLU?

For custom ops, unfortunality, tflite2onnx cannot convert such ops as of now. But it's encouraged to introduce a design for custome operators and bridge to ONNX. As first step, we can take the custom op as blackbox - we don't care what the semantic of it, but only track the tensors of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants