import numpy as np
import os
import time
from vgg16 import VGG16
from keras.preprocessing import image
from imagenet_utils import preprocess_input, decode_predictions
from keras.layers import Dense, Activation, Flatten
from keras.layers import merge, Input
from keras.models import Model
from keras.utils import np_utils
from sklearn.utils import shuffle
from sklearn.cross_validation import train_test_split
from keras.models import load_model
I was running a vgg model in my pc using Spyder everything was working fine, but when I tried running the code in Jupyter for using cloud gpu I got the following error:
>>>>>
ImportError Traceback (most recent call last)
<ipython-input-12-4398e37e021e> in <module>()
----> 1 from imagenet_utils import preprocess_input, decode_predictions
ImportError: No module named 'imagenet_utils'<<<
Why do I have this when its working fine in another IDE quite fine? I am using Jupyter for training the model in cloud using Floyd web service.
Try importing it like:
from keras.applications.vgg16 import preprocess_input, decode_prediction
This is the standard way according to the Keras Applications doc page. More reference about Keras Applications can be found there also.
Note: Be aware that it is decode_prediction
and not decode_predictions
in plural.
As opposed to the older versions of keras (or tensorflow), you will need to be model-specific while importing imagenet_utils functions preprocess_input and decode_predictions.
For example, if you're working with Tensorflow 2 and working with ResNet50, you will have to do it in following manner
from tensorflow.keras.applications.resnet50 import decode_predictions, preprocess_input
In this case it is decode_predictions (plural) and not decode_prediction. Similar for VGG16 and other models
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With