keras-team / keras-applications

Reference implementations of popular deep learning models.
Other
2k stars 910 forks source link

Remove a contradict exception in MobileNet and V2 #94

Closed taehoonlee closed 5 years ago

taehoonlee commented 5 years ago

This PR removes a contradict exception in MobileNet and MobileNetV2. They are already able to take input_shape=None, include_top=False. In other words, inferences for arbitrary input shapes are possible as follows.

import numpy as np
from keras.applications.mobilenet_v2 import MobileNetV2

x = np.random.random((1, 224, 448, 3)).astype(np.float32)
mobilenet1 = MobileNetV2(input_shape=None, include_top=False)
print(mobilenet1.predict(x).shape)  # (1, 7, 14, 1280)

But currently, it is impossible to even create a model with the below form.

mobilenet2 = MobileNetV2(input_shape=(224, 448, 3), include_top=False)

This PR enables users to create a model with a non-square static input shape.

taehoonlee commented 5 years ago

The issue was reported in #92 by @see--. Thank you @see--.