Skip to main content

Tool of computing the metric of text detection

Project description

Text Detect Metric

PyPI SemVer2.0

Evaluate on the custom dataset.

  • Here we use the evaluation code of ch_mobile_v2_det on the text detection test set liekkas/text_det_test_dataset, and you can use the same analogy.

1. Install packages.

pip install modelscope==1.5.2
pip install text_det_metric

2. Run

  1. Run get_pred_txt.py to get pred.txt
    import cv2
    from modelscope.msdatasets import MsDataset
    
    from ch_mobile_v2_det import TextDetector
    
    test_data = MsDataset.load(
        "text_det_test_dataset",
        namespace="liekkas",
        subset_name="default",
        split="test",
    )
    
    text_detector = TextDetector()
    
    content = []
    for one_data in test_data:
        img_path = one_data.get("image:FILE")
    
        print(img_path)
        img = cv2.imread(str(img_path))
        dt_boxes, scores, _ = text_detector(img)
        content.append(f"{img_path}\t{dt_boxes.tolist()}\t{scores}")
    
    with open("pred.txt", "w", encoding="utf-8") as f:
        for v in content:
            f.write(f"{v}\n")
    
  2. Run compute_metric.py to get the metrics on the dataset
    from text_det_metric import DetectionIoUEvaluator
    
    metric = DetectionIoUEvaluator()
    
    # pred_path
    pred_path = "1.txt"
    mertric = metric(pred_path)
    print(mertric)
    

See details for TextDetMetric.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

text_det_metric-0.0.2-py3-none-any.whl (9.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page