ho正确使用torchvision.ops.generalized_box_iou_loss?
我正在训练模型以适合图像上的边界框。所有边界框均由两个坐标(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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论