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

Hello, I would like to ask you about the following error when training the dbnet model on the ICDAR2017 dataset。 #1388

Closed
ViviKing414 opened this issue Sep 13, 2022 · 5 comments
Assignees

Comments

@ViviKing414
Copy link

raise TopologicalError(
shapely.errors.TopologicalError: The operation 'GEOSIntersection_r' could not be performed. Likely cause is invalidity of the geometry <shapely.geometry.polygon.Polygon object at 0x7f63038f4520>

@xinke-wang
Copy link
Collaborator

Hi, this error may caused due to invalid polygonal bounding boxes with self-intersection included in the annotation of the dataset.

If you are using MMOCR 1.x version, you can directly add our FixInvalidPolygon transform to the training/testing pipeline, which will automatically fixes the invalid shapes.

class FixInvalidPolygon(BaseTransform):

If you are using the MMOCR 0.x version, we recommend you to write a script to filter out the invalid samples or fix them, take the following codes as an example.

# if you want to filter out the invalid polygons, simply replace them with [x, y, x+w, y, x+w, y+h, x, y+h]
box = [0, 0, 3, 3]
polygon = Polygon([(0,0), (0,3), (3,3), (3,0), (2,0), (2,2), (1,2), (1,1), (2,1), (2,0), (0,0)])
if not polygon.is_valid:
    x, y, w, h = box
    polygon = [x, y, x+w, y, x+w, y+h, x, y+h]

# or you can mark this sample as ignored
if not polygon.is_valid:
    ignored = 1

@ViviKing414
Copy link
Author

Thank you very much for your answer. I'll try it out right away

@ViviKing414
Copy link
Author

Hi, this error may caused due to invalid polygonal bounding boxes with self-intersection included in the annotation of the dataset.

If you are using MMOCR 1.x version, you can directly add our FixInvalidPolygon transform to the training/testing pipeline, which will automatically fixes the invalid shapes.

class FixInvalidPolygon(BaseTransform):

If you are using the MMOCR 0.x version, we recommend you to write a script to filter out the invalid samples or fix them, take the following codes as an example.

# if you want to filter out the invalid polygons, simply replace them with [x, y, x+w, y, x+w, y+h, x, y+h]
box = [0, 0, 3, 3]
polygon = Polygon([(0,0), (0,3), (3,3), (3,0), (2,0), (2,2), (1,2), (1,1), (2,1), (2,0), (0,0)])
if not polygon.is_valid:
    x, y, w, h = box
    polygon = [x, y, x+w, y, x+w, y+h, x, y+h]

# or you can mark this sample as ignored
if not polygon.is_valid:
    ignored = 1

Regarding the MMOCR version, is there any difference between the 1. X version and the mmocr default version?

@ViviKing414
Copy link
Author

Excuse me again, when training in version 1.x, ImportError: cannot import name 'register_all_modules' from 'mmocr.utils' 。

@xinke-wang
Copy link
Collaborator

xinke-wang commented Sep 14, 2022

Hi,

1.x is the latest major update that MMOCR has released, which introduces many new features (check our latest document for more details English Doc/Chinese Doc). The 0.x version (default version) will be deprecated at the end of this year, hence we recommend users transfer to the 1.x version.

Since the 1.x version relies on the new MMEngine, it does not share the same running env with the 0.x version. You have to install it following our installation guide.

@gaotongxiao gaotongxiao closed this as not planned Won't fix, can't repro, duplicate, stale Oct 9, 2022
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

3 participants