Skip to main content

Donut packages for evaluating the output of data entry and redact.

Project description

Donut AI Evaluate

Install the library using

pip install donut-ai-evaluate

Before running the evaluation, make sure that the google gemini API key is present in the environment variables.

Data Entry Evaluation

The user can either compare a single field or multiple fields with one another.

The following code snipped shows an example of how single field comparison works:

from donut_ai_evaluate.data_entry import compare_single_field

data = {
    "Name" : 
    {
        "predicted" : "John",
        "ground-truth" : "Jon"
    }
}

comparison_data = compare_single_field(data)

print(comparison_data)

The following code snipped shows an example of how multi field comparison works:

from donut_ai_evaluate.data_entry import compare_batch_fields

data = [
    {
        "Name" : 
        {
            "predicted" : "John",
            "ground-truth" : "Jon"
        }
    },
    {
        "State" : 
        {
            "predicted" : "Florida",
            "ground-truth" : "Fl"
        }
    },
    {
        "Phone Number" : 
        {
            "predicted" : "922000511",
            "ground-truth" : "92-2000-511"
        }
    }
]

comparison_data = compare_batch_fields(data)

print(comparison_data)

Redact Evaluation

Field redactions can be evaluated using the following code:

from donut_ai_evaluate.redact import is_redacted_field_gt,is_gt_field_redacted
from donut_ai_evaluate._common.eval_logger import logger


# Example Ground Truth Bboxes as lists [x, y, w, h]
gt_boxes_raw = [
    [10, 10, 50, 20],   # GT 0
    [100, 100, 80, 30],  # GT 1
    [200, 50, 40, 40]   # GT 2
]

# Example AI Detected Bboxes as lists [x, y, w, h]
# Scenario 1: Perfect match
ai_boxes_perfect_raw = [
    [11, 11, 49, 19],   # AI 0 -> matches GT 0
    [100, 100, 80, 30], # AI 1 -> matches GT 1
    [201, 51, 39, 39],   # AI 2 -> matches GT 2
    [201, 51, 41, 123] , # AI 3 -> matches None
    [300, 41, 41, 123]  # AI 4 -> matches None
]


# Check if each GT is matched by an AI box
is_gt_field_redacted(gt_boxes_raw, ai_boxes_perfect_raw) # Should be [True, True, True]

# Check if each AI box matches a GT box
is_redacted_field_gt(ai_boxes_perfect_raw, gt_boxes_raw) # Should be [True, True, True]

Project details


Download files

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

Source Distribution

donut_ai_evaluate-0.1.2.tar.gz (17.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

donut_ai_evaluate-0.1.2-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file donut_ai_evaluate-0.1.2.tar.gz.

File metadata

  • Download URL: donut_ai_evaluate-0.1.2.tar.gz
  • Upload date:
  • Size: 17.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.10

File hashes

Hashes for donut_ai_evaluate-0.1.2.tar.gz
Algorithm Hash digest
SHA256 869b1bfee5f0a45eaebd9c903172a42bc55dd6d3b8b99eff5a50f4549df4d678
MD5 b0d37ac9ba4596f8114fb1d7bf12780f
BLAKE2b-256 05ddbf8716abc8c9c04ca9927bdfa2d0caf7d9c70cc02c580c319b0a16cbede9

See more details on using hashes here.

File details

Details for the file donut_ai_evaluate-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for donut_ai_evaluate-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0c829dcb910657e34dae9742b790e29caf1d092da28b37535a95093f90c57d09
MD5 742d73afdd4b385813635dbb1c8ad1fc
BLAKE2b-256 01ec416dfac05e8f31130a1e92625b2235c76f926a7ed241bbbc998747a5b5ad

See more details on using hashes here.

Supported by

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