broadinstitute / keras-rcnn

Keras package for region-based convolutional neural networks (RCNNs)
Other
555 stars 222 forks source link

object of type 'int' has no len() #182

Closed jmd9019 closed 6 years ago

jmd9019 commented 6 years ago

Running on jupyter with python 3.6 anaconda environment

TypeError Traceback (most recent call last)

in () 3 from keras_rcnn.models import RCNN 4 img_in = Input((None, None, 3)) ----> 5 rcnn_model = RCNN(img_in, 2) 6 optimizer = keras.optimizers.Adam(0.0001) 7 rcnn_model.compile(optimizer) ~/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/keras_rcnn-0.0.2-py3.6.egg/keras_rcnn/models/_rcnn.py in __init__(self, input_shape, categories, anchor_aspect_ratios, anchor_base_size, anchor_scales, anchor_stride, backbone, dense_units, mask_shape, maximum_proposals, minimum_size) 123 anchor_scales = [4, 8, 16] 124 --> 125 n_categories = len(categories) + 1 126 127 k = len(anchor_aspect_ratios) * len(anchor_scales) TypeError: object of type 'int' has no len()
jhung0 commented 6 years ago

Try to input a dictionary instead of an integer into RCNN, e.g. model = keras_rcnn.models.RCNN((224, 224, 3), ["circle", "rectangle", "triangle"])

0x00b1 commented 6 years ago

Closing. @jmd9019 Let me know if @jhung0's comment did not resolve your issue.

0x00b1 commented 6 years ago

I also apologize for the API instability. @jhung0 and I are in the process of (semi-) stabilizing the object detection API. I'll also look at stabilizing the image segmentation API soon.

jmd9019 commented 6 years ago

@0x00b1 @jhung0 comment did not work still facing the same issue.

One more question is this issue is because of I am running on aws ec2 instance in jupyter??

jhung0 commented 6 years ago

No, that's not an issue. Do you have everything updated? Have you tried what's in the readme?

jmd9019 commented 6 years ago

Yes everything is updated but haven't tried as given in readme. And I tried in Kaggle there was no issue. But I am getting this error when running on aws so i asked the above question

jhung0 commented 6 years ago

Is it really the same error? If you input a dictionary, I'm not sure why it would give you TypeError: object of type 'int' has no len()

jmd9019 commented 6 years ago

No getting different error now

codes:

import keras from keras.layers import Input from keras_rcnn.models import RCNN

img_in = Input((None, None, 3)) rcnn_model = RCNN((225,225, 2),["circle", "rectangle", "triangle"]) optimizer = keras.optimizers.Adam(0.0001) rcnn_model.compile(optimizer) print('Input:', rcnn_model.get_input_shape_at(0)) print('Output:', rcnn_model.get_output_shape_at(0))

Error:

in () 1 import keras 2 from keras.layers import Input ----> 3 from keras_rcnn.models import RCNN 4 5 img_in = Input((None, None, 3)) ~/notebook/keras-rcnn/keras_rcnn/models/__init__.py in () ----> 1 from ._rcnn import RCNN ~/notebook/keras-rcnn/keras_rcnn/models/_rcnn.py in () 4 5 import keras_rcnn.layers ----> 6 import keras_rcnn.models.backbone 7 8 ~/notebook/keras-rcnn/keras_rcnn/models/backbone.py in () 2 3 import keras ----> 4 import keras_resnet.models 5 6 ModuleNotFoundError: No module named 'keras_resnet' I actually updated my keras-rcnn local repo using git pull command after update its show this error