在尝试为自己的数据集训练模型时,我遇到以下错误:
ValueError: could not convert string to float: '281.46762 316.82224 306.0123 270.65768 136.2258 160.62991 176.29044 151.88632 तब'
File "/Users/shwaitkumar/Downloads/EAST-master/icdar.py", line 609, in generator
text_polys, text_tags = load_annoataion(txt_fn)
如何正确地将字符串转换为浮点? 以下是以txt格式加载注释的代码:
def load_annoataion(p):
text_polys = []
text_tags = []
if not os.path.exists(p):
return np.array(text_polys, dtype=np.float32)
with open(p, 'r') as f:
reader = csv.reader(f)
for line in reader:
label = line[-1]
line = [i.strip('\ufeff').strip('\xef\xbb\xbf') for i in line]
x1, y1, x2, y2, x3, y3, x4, y4 = list(map(float, line[:8]))
text_polys.append([[x1, y1], [x2, y2], [x3, y3], [x4, y4]])
if label == '*' or label == '###':
text_tags.append(True)
else:
text_tags.append(False)
return np.array(text_polys, dtype=np.float32), np.array(text_tags, dtype=np.bool)
您必须清理数据,但根据错误中的这一行,这里有一些东西可以帮助您解决问题
相关问题 更多 >
编程相关推荐