From 156d1813bc1785b00775150e7b5a69282eedc9d6 Mon Sep 17 00:00:00 2001 From: bilibili12433014 <717427401@qq.com> Date: Tue, 12 Mar 2024 18:32:28 +0800 Subject: [PATCH 1/2] fix a bug: onnxruntime.capi.onnxruntime_pybind11_state.Fail fix a bug which may cause err: onnxruntime.capi.onnxruntime_pybind11_state.Fail: [ONNXRuntimeError] : 1 : FAIL : Load model from *.onnx failed:Type Error: Type parameter (T) of Optype (Where) bound to different types (tensor(int64) and tensor(float) in node (/end2end/Where_1). --- yolov6/models/end2end.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yolov6/models/end2end.py b/yolov6/models/end2end.py index c1f102ba..e9f41b51 100644 --- a/yolov6/models/end2end.py +++ b/yolov6/models/end2end.py @@ -171,7 +171,7 @@ def forward(self, x): batched_dets = batched_dets.where((batch_inds == batch_template.unsqueeze(1)).unsqueeze(-1),batched_dets.new_zeros(1)) batched_labels = cls_inds.unsqueeze(0).repeat(batch, 1) - batched_labels = batched_labels.where((batch_inds == batch_template.unsqueeze(1)),batched_labels.new_ones(1) * -1) + batched_labels = batched_labels.where((batch_inds == batch_template.unsqueeze(1)),batched_labels.new_ones(1, dtype=batched_labels.dtype) * -1) N = batched_dets.shape[0] From a11ba3c7161d319efbf50011f578de1046fbc4e2 Mon Sep 17 00:00:00 2001 From: bilibili12433014 <73748897+bilibili12433014@users.noreply.github.com> Date: Thu, 8 Aug 2024 02:19:32 +0800 Subject: [PATCH 2/2] Update loss.py FutureWarning: torch.cuda.amp.autocast(args...) is deprecated. Use torch.amp.autocast('cuda', args...) instead. --- yolov6/models/losses/loss.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yolov6/models/losses/loss.py b/yolov6/models/losses/loss.py index ec534923..86326965 100644 --- a/yolov6/models/losses/loss.py +++ b/yolov6/models/losses/loss.py @@ -205,7 +205,7 @@ def __init__(self): def forward(self, pred_score,gt_score, label, alpha=0.75, gamma=2.0): weight = alpha * pred_score.pow(gamma) * (1 - label) + gt_score * label - with torch.cuda.amp.autocast(enabled=False): + with torch.amp.autocast('cuda', enabled=False): loss = (F.binary_cross_entropy(pred_score.float(), gt_score.float(), reduction='none') * weight).sum() return loss