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

kwargs not supported #230

Open
bonlime opened this issue Oct 17, 2019 · 5 comments
Open

kwargs not supported #230

bonlime opened this issue Oct 17, 2019 · 5 comments

Comments

@bonlime
Copy link

bonlime commented Oct 17, 2019

This issue occurs for all models in the repo but i'll explain it in case of Unet
If you try to pass any additional arguments to Unet model, they get into **kwargs and are passed to keras_applications.get_submodules_from_kwargs function

backend, layers, models, keras_utils = get_submodules_from_kwargs(kwargs)

which DOESN'T allow any extra arguments! and raises TypeError
https://github.com/keras-team/keras-applications/blob/71acdcd98088501247f4b514b7cbbdf8182a05a4/keras_applications/__init__.py#L13-L21
it makes the following line useless:

I think the easiest way to fix this issue is to write a custom get_submodules_from_kwargs function. I can make PR if you find it helpfull

@qubvel
Copy link
Owner

qubvel commented Oct 17, 2019

Hi @bonlime
What is the case you want to pass additional kwargs?
I guess only mobilenet support additional arguments

@qubvel
Copy link
Owner

qubvel commented Oct 17, 2019

I would be glad to fix it with your PR 👍

@bonlime
Copy link
Author

bonlime commented Oct 17, 2019

I'm passing input_tensor argument. all backbone models accept it

@JonnoFTW
Copy link

I'm using the latest code from github and get an error later on about backend being NoneType. I got it working with:

from keras import layers, utils, models
from segmentation_models.models import unet
model = unet.Unet('efficientnetb3', classes=num_classes, activation='softmax',
                     backend=K, layers=layers, utils=utils, models=models)

@qubvel
Copy link
Owner

qubvel commented Oct 22, 2019

@JonnoFTW Do not import Unet from .models, look at example in readme

qubvel pushed a commit that referenced this issue Apr 17, 2020
* Allow passing keyword arguments to backbone models

* Rename function get_submodules_args to improve readability

Co-authored-by: Peter Sluka <[email protected]>
lukfischer added a commit to SCCH-KVS/segmentation_models that referenced this issue May 11, 2020
Allow passing keyword arguments to backbone models (qubvel#230) (qubvel#291)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants