question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GIoULoss doesn't go below 1

See original GitHub issue

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Ubuntu 18.04 LTS
  • TensorFlow version and how it was installed (source or binary): 2.1.0 (binary)
  • TensorFlow-Addons version and how it was installed (source or binary):0.7.1 (binary)
  • Python version: 3.6.9
  • Is GPU used? (yes/no): yes

Describe the bug I am using the GIoULoss to train a small CNN using keras which predicts the (x,y) of a bounding box. The training starts with loss at 1.04 and stops decreasing after 1.0. I tried changing the architecture and epochs but it gets stuck at val_loss=1.0

Code to reproduce the issue

def PreprocessLabels(row,col,rad):
    # Convert (row,col) & radius to (x1,y1) & (x2,y2)
    # This helps us to shape the problem as bounding box prediction problem
    # where we can use GIoU as our loss function.
    x1 = int(row)-int(rad)
    y1 = int(col)-int(rad)
    x2 = int(row)+int(rad)
    y2 = int(col)+int(rad)
    return [y1,x1,y2,x2]

    def DataGenerator(FileList,mode='train'):
        DataInput, DataLabels = [],[]
            for img_name in FileList:
                img = cv2.imread(img_name,2)
                row,col,rad = img_name.split("_")[2:]
                rad = rad.split(".")[0]
                DataInput.append(img)
                DataLabels.append(PreprocessLabels(row,col,rad))
        return np.expand_dims(np.array(DataInput),axis=3),np.array(DataLabels)


def Model():
    model = Sequential()
    model.add(Conv2D(64,kernel_size=3,activation='relu',input_shape=(200,200,1)))
    model.add(Conv2D(64,kernel_size=5,activation='relu'))
    model.add(Conv2D(32,kernel_size=3,activation='relu'))
    model.add(Flatten())
    model.add(Dense(4,activation='linear',use_bias=False,kernel_initializer="he_normal"))
    return model

FileList = glob("images/*.png")
x,y = DataGenerator(FileList)

model = Model()
model.compile(optimizer='adam',loss=GIoULoss())
model.fit(x,y,batch_size=64,epochs=10,verbose=1,validation_split=0.2,shuffle=True,)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
betamoocommented, Jan 19, 2021

I am having the same problem as well, the loss reaches 1 and stays there!

1reaction
FabianMoenkebergcommented, Feb 11, 2021

Same problem here…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Different IoU Losses for Faster and Accurate Object Detection
GIoU loss solves vanishing gradients for non-overlapping cases but has slow convergence and inaccurate regression, especially for the boxes with ...
Read more >
A Metric and A Loss for Bounding Box Regression
In this paper, we only focus on 2D object detection where we can easily derive an analytical solution for GIoU to apply it...
Read more >
Focal and Efficient IOU Loss for Accurate Bounding ... - arXiv
C is the smallest convex box C ⊆ S ∈ Rn enclosing both A and B and IOU = |A ∩ B|/|A ∪...
Read more >
Keras Loss Functions: Everything You Need to Know
In deep learning, the loss is computed to get the gradients with respect to model weights and update those weights accordingly via ...
Read more >
Focal and Efficient IOU Loss for Accurate Bounding Box ...
So far, most of loss functions for BBR fall into two categories: -2. -1. 0. 1. 2. 3. 4. 5. 6. 7. -2....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found