解决:AssertionError: Label class 1 exceeds nc=1 in data/coco128.yaml. Possible class labels are 0-0

Yolov5报错:
AssertionError: Label class 1 exceeds nc=1 in data/coco128.yaml. Possible class labels are 0-0
这个错别傻乎乎该nc之类的,细看代码出错位置,我这个是这样的

File “C:\Users\1\Desktop\水表识别\YOLO5\yolov5-master\train.py”, line 175, in train
assert mlc < nc, ‘Label class %g exceeds nc=%g in %s. Possible class labels are 0-%g’ % (mlc, nc, opt.data, nc - 1)

AssertionError: Label class 1 exceeds nc=1 in data/coco128.yaml. Possible class labels are 0-0

这样就找到train文件的175行:

assert mlc < nc, 'Label class %g exceeds nc=%g in %s. Possible class labels are 0-%g' % (mlc, nc, opt.data, nc - 1)

改成这样

#assert mlc < nc, 'Label class %g exceeds nc=%g in %s. Possible class labels are 0-%g' % (mlc, nc, opt.data, nc - 1)

即注销掉就可以了

你可能感兴趣的:(python)