Keras-retinanet: ImportError: No module named 'keras_resnet'

Created on 25 Jun 2018  路  14Comments  路  Source: fizyr/keras-retinanet

/home/keras-retinanet-master/keras_retinanet/models/resnet.py in ()
16
17 import keras
---> 18 import keras_resnet
19 import keras_resnet.models
20 from . import retinanet

ImportError: No module named 'keras_resnet'

Most helpful comment

I had the same issue, I hadn't understood that keras_resnet is a python module. You can directly install this by using pip install keras-resnet

All 14 comments

Did you run pip install . --user just like manual says?

I had the same issue, I hadn't understood that keras_resnet is a python module. You can directly install this by using pip install keras-resnet

Closing this issue. If the instructions in README.md don't work, feel free to comment here and we'll re-open.

Hello all,
Im getting this error while importing the correct module
No module named 'keras_retinanet.utils.compute_overlap'.Can anyone please help me here?

Completely different issue. Also, check the README.

Here is the code snippet:

model_path = os.path.join('..', 'snapshots', 'resnet50_coco_best_v2.1.0.h5')

load retinanet model

model = models.load_model(model_path, backbone_name='resnet50')

if the model is not converted to an inference model, use the line below

see: https://github.com/fizyr/keras-retinanet#converting-a-training-model-to-inference-model

model = models.load_model(model_path, backbone_name='resnet50', convert_model=True)

print(model.summary())

load label to names mapping for visualization purposes

labels_to_names = {0: 'person', 1: 'bicycle', 2: 'car', 3: 'motorcycle', 4: 'airplane', 5: 'bus', 6: 'train', 7: 'truck', 8: 'boat', 9: 'traffic light', 10: 'fire hydrant', 11: 'stop sign', 12: 'parking meter', 13: 'bench', 14: 'bird', 15: 'cat', 16: 'dog', 17: 'horse', 18: 'sheep', 19: 'cow', 20: 'elephant', 21: 'bear', 22: 'zebra', 23: 'giraffe', 24: 'backpack', 25: 'umbrella', 26: 'handbag', 27: 'tie', 28: 'suitcase', 29: 'frisbee', 30: 'skis', 31: 'snowboard', 32: 'sports ball', 33: 'kite', 34: 'baseball bat', 35: 'baseball glove', 36: 'skateboard', 37: 'surfboard', 38: 'tennis racket', 39: 'bottle', 40: 'wine glass', 41: 'cup', 42: 'fork', 43: 'knife', 44: 'spoon', 45: 'bowl', 46: 'banana', 47: 'apple', 48: 'sandwich', 49: 'orange', 50: 'broccoli', 51: 'carrot', 52: 'hot dog', 53: 'pizza', 54: 'donut', 55: 'cake', 56: 'chair', 57: 'couch', 58: 'potted plant', 59: 'bed', 60: 'dining table', 61: 'toilet', 62: 'tv', 63: 'laptop', 64: 'mouse', 65: 'remote', 66: 'keyboard', 67: 'cell phone', 68: 'microwave', 69: 'oven', 70: 'toaster', 71: 'sink', 72: 'refrigerator', 73: 'book', 74: 'clock', 75: 'vase', 76: 'scissors', 77: 'teddy bear', 78: 'hair drier', 79: 'toothbrush'}
Can anyone help ?

README

Followed the README but not able to solve.

I've succesfully exposed a virtualenv to my jupyter-notebook server and installed keras-retinanet with pip install . --user but I get ImportError: No module named keras_retinanet when running the example notebook . I moved it to the root directory and now I get ImportError: No module named keras_resnet.

When I use that same virtualenv in a python3 console importing keras_retinanet works fine. Importing keras_resnet also works fine using the virtualenv outside of a notebook. My virtualenv kernel is available to choose from the list of kernels in jupyter-notebook's web interface and I've been training and validating models (automatic validation after each epoch) with the train.py script for over a week so I am sure the keras_resnet module is installed. BTW I since I'm using a virtualenv I had to remove the --user flag from the repo install command (pip install . --user) to work.

This is the output of pip list:

Package                Version  
---------------------- ---------
absl-py                0.3.0    
astor                  0.7.1    
bleach                 1.5.0    
Cython                 0.28.5   
enum34                 1.1.6    
gast                   0.2.0    
grpcio                 1.13.0   
h5py                   2.8.0    
html5lib               0.9999999
Keras                  2.2.2    
Keras-Applications     1.0.4    
Keras-Preprocessing    1.0.2    
keras-resnet           0.1.0    
keras-retinanet        0.4.1    
Markdown               2.6.11   
numpy                  1.15.0   
opencv-python          3.4.2.17 
Pillow                 5.2.0    
pip                    18.0     
protobuf               3.6.0    
PyYAML                 3.13     
scipy                  1.1.0    
setuptools             39.1.0   
six                    1.11.0   
tensorboard            1.9.0    
tensorflow             1.9.0    
tensorflow-gpu         1.4.0    
tensorflow-tensorboard 0.4.0    
termcolor              1.1.0    
Werkzeug               0.14.1   
wheel                  0.31.1 

My system defaults to using tensorflow-gpu and I'm using version 1.4.0 to avoid upgrading my CUDA toolkit to version to 9+ (which is required for tensorflow-gpu >= v1.5).I'm just making the clarification in case you need to know but I am sure my TF install is not the problem - I could be wrong though...

Can anyone shed some light about what is going on?

@de-vri-es Still not able to use keras-retinanet with jupyter-notebook. Can this be reopened?

I'm sorry but we can't help everyone setting up their python environment correctly. I would recommend starting with a clean environment and follow the installation steps from their (adjusted for virtualenv as you indicated).

If the virtualenv works with a python shell, but not jupyter-notebook, it would seem that jupyter-notebook is either ignoring the virtualenv or maybe even using python2. But why and/or how to fix that is really out of scope for this issue tracker. Maybe stackoverflow or slack can help.

ModuleNotFoundError: No module named 'Backbone'
while running resnet.py
I followed the README instruction

from models import load_model ---> is successful but
model = load_model('/path/to/model.h5', backbone_name='resnet50') ---> it raises an error
Traceback (most recent call last):
File "", line 1, in
File "C:UsersPrisillaDesktopCNN11Bounding BoxesSatellite_imagesNewmode
ls__init__.py", line 83, in load_model
return models.load_model(filepath, custom_objects=backbone(backbone_name).cu
stom_objects)
File "C:UsersPrisillaDesktopCNN11Bounding BoxesSatellite_imagesNewmode
ls__init__.py", line 53, in backbone
from resnet import ResNetBackbone as b
ModuleNotFoundError: No module named 'resnet'
>

Actually resnet50 itself is not present in the keras-retinanet
backbone_name='resnet50'
Can we use backbone_name='resnet'?

I had the same issue, I hadn't understood that keras_resnet is a python module. You can directly install this by using pip install keras-resnet

It works.. Thanklyou

Was this page helpful?
0 / 5 - 0 ratings