broadinstitute / keras-rcnn

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

TypeError: __int__ returned non-int (type NoneType) #125

Open hiteshnitetc opened 6 years ago

hiteshnitetc commented 6 years ago

Hello, On running following code getting some error: code:

import keras_rcnn.datasets
import keras_rcnn.preprocessing
def load_data():
    return keras_rcnn.datasets.load_data("malaria")
training, test = load_data()
generator = keras_rcnn.preprocessing.ObjectDetectionGenerator()
classes = {
    "rbc": 1,
    "not":2
}
generator = generator.flow(training, classes)
import keras.layers
import keras_rcnn.models
from keras import layers
from keras.layers import Input
image = keras.layers.Input((448, 448, 3))
model = keras_rcnn.models.RCNN(image, classes=len(classes) + 1)

error:

Traceback (most recent call last):

  File "<ipython-input-21-3713c0787a05>", line 1, in <module>
    model = keras_rcnn.models.RCNN(image, classes=len(classes) + 1)

  File "/home/nd/anaconda3/lib/python3.6/site-packages/keras_rcnn-0.0.2-py3.6.egg/keras_rcnn/models.py", line 173, in __init__
    outputs = _train(classes, training_options)(inputs)

  File "/home/nd/anaconda3/lib/python3.6/site-packages/keras_rcnn-0.0.2-py3.6.egg/keras_rcnn/models.py", line 137, in f
    scores = keras_rcnn.layers.RPNClassificationLoss(9)([scores, rpn_labels])

  File "/home/nd/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py", line 596, in __call__
    output = self.call(inputs, **kwargs)

  File "/home/nd/anaconda3/lib/python3.6/site-packages/keras_rcnn-0.0.2-py3.6.egg/keras_rcnn/layers/losses/_rpn.py", line 19, in call
    loss = self.compute_loss(output, target)

  File "/home/nd/anaconda3/lib/python3.6/site-packages/keras_rcnn-0.0.2-py3.6.egg/keras_rcnn/layers/losses/_rpn.py", line 34, in compute_loss
    loss = keras.backend.sparse_categorical_crossentropy(target, output)

  File "/home/nd/anaconda3/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 2779, in sparse_categorical_crossentropy
    logits = tf.reshape(output, [-1, int(output_shape[-1])])

TypeError: __int__ returned non-int (type NoneType)

How to solve it.

hiteshnitetc commented 6 years ago

Waiting for response

jhung0 commented 6 years ago

Do you have the newest version? I can't replicate

hiteshnitetc commented 6 years ago

ok. I will update and let you know.

On Wed, Nov 15, 2017 at 4:12 AM, Jane Hung notifications@github.com wrote:

Do you have the newest version? I can't replicate

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/broadinstitute/keras-rcnn/issues/125#issuecomment-344424460, or mute the thread https://github.com/notifications/unsubscribe-auth/AdMpSon_UV3BwD3X2PDvIWpKaKnPX8nYks5s2hdZgaJpZM4QU2Hn .

hiteshnitetc commented 6 years ago

Currently i am using Keras 2.0.6 with anaconda python 3.6.

On Wed, Nov 15, 2017 at 9:49 AM, Hitesh Tekchandani (Ph.D. Student ) < htekchandani.phd2016.etc@nitrr.ac.in> wrote:

ok. I will update and let you know.

On Wed, Nov 15, 2017 at 4:12 AM, Jane Hung notifications@github.com wrote:

Do you have the newest version? I can't replicate

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/broadinstitute/keras-rcnn/issues/125#issuecomment-344424460, or mute the thread https://github.com/notifications/unsubscribe-auth/AdMpSon_UV3BwD3X2PDvIWpKaKnPX8nYks5s2hdZgaJpZM4QU2Hn .

satchmo233 commented 5 years ago

I get a same question with u! And i just want to know how did solve this bug...Asking for help~~

hiteshnitetc commented 5 years ago

@satchmo233 still unable to solve problem

satchmo233 commented 5 years ago

@hiteshnitetc I have solve my problem.It because keras package the network. So i cant change the network directly. I just suggest u check about the code when data is entered. Hope it can do help you.

hiteshnitetc commented 5 years ago

@satchmo233 can't understand your solution advice. please elaborate it.