Closed sun-yitao closed 5 years ago
@sun-yitao, The official documents say from keras.applications.xception import Xception
not from keras_applications.xception import Xception
.
Oh dear must have seen wrongly, will close this issue now
alternatively, you can use the following to interact with keras_applications directly. I had to do so to get access to ResNet101 that is unavailable through keras.applications for some reason.
import keras
import keras_applications
keras_applications.set_keras_submodules(
backend=keras.backend,
layers=keras.layers,
models=keras.models,
utils=keras.utils
)
@Kautenja, That can be one of the workarounds. Thank you.
FYI this no longer works, as the set_keras_submodules
function has been removed from keras_applications/__init__.py
@kkanellis Instead of using set_keras_submodules
, you can directly pass the keras submodules when you create the model, e.g.,
import keras
import keras_applications
resnet = keras_applications.resnet.ResNet101(
backend=keras.backend,
layers=keras.layers,
models=keras.models,
utils=keras.utils
)
@kkanellis Instead of using
set_keras_submodules
, you can directly pass the keras submodules when you create the model, e.g.,import keras import keras_applications resnet = keras_applications.resnet.ResNet101( backend=keras.backend, layers=keras.layers, models=keras.models, utils=keras.utils )
Model loads with this but later with doing inference with .predict() This gives this error: 'NoneType' object has no attribute 'image_data_format'
from keras_applications import resnet_common model = resnet_common.ResNet101(include_top=False, weights='imagenet', input_tensor=None, input_shape=None, pooling=None, classes=1000,backend=keras.backend, layers=keras.layers, models=keras.models, utils=keras.utils)
running as : Downloading data from https://github.com/keras-team/keras-applications/releases/download/resnet/resnet101_weights_tf_dim_ordering_tf_kernels_notop.h5 163840/171446536 [..............................] - ETA: 18:08:28
maybe it work on keras.version==2.2.4,keras_applications.version=1.0.8
Steps to replicate: (tried on MacOS Mojave and Windows 10)
conda create -n testenv tensorflow-gpu keras
works tooCreating a ResNeXt (keras applications 1.0.7) and Inception v3 model also gives the same error. I also tried installing keras and keras-applications using pip but same error again. Downgrading to keras 2.2.2 and everything will work properly.
Update: I found that this works:
However I'm not sure if this is the intended usage as the docs seem to be using the previous style of
from keras.applications.inception_v3 import InceptionV3