Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

MobileNetV3 #183

Open
CRosero opened this issue May 4, 2020 · 7 comments
Open

MobileNetV3 #183

CRosero opened this issue May 4, 2020 · 7 comments

Comments

@CRosero
Copy link

CRosero commented May 4, 2020

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?

@Scottchou7
Copy link

I think they haven't updated "mobilenet_v3.py" file in keras and TF. But I successsfully import MobileNetV3Small in my keras project.

  1. 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.

  2. from keras_applications.mobilenet_v3 import MobileNetV3Small

  3. model = = MobileNetV3Small(
    weights='imagenet',
    include_top=False,
    input_shape=(128, 128, 3),
    backend=keras.backend,
    layers=keras.layers,
    models=keras.models,
    utils=keras.utils)

@espetro
Copy link

espetro commented May 11, 2020

Another way to do what @Scottchou7 does is:

  1. Uninstall your local keras-applications (pip uninstall keras-applications).
  2. Then install it via git (pip install git+https://github.com/keras-team/keras-applications.git@master).
  3. 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

@anilsathyan7
Copy link

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)

@lovejing0306
Copy link

Another way to do what @Scottchou7 does is:

  1. Uninstall your local keras-applications (pip uninstall keras-applications).
  2. Then install it via git (pip install git+https://github.com/keras-team/keras-applications.git@master).
  3. 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'

@CRosero
Copy link
Author

CRosero commented Jun 10, 2020

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

@woctezuma
Copy link

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>.

@andreped
Copy link

andreped commented Jun 5, 2022

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:
keras-team/tf-keras#575

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants