Open CRosero opened 4 years ago
I think they haven't updated "mobilenet_v3.py" file in keras and TF. But I successsfully import MobileNetV3Small in my keras project.
Copy "mobilenet_v3.py" file and put it in your local "keras_applications" folder. For example I use anaconda: C:\user\AppData\Local\conda\conda\envs\Your Environment Name\Lib\site-packages\keras_applications.
from keras_applications.mobilenet_v3 import MobileNetV3Small
model = = MobileNetV3Small( weights='imagenet', include_top=False, input_shape=(128, 128, 3), backend=keras.backend, layers=keras.layers, models=keras.models, utils=keras.utils)
Another way to do what @Scottchou7 does is:
keras-applications
(pip uninstall keras-applications
).pip install git+https://github.com/keras-team/keras-applications.git@master
).keras_applications
submodule:
from keras.applications.keras_applications import keras_applications
from keras_applications.mobilenet_v3 import MobileNetV3
Mobilenetv3 is available in latest keras version; but it's not available officially with tf.keras as of now.
First install latest keras-applications as mentioned by @espetro . Now, to use mobilenetv3(large) with tf.keras/tf2 for transfer learning:
mnv3=keras.applications.keras_applications.mobilenet_v3.MobileNetV3Large(input_shape=(224, 224, 3),alpha=1.0, minimalistic=True, include_top=False, weights='imagenet', backend=tf.keras.backend, layers=tf.keras.layers, models=tf.keras.models, utils=tf.keras.utils)
Another way to do what @Scottchou7 does is:
- Uninstall your local
keras-applications
(pip uninstall keras-applications
).- Then install it via git (
pip install git+https://github.com/keras-team/keras-applications.git@master
).- For an unknown reason, MobileNetV3 is only directly visible from
keras_applications
submodule:from keras.applications.keras_applications import keras_applications from keras_applications.mobilenet_v3 import MobileNetV3
I use you way, but is wrong
>>> from keras.applications.keras_applications import keras_applications
Using TensorFlow backend.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'keras.applications.keras_applications'
Seeing as how sadly there has been no response from the Keras team regarding this, I contacted TF and this is the response I received
For reference, the solution offered in the Tensforflow thread consists in:
!pip install tf-nightly
Then:
import tensorflow as tf
tf.keras.applications.MobileNetV3Small
returns <function tensorflow.python.keras.applications.mobilenet_v3.MobileNetV3Small>
.
Has anyone here tried to use MobileNetV3 in keras.applications with TimeDistributed?
I am having some challenges (Python 3.8.10, keras-nightly==2.10.x).
To reproduce error:
import keras
from keras.applications import MobileNetV2, MobileNetV3Small, ConvNeXtSmall
input_ = keras.layers.Input(shape=(8, 224, 224, 3))
# base_model = MobileNetV2(include_top=True, input_shape=(224, 224, 3))
base_model = MobileNetV3Small(include_top=True, input_shape=(224, 224, 3))
output = keras.layers.TimeDistributed(base_model)(input_)
model = keras.Model(inputs=input_, outputs=output)
More details on error, logs, and other stuff can be seen here: https://github.com/keras-team/tf-keras/issues/575
I want to do transfer learning using MobileNetV3. I see on here that MobileNetV3 is available, but I don't see it either in the Keras website or on TF. Why is this?