ho正确使用torchvision.ops.generalized_box_iou_loss?

发布于 2025-01-28 04:50:36 字数 478 浏览 4 评论 0原文

我正在训练模型以适合图像上的边界框。所有边界框均由两个坐标(X1,Y1,X2,Y2)定义。为了适合这些边界盒,我首先使用MSE_LOSS。损失收敛,但结果仍然不够出色。 因此,我尝试使用

模型的最后一层看起来像这样。

self.fc3 = nn.Linear(256, 4)
...
# in forward:
x = self.fc3(x)

训练步骤定义如下:

def training_step(self, batch, batch_idx):
    x, y = batch
    y_hat = self.model(x_aug) 
    loss = generalized_box_iou_loss(y_hat, y, reduction='mean')
    self.log("train_loss", loss)
    return loss

如何解决此问题? 最好,乔纳

I’m training a model to fit bounding boxes on images. All Bounding boxes are defined by two coordinates (x1,y1,x2,y2). To fit these bounding boxes I first used mse_loss. The loss converges, but the results are still not great enough.
I therefore tried to use generalized_box_iou_loss with reduction='mean' (to have a Scalar for back-propagation). My bounding boxes satisfy the requirements 0 <= x1 < x2 and 0 <= y1 < y2. However, the loss is only approaching 1.

The final layer of the model looks like this.

self.fc3 = nn.Linear(256, 4)
...
# in forward:
x = self.fc3(x)

And the training step is defined as follows:

def training_step(self, batch, batch_idx):
    x, y = batch
    y_hat = self.model(x_aug) 
    loss = generalized_box_iou_loss(y_hat, y, reduction='mean')
    self.log("train_loss", loss)
    return loss

Any ideas how to resolve this issue?
Best, Jona

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文