AlexanderLutsenko / nobuco

Pytorch to Keras/Tensorflow/TFLite conversion made intuitive
MIT License
272 stars 17 forks source link

I am getting 'Unimplemented nodes' exception #20

Closed kiyanisarah closed 8 months ago

kiyanisarah commented 10 months ago

I am trying to convert my Detr model but i am getting this error: Traceback (most recent call last): File "===/DETR/nobuco_script.py", line 32, in keras_model = nobuco.pytorch_to_keras( File "==/DETR/env/lib/python3.10/site-packages/nobuco/convert.py", line 331, in pytorch_to_keras raise Exception('Unimplemented nodes') Exception: Unimplemented nodes

using these checkpoints to convert: CHECKPOINT = "TahaDouaji/detr-doc-table-detection"

AlexanderLutsenko commented 10 months ago

Hi! Could you provide a minimal reproducible example? Another thing is to set save_trace_html=True and send me trace.html.

kiyanisarah commented 10 months ago

Hi! Could you provide a minimal reproducible example? Another thing is to set save_trace_html=True and send me trace.html.

Here are the contents of the html file as txt: trace.txt

AlexanderLutsenko commented 10 months ago

Ah, I see. There was a bunch of problems in specific node converters (namely, sin/cos, truncated div, cumsum). Fixed those in v0.11.2. I don't know where your DETR comes from, so I tested on an implementation from transformers lib, which looks pretty similar. Try this example code, does it work for you?

I also noticed all of your Conv2d and MaxPool2d layers are broken. This is a separate issue, probably due to incompatible version of cudnn/cudatoolkit (see here). To confirm this, try disabling your GPU:

import os
os.environ["CUDA_VISIBLE_DEVICES"] = ""
kiyanisarah commented 10 months ago

Now i'm getting this error: Traceback (most recent call last): File "nobuco_script.py", line 43, in keras_model = nobuco.pytorch_to_keras( File "/DETR/env/lib/python3.8/site-packages/nobuco/convert.py", line 336, in pytorch_to_keras outputs_tf = keras_op(*args_tf, kwargs_tf) File "/DETR/env/lib/python3.8/site-packages/nobuco/layers/container.py", line 69, in call outputs = op(*args, *kwargs) File "/DETR/env/lib/python3.8/site-packages/nobuco/layers/container.py", line 69, in call outputs = op(args, kwargs) File "/DETR/env/lib/python3.8/site-packages/nobuco/layers/container.py", line 69, in call outputs = op(*args, *kwargs) [Previous line repeated 2 more times] File "/DETR/env/lib/python3.8/site-packages/nobuco/layers/channel_order.py", line 59, in call outputs = self.func(args, **kwargs) File "/DETR/env/lib/python3.8/site-packages/nobuco/node_converters/convolution.py", line 142, in func output = conv(input) File "/DETR/env/lib/python3.8/site-packages/keras/src/utils/traceback_utils.py", line 70, in error_handler raise e.with_traceback(filtered_tb) from None File "/DETR/env/lib/python3.8/site-packages/keras/src/engine/base_layer.py", line 1832, in set_weights raise ValueError( ValueError: Layer conv2d weight shape (7, 7, 800, 64) is not compatible with provided weight shape (7, 7, 3, 64).

but i think i can get around this problem. Thankyou so much for the help :)

AlexanderLutsenko commented 10 months ago

ValueError: Layer conv2d weight shape (7, 7, 800, 64) is not compatible with provided weight shape (7, 7, 3, 64).

That could be because the second input to the DetrForObjectDetection model (pixel_mask) should be of same size as the image.