xiaochus / MobileNetV3

A Keras implementation of MobileNetV3.
MIT License
236 stars 83 forks source link

Hi, #14

Open LucyGarlapati opened 4 years ago

LucyGarlapati commented 4 years ago

I tried Image classification using MobilenetV3 both small & large. How to do inference on test image. I am getting error saying "ValueError: Unknown activation function:_hard_swish"

rokopi-byte commented 3 years ago

you have to redefine the custom objects like hard_wish in your inference script and pass them to the load_model function

YuliyaLi commented 3 years ago

hi, did you solve this problem? i am still getting an error "TypeError: _hard_swish() missing 1 required positional argument: 'x'" when i pass the custom objects to the load_model function. Thanks.

rokopi-byte commented 3 years ago

Yes, this is what I did..

def relu6(x):
    """Relu 6
    """
    return K.relu(x, max_value=6.0)

def hard_swish(x):
    """Hard swish
    """
    return x * K.relu(x + 3.0, max_value=6.0) / 6.0

dependencies = {'_hard_swish': hard_swish,'_relu6': relu6}
model = load_model(model_path, custom_objects=dependencies)
YuliyaLi commented 3 years ago

Thanks a million!!!