Code Monkey home page Code Monkey logo

Comments (19)

goldengrisha avatar goldengrisha commented on June 10, 2024 4

@mahirahzainipderas it looks like you're facing the problem of daying gradients with ReLu activation function (that what NaN means -- very small activations). If you use model.compile(loss=yolo_loss_func , optimizer=opt , metrics = ['accuracy']) the metric isn't correct in this context instead just orient your focus for decreasing loss.

    inp = Input(input_shape)

    model = MobileNetV2(
        input_tensor=inp, include_top=False, weights='imagenet')
    last_layer = model.output
    conv = Conv2D(512, (3, 3), activation=tf.nn.leaky_relu,
                  padding='same')(last_layer)
    conv = Dropout(0.4)(conv)
    bn = BatchNormalization()(conv)
    lr = LeakyReLU(alpha=0.1)(bn)
    conv = Conv2D(128, (3, 3), activation=tf.nn.leaky_relu, padding='same')(lr)
    conv = Dropout(0.4)(conv)
    bn = BatchNormalization()(conv)
    lr = LeakyReLU(alpha=0.1)(bn)
    conv = Conv2D(5, (3, 3), activation=tf.nn.leaky_relu, padding='same')(lr)
    final = Reshape((grid_h, grid_w, classes, info))(conv)

    model = Model(inp, final)


from text-detection-using-yolo-algorithm-in-keras-tensorflow.

HOD101s avatar HOD101s commented on June 10, 2024 1

@mahirahzainipderas it looks like you're facing the problem of daying gradients with ReLu activation function (that what NaN means -- very small activations). If you use model.compile(loss=yolo_loss_func , optimizer=opt , metrics = ['accuracy']) the metric isn't correct in this context instead just orient your focus for decreasing loss.

    inp = Input(input_shape)

    model = MobileNetV2(
        input_tensor=inp, include_top=False, weights='imagenet')
    last_layer = model.output
    conv = Conv2D(512, (3, 3), activation=tf.nn.leaky_relu,
                  padding='same')(last_layer)
    conv = Dropout(0.4)(conv)
    bn = BatchNormalization()(conv)
    lr = LeakyReLU(alpha=0.1)(bn)
    conv = Conv2D(128, (3, 3), activation=tf.nn.leaky_relu, padding='same')(lr)
    conv = Dropout(0.4)(conv)
    bn = BatchNormalization()(conv)
    lr = LeakyReLU(alpha=0.1)(bn)
    conv = Conv2D(5, (3, 3), activation=tf.nn.leaky_relu, padding='same')(lr)
    final = Reshape((grid_h, grid_w, classes, info))(conv)

    model = Model(inp, final)

Updating the activation functions worked for me. Thanks!

from text-detection-using-yolo-algorithm-in-keras-tensorflow.

Neerajj9 avatar Neerajj9 commented on June 10, 2024

I'll need some more info. Are you using the exact same code, data and loss function ?

from text-detection-using-yolo-algorithm-in-keras-tensorflow.

Tyre20 avatar Tyre20 commented on June 10, 2024

Everything is the same except for different dataset

from text-detection-using-yolo-algorithm-in-keras-tensorflow.

Tyre20 avatar Tyre20 commented on June 10, 2024

My accuracy shoot up to 100% after just one epoch

from text-detection-using-yolo-algorithm-in-keras-tensorflow.

jeewenjie avatar jeewenjie commented on June 10, 2024

Check your X.npy and Y.npy files. Make sure the data inside are clean (No '\n' or extra characters etc.) .

from text-detection-using-yolo-algorithm-in-keras-tensorflow.

Tyre20 avatar Tyre20 commented on June 10, 2024

I have the same error with the same dataset and code with loss of nan

from text-detection-using-yolo-algorithm-in-keras-tensorflow.

Randheer91 avatar Randheer91 commented on June 10, 2024

Screenshot from 2019-11-10 16-31-09
I have also face the same ERROR i.e., "val_loss did not improve from inf" and find accuracy and validation loss as "nan". Kindly suggest the proper solution for it. I have used the same code with the same dataset provided in your repository.

from text-detection-using-yolo-algorithm-in-keras-tensorflow.

benjastudio avatar benjastudio commented on June 10, 2024

I think that the code has been written for another version of python that you use (python 3)? I got the same problem. I took a look at the code, and a bit of work have to be done to make it compatible with python 2/3 (some division operators need to be fixed). Can you confirm @Neerajj9 ?

from text-detection-using-yolo-algorithm-in-keras-tensorflow.

goldengrisha avatar goldengrisha commented on June 10, 2024

I've got the same issue, any updates?

from text-detection-using-yolo-algorithm-in-keras-tensorflow.

goldengrisha avatar goldengrisha commented on June 10, 2024

The problem was in inactivation function 'relu' . It can be fix as: 'activation=tf.nn.leaky_relu' or 'activation=tf.nn.elu'. I've achived the same result after 100 epochs.

from text-detection-using-yolo-algorithm-in-keras-tensorflow.

mahirahzainipderas avatar mahirahzainipderas commented on June 10, 2024

can you explain more @goldengrisha ? I go both loss and val_loss nan and val_acc at 1. Seems incorrect for training data.

from text-detection-using-yolo-algorithm-in-keras-tensorflow.

noarotman avatar noarotman commented on June 10, 2024

Hi,
I am facing this problem now. I tried @goldengrisha tip but still got nan after the first step.
Any updates?

from text-detection-using-yolo-algorithm-in-keras-tensorflow.

goldengrisha avatar goldengrisha commented on June 10, 2024

Hello, @noarotman what version of TF do you use?

from text-detection-using-yolo-algorithm-in-keras-tensorflow.

noarotman avatar noarotman commented on June 10, 2024

@goldengrisha I use the version that was written in "readme" file: Tensorflow : 1.9.0
and I run this on CPU..

from text-detection-using-yolo-algorithm-in-keras-tensorflow.

goldengrisha avatar goldengrisha commented on June 10, 2024

@noarotman try switching to TF 2.1 and check the code above, it should work.

from text-detection-using-yolo-algorithm-in-keras-tensorflow.

noarotman avatar noarotman commented on June 10, 2024

@goldengrisha thanks I will try.
another issue is that when I try to run the yolo model I get this error:

image

from text-detection-using-yolo-algorithm-in-keras-tensorflow.

goldengrisha avatar goldengrisha commented on June 10, 2024

@noarotman, you're welcome, please check the last URL, it can be wrong.

from text-detection-using-yolo-algorithm-in-keras-tensorflow.

Neerajj9 avatar Neerajj9 commented on June 10, 2024

Hello everyone, the code was written in python3 and the exact versions mentioned in the README.md file. There might be some compatibility issues as @goldengrisha pointed out which might be because of a different version of tensorflow or keras. Also yes concentrate on the decreasing loss as against the 'accuracy' metric.

from text-detection-using-yolo-algorithm-in-keras-tensorflow.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.