meituan / YOLOv6

YOLOv6: a single-stage object detection framework dedicated to industrial applications.
GNU General Public License v3.0
5.72k stars 1.04k forks source link

RuntimeError: one_hot is only applicable to index tensor. #435

Closed yang-0201 closed 2 years ago

yang-0201 commented 2 years ago

when I trained my datasets in YOLOV6-M,the first 4 epochs is normal,but in 5 epoch,an error is reported when you are about to verify.

 Epoch  iou_loss  dfl_loss  cls_loss
 5/299    0.9721    0.5122    0.9138:  99%|█████████▉| 90/91 [00:41<00:00,  2.19it/s]                                                                                                                                                               

ERROR in training steps. ERROR in training loop or eval/save model.

Training completed in 0.097 hours. Traceback (most recent call last): File "tools/train.py", line 126, in main(args) File "tools/train.py", line 116, in main trainer.train() File "I:\yolov6_new\yolov6\core\engine.py", line 99, in train self.train_in_loop(self.epoch) File "I:\yolov6_new\yolov6\core\engine.py", line 112, in train_in_loop self.train_in_steps(epoch_num) File "I:\yolov6_new\yolov6\core\engine.py", line 141, in train_in_steps total_loss, loss_items = self.compute_loss(preds, targets, epoch_num) File "I:\yolov6_new\yolov6\models\loss.py", line 100, in call one_hot_label = F.one_hot(target_labels, self.num_classes + 1)[..., :-1] RuntimeError: one_hot is only applicable to index tensor.

Chilicyy commented 2 years ago

This problem is fixed now. Please git pull the latest code, or just convert the datatype of target_labels in ./yolov6\models\loss.py #line 100 by: one_hot_label = F.one_hot(target_labels.long(), self.num_classes + 1)[..., :-1]