Giter Site home page Giter Site logo

Comments (4)

zxj11838 avatar zxj11838 commented on May 17, 2024

I also found the same problem, this may be the reason why the network training loss is nan

from tensorflow-yolov4-tflite.

robisen1 avatar robisen1 commented on May 17, 2024

I also found the same problem, this may be the reason why the network training loss is nan

do you have a solution to the issue?

from tensorflow-yolov4-tflite.

zxj11838 avatar zxj11838 commented on May 17, 2024

I have changed,
left_up = tf.maximum(boxes1_coor[..., :2], boxes1_coor[..., :2])
to:
left_up = tf.maximum(boxes1_coor[..., :2], boxes2_coor[..., :2])

But the loss of training is still nan.

from tensorflow-yolov4-tflite.

rubencardenes avatar rubencardenes commented on May 17, 2024

Yes, that function is definitely wrong. I changed that line to compute left_up coordinates, as well as the right_down coordinates. I also found in some implementations the iou is computed using the maximum between the value and an epsilon as this:

def bbox_iou(boxes1, boxes2):

    boxes1_area = boxes1[..., 2] * boxes1[..., 3]
    boxes2_area = boxes2[..., 2] * boxes2[..., 3]

    boxes1_coor = tf.concat([boxes1[..., :2] - boxes1[..., 2:] * 0.5,
                             boxes1[..., :2] + boxes1[..., 2:] * 0.5], axis=-1)
    boxes2_coor = tf.concat([boxes2[..., :2] - boxes2[..., 2:] * 0.5,
                             boxes2[..., :2] + boxes2[..., 2:] * 0.5], axis=-1)

    left_up    = tf.maximum(boxes1_coor[..., :2], boxes2_coor[..., :2])
    right_down = tf.minimum(boxes1_coor[..., 2:], boxes2_coor[..., 2:])

    inter_section = tf.maximum(right_down - left_up, 0.0)
    inter_area = inter_section[..., 0] * inter_section[..., 1]
    union_area = boxes1_area + boxes2_area - inter_area
    iou       = tf.maximum(1.0 * inter_area / union_area, np.finfo(np.float32).eps)

    return iou

from tensorflow-yolov4-tflite.

Related Issues (20)

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.