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

Support for More Layers #13

Open
frytoli opened this issue Mar 1, 2022 · 1 comment
Open

Support for More Layers #13

frytoli opened this issue Mar 1, 2022 · 1 comment

Comments

@frytoli
Copy link

frytoli commented Mar 1, 2022

Firstly, nice work on this project -- this looks really cool!

I'm working on a computer vision project, and would love to use Konverter to convert some pre-trained models. As such, these models include ZeroPadding2D layers. Because this layer type isn't supported, when I run Konverter on the model (yes I tried anyway haha) this is the resulting traceback and error:

Traceback (most recent call last):
File "test.py", line 14, in
konverter.konvert(os.path.join(os.getcwd(), 'models_eynollah', 'model_page_mixed_best.h5'), output_file=os.path.join(os.getcwd(), 'models', 'page_mixed_best.py'))
File "/venv/lib/python3.7/site-packages/konverter/init.py", line 20, in init
no_watermark=no_watermark)
File "/venv/lib/python3.7/site-packages/konverter/init.py", line 41, in _konvert
self.start()
File "/venv/lib/python3.7/site-packages/konverter/init.py", line 45, in start
self.get_layers()
File "/venv/lib/python3.7/site-packages/konverter/init.py", line 214, in get_layers
layer = support.get_layer_info(layer, next_layer)
File "/venv/lib/python3.7/site-packages/konverter/utils/konverter_support.py", line 104, in get_layer_info
layer_class.info.activation = self._get_layer_activation(layer)
File "/venv/lib/python3.7/site-packages/konverter/utils/konverter_support.py", line 80, in _get_layer_activation
if hasattr(layer.activation, '_keras_api_names'):
AttributeError: 'ZeroPadding2D' object has no attribute 'activation'

Do you have any advice for how I could add functionality for more layers and/or would you consider adding support for more layers?

Thanks!

@sshane
Copy link
Owner

sshane commented Mar 25, 2022

Sorry for the late response, I haven't been working on this project for a while now! I would love to add support for new layers, but because I'm not actively using the project (for now), I have no need to add anything else.

Two things I would love someone to attempt a PR for are:

  • Support for functional models with multiple inputs and outputs
  • Support for new layers, especially convolutional types for images and video

If you attempt this, check out https://github.com/sshane/Konverter/blob/master/konverter/utils/model_attributes.py to see how I've defined the code for each activation/layer and try to add your own. The main code to parse each layer is here: https://github.com/sshane/Konverter/blob/master/konverter/utils/konverter_support.py#L91, however, it's super messy and not really well abstracted away, so you might want to do that at the same time so it doesn't get unwieldy. Good luck if you try anything! I can review and help on PRs as well.

@sshane sshane added enhancement New feature or request layer support and removed enhancement New feature or request labels Mar 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants