2.7 KiB
FAQ
General
Q1 I'm getting the warning like unexpected key in source state_dict: fc.weight, fc.bias
, is there something wrong?
A It's not an error. It occurs because the backbone network is pretrained on image classification tasks, where the last fc layer is required to generate the classification output. However, the fc layer is no longer needed when the backbone network is used to extract features in downstream tasks, and therefore these weights can be safely skipped when loading the checkpoint.
Q2 MMOCR terminates with an error: shapely.errors.TopologicalError: The operation 'GEOSIntersection_r' could not be performed. Likely cause is invalidity of the geometry
. How could I fix it?
A This error occurs because of some invalid polygons (e.g., polygons with self-intersections) existing in the dataset or generated by some non-rigorous data transforms. These polygons can be fixed by adding FixInvalidPolygon
transform after the transform likely to introduce invalid polygons. For example, a common practice is to append it after LoadOCRAnnotations
in both train and test pipeline. The resulting pipeline should look like:
train_pipeline = [
...
dict(
type='LoadOCRAnnotations',
with_polygon=True,
with_bbox=True,
with_label=True,
),
dict(type='FixInvalidPolygon', min_poly_points=4),
...
]
In practice, we find that Totaltext contains some invalid polygons and using FixInvalidPolygon
is a must. Here is an example config.
Text Recognition
Q1 What are the steps to train text recognition models with my own dictionary?
A In MMOCR 1.0, you only need to modify the config and point Dictionary
to your custom dict file. For example, if you want to train SAR model (75c06d34bb/configs/textrecog/sar/sar_resnet31_parallel-decoder_5e_st-sub_mj-sub_sa_real.py
) with your own dictionary placed at /my/dict.txt
, you can modify dictionary.dict_file
term in base config to:
dictionary = dict(
type='Dictionary',
dict_file='/my/dict.txt',
with_start=True,
with_end=True,
same_start_end=True,
with_padding=True,
with_unknown=True)
Now you are good to go. You can also find more information in Dictionary API.