Using this repo : GitHub - ultralytics/yolov5: YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite i am trying to train yolov5 on a custom dataset containing 3 classes.once the training is done,during validation i get this error :
Validating runs/train/Result4/weights/best.pt...
Fusing layers...
Model Summary: 476 layers, 87212152 parameters, 0 gradients, 217.1 GFLOPs
Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 1/1 [00:04<00:00, 4.19s/it]
Traceback (most recent call last):
File "train.py", line 625, in <module>
main(opt)
File "train.py", line 522, in main
train(opt.hyp, opt, device, callbacks)
File "train.py", line 429, in train
compute_loss=compute_loss) # val best model with plots
File "/usr/local/lib/python3.7/dist-packages/torch/autograd/grad_mode.py", line 28, in decorate_context
return func(*args, **kwargs)
File "/content/val.py", line 240, in run
p, r, ap, f1, ap_class = ap_per_class(*stats, plot=plots, save_dir=save_dir, names=names)
File "/content/utils/metrics.py", line 78, in ap_per_class
plot_mc_curve(px, f1, Path(save_dir) / 'F1_curve.png', names, ylabel='F1')
File "/content/utils/metrics.py", line 323, in plot_mc_curve
ax.plot(px, y, linewidth=1, label=f'{names[i]}') # plot(confidence, metric)
KeyError: 1
even though i wrote custom yaml file like this :
%%writetemplate /content/DataFile/data.yaml
train: /content/convertor/fold0/images/train
val: /content/convertor/fold0/images/val
test: /content/convertor/fold0/images/val
nc: 3
names: ["name","age","mobile"]
i still get the error above and while inferring, all the bounding boxes are given “name” as label ,instead of predicting these 3 classes names: [“name”,“age”,“mobile”]
my model always predicts “name” for all 3 fields(please check the last image attached in the colab code):
here is the code with outputs and errors : Google Colab
how can i solve this issue? thanks in advance