Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error report: Textsnake for generating ground truth targets. #100

Closed
Bovey0809 opened this issue Apr 20, 2021 · 6 comments
Closed

Error report: Textsnake for generating ground truth targets. #100

Bovey0809 opened this issue Apr 20, 2021 · 6 comments
Assignees

Comments

@Bovey0809
Copy link

When training the textsnake for my own data, issue randomly came out from

while current_line_len >= length_cumsum[current_edge_ind + 1]:

Same issue here, princewang1994/TextSnake.pytorch#30

line 205, in resample_line
    while current_line_len >= length_cumsum[current_edge_ind + 1]:
IndexError: index 2 is out of bounds for axis 0 with size 2

I'm trying to figure out, thanks a lot if you can help with that.

@Bovey0809
Copy link
Author

Sorry for disturbing, I found the reason of the bug, it came from a invalid annotation. I fix the issue by double-check the labels. Here is the script to figure out the invalid points.

from shapely.geometry import Polygon, LinearRing

import glob

import random

anno_root = 'annotations/training/'

filelist = glob.glob(anno_root+"*.txt")

assert len(filelist) > 0

def check_polygon(filename):
    t = open(filename)
    for line in t.readlines():
        cors = line.strip().split(',')
        assert (len(cors) % 2) == 0, "invalid cors"
        pts = [(int(cors[j]), int(cors[j+1])) for j in range(0, len(cors)-1, 2)]
        try:
            pgt = Polygon(pts)
        except Exception as e:
            print('Not a valid polygon', pgt)
            continue
        if not pgt.is_valid:
            print('GT polygon has intersecting sides', pts)
            continue
        pRing = LinearRing(pts)
        if not pRing.is_ccw:
            pts.reverse()
    t.close()
# test
check_polygon(random.choice(filelist))

for i in filelist:
    check_polygon(i)

@FFoCC
Copy link

FFoCC commented Jun 30, 2021

@Bovey0809 Hi. I have the same problem. This error shows what is wrong with the data? I have filtered the data with your check code, but I still have this problem.

line 205, in resample_line
    while current_line_len >= length_cumsum[current_edge_ind + 1]:
IndexError: index 3 is out of bounds for axis 0 with size 3

@innerlee innerlee reopened this Jun 30, 2021
@HolyCrap96
Copy link
Contributor

@FFoCC Thanks for your feedback. Could you provide the polyline data that the code wrongly processed?

@FFoCC
Copy link

FFoCC commented Jul 5, 2021

@HolyCrap96 I don't know which piece of data is wrong. It is strange that sometimes my dataset can work with three epochs and a fourth error.
e42333
e42222

@FFoCC
Copy link

FFoCC commented Jul 5, 2021

@HolyCrap96 Here are two examples of my data. Is there anything wrong with them?

{"file_name": "training/210519_0670.jpg", "height": 3968, "width": 2976, "annotations": [{"iscrowd": 0, "category_id": 1, "bbox": [897.0, 914.0, 578.0, 139.0], "segmentation": [[897, 914, 1475, 914, 1475, 1053, 897, 1053]]}, {"iscrowd": 0, "category_id": 1, "bbox": [918.0, 2081.0, 1079.0, 187.0], "segmentation": [[923, 2142, 1143, 2128, 1178, 2122, 1409, 2132, 1476, 2123, 1538, 2123, 1572, 2126, 1595, 2123, 1621, 2114, 1641, 2114, 1660, 2109, 1709, 2099, 1893, 2084, 1957, 2081, 1997, 2172, 1956, 2199, 1884, 2218, 1812, 2240, 1145, 2264, 969, 2268, 918, 2263]]}, {"iscrowd": 0, "category_id": 1, "bbox": [1087.0, 1260.0, 420.0, 178.0], "segmentation": [[1087, 1260, 1507, 1260, 1507, 1438, 1087, 1438]]}, {"iscrowd": 0, "category_id": 1, "bbox": [1132.0, 2468.0, 428.0, 165.0], "segmentation": [[1132, 2468, 1560, 2468, 1560, 2633, 1132, 2633]]}, {"iscrowd": 0, "category_id": 1, "bbox": [2086.0, 287.0, 237.0, 137.0], "segmentation": [[2086, 287, 2323, 287, 2323, 424, 2086, 424]]}]}
{"file_name": "training/397756.jpg", "height": 1800, "width": 850, "annotations": [{"iscrowd": 0, "category_id": 1, "bbox": [314.0, 829.0, 77.0, 27.0], "segmentation": [[314, 829, 391, 829, 391, 856, 314, 856]]}, {"iscrowd": 0, "category_id": 1, "bbox": [399.0, 826.0, 27.0, 31.0], "segmentation": [[399, 826, 426, 826, 426, 857, 399, 857]]}, {"iscrowd": 0, "category_id": 1, "bbox": [225.0, 909.0, 227.0, 48.0], "segmentation": [[225, 925, 445, 909, 452, 942, 229, 957]]}, {"iscrowd": 0, "category_id": 1, "bbox": [276.0, 1008.0, 116.0, 30.0], "segmentation": [[276, 1008, 392, 1008, 392, 1038, 276, 1038]]}, {"iscrowd": 0, "category_id": 1, "bbox": [252.0, 1089.0, 124.0, 49.0], "segmentation": [[252, 1089, 376, 1089, 376, 1138, 252, 1138]]}, {"iscrowd": 0, "category_id": 1, "bbox": [819.0, 471.0, 31.0, 43.0], "segmentation": [[819, 471, 850, 471, 850, 514, 819, 514]]}]}

@gaotongxiao
Copy link
Collaborator

Probably get fixed in #448, which is a part of MMOCR 0.3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants