Open aamna2401 opened 1 year ago
Why is this error happening? Here is a log
This is because the number of annotation points in the label is less than 4 or coincidence of annotation points. Please remove these annotations with less than 4 annotation points during data loading。
such as in Icdar15_Text.py:
for line in lines:
line = strs.remove_all(line.strip('\ufeff'), '\xef\xbb\xbf')
gt = line.split(',')
x1, y1, x2, y2, x3, y3, x4, y4 = list(map(int, gt[:8]))
xx = [x1, x2, x3, x4]
yy = [y1, y2, y3, y4]
label = gt[-1].strip().replace("###", "#")
pts = np.stack([xx, yy]).T.astype(np.int32)
d1 = norm2(pts[0] - pts[1])
d2 = norm2(pts[1] - pts[2])
d3 = norm2(pts[2] - pts[3])
d4 = norm2(pts[3] - pts[0])
if min([d1, d2, d3, d4]) < 2:
continue
polygons.append(TextInstance(pts, 'c', label))
We can't guarantee that the code can cover all situations. Data differences may cause some bugs. Please fix it yourself.
Why is this error happening? Here is a log
你好,请问您解决了吗?我在评估totaltxt数据集的时候也遇到了这种问题
一般来说,文本检测的结果都会把面积过小的文本过滤掉,所以文本轮廓的点数不应该小于3,也就通常不会报这个错误。点数小于3,无法组成一个封闭的轮廓,所以报这个错误。建议对检测的结果进行检查过滤。
Why is this error happening? Here is a log
你好,请问您解决了吗?我在评估totaltxt数据集的时候也遇到了这种问题
请检查边界上点的个数,如果少于四个点[shape(4,2)],过滤掉; 或者用Polygon(inst.points).is_valid:判断轮廓是否是有效的,过滤掉无效的轮廓。在total-text的数据加载里,我们有添加这个过代码 https://github.com/GXYM/TextBPN-Plus-Plus/blob/34a7949966a0f1a95a67495368a86529a21e2772/dataset/Total_Text.py#L57, 为什还会报这个错呢?
if len(x) < 4: # too few points
continue
Why is this error happening? Here is a log
你好,请问您解决了吗?我在评估totaltxt数据集的时候也遇到了这种问题
请检查边界上点的个数,如果少于四个点[shape(4,2)],过滤掉; 或者用Polygon(inst.points).is_valid:判断轮廓是否是有效的,过滤掉无效的轮廓。在total-text的数据加载里,我们有添加这个过代码 https://github.com/GXYM/TextBPN-Plus-Plus/blob/34a7949966a0f1a95a67495368a86529a21e2772/dataset/Total_Text.py#L57, 为什还会报这个错呢?
if len(x) < 4: # too few points continue
是的,还存在这个问题,我学习的是您的TextPM模型,在使用训练得到的模型对totaltxt数据集进行评估的过程中出现这种问题:detect 298 / 300 images: img391.jpg. (6.42 fps);
detect 299 / 300 images: img661.jpg. (6.42 fps);
detect 300 / 300 images: img898.jpg. (6.41 fps);
Computing DetEval in output/Totaltext
80%|##################################################################9 | 239/300 [00:12<00:03, 19.28it/s]
Traceback (most recent call last):
File "dataset/total_text/Evaluation_Protocol/Python_scripts/Deteval.py", line 106, in
ValueError: A LinearRing must have at least 3 coordinate tuples
那你对最终的检测结果,再存txt文件之前,过滤一下吧。把点数小于4的检测结果和Polygon(inst.points).is_valid ==False的检测结果都过滤掉,应该就不会报错了
ValueError: A LinearRing must have at least 3 coordinate tuples
那你对最终的检测结果,再存txt文件之前,过滤一下吧。把点数小于4的检测结果和Polygon(inst.points).is_valid ==False的检测结果都过滤掉,应该就不会报错了 ` if cfg.expname == "Icdar2015": fname = "res" + meta['image_id'][idx].replace('jpg', 'txt') contours = data_transfer_ICDAR(contours) write_to_file(contours, os.path.join(output_dir, fname)) elif cfg.exp_name == "MLT2017": out_dir = os.path.join(outputdir, "{}{}{}{}_{}".format(str(cfg.checkepoch), str(cfg.threshold), str(cfg.score_i), str(cfg.test_size[0]), str(cfg.test_size[1]))) if not os.path.exists(out_dir): mkdirs(out_dir) fname = meta['image_id'][idx].split("/")[-1].replace('ts', 'res') fname = fname.split(".")[0] + ".txt" data_transfer_MLT2017(contours, os.path.join(out_dir, fname)) elif cfg.expname == "TD500": fname = "res" + meta['image_id'][idx].split(".")[0]+".txt" data_transfer_TD500(contours, os.path.join(output_dir, fname))
elif cfg.exp_name == "Totaltext":
fname = meta['image_id'][idx].replace('jpg', 'txt')
data_transfer_Totaltext(contours, os.path.join(output_dir, fname))
else:
fname = meta['image_id'][idx].replace('jpg', 'txt')
write_to_file(contours, os.path.join(output_dir, fname))`
def write_to_file(contours, file_path):
"""
:param contours: [[x1, y1], [x2, y2]... [xn, yn]]
:param file_path: target file path
"""
with open(file_path, 'w') as f:
for cont in contours:
cont = np.stack([cont[:, 0], cont[:, 1]], 1)
if cv2.contourArea(cont) <= 0:
continue
cont = cont.flatten().astype(str).tolist()
cont = ','.join(cont)
f.write(cont + '\n')
Why is this error happening? Here is a log