Open ClayZhang0403 opened 4 years ago
13.2020/4/30在datasets.py 592行添加了支持负样本训练,默认注释掉.
把append缩进 ` # Load labels label_path = self.label_files[index] if os.path.isfile(label_path): x = self.labels[index] if x is None: # labels not preloaded with open(label_path, 'r') as f: x = np.array([x.split() for x in f.read().splitlines()], dtype=np.float32)
if x.size > 0:
# Normalized xywh to pixel xyxy format
labels = x.copy()
labels[:, 1] = w * (x[:, 1] - x[:, 3] / 2) + padw
labels[:, 2] = h * (x[:, 2] - x[:, 4] / 2) + padh
labels[:, 3] = w * (x[:, 1] + x[:, 3] / 2) + padw
labels[:, 4] = h * (x[:, 2] + x[:, 4] / 2) + padh
labels4.append(labels)
if len(labels4):
labels4 = np.concatenate(labels4, 0)`
把append缩进 ` # Load labels label_path = self.label_files[index] if os.path.isfile(label_path): x = self.labels[index] if x is None: # labels not preloaded with open(label_path, 'r') as f: x = np.array([x.split() for x in f.read().splitlines()], dtype=np.float32)
if x.size > 0: # Normalized xywh to pixel xyxy format labels = x.copy() labels[:, 1] = w * (x[:, 1] - x[:, 3] / 2) + padw labels[:, 2] = h * (x[:, 2] - x[:, 4] / 2) + padh labels[:, 3] = w * (x[:, 1] + x[:, 3] / 2) + padw labels[:, 4] = h * (x[:, 2] + x[:, 4] / 2) + padh labels4.append(labels) if len(labels4): labels4 = np.concatenate(labels4, 0)`
没看明白啥意思。能再明确些吗,我也有负样本,这里出错了,谢谢
当训练的时候就出现了这个问题UnboundLocalError: local variable 'labels' referenced before assignment,我的数据集中有一部分负样本,但是不知道这个问题该怎么解决,求楼主或者其他大佬赐教