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.1.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.1-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: donut_ai_evaluate-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 39afd130a8b78c600b0c31f186d42bd594afe2b3c026ac9d2cf8d9ab2c5cbe79
MD5 64208bc9b89f6b1c9622257dc10357f8
BLAKE2b-256 147a234d5ecbdc9791f2d5886172ed3be5c66f3a794bb37f3d59bac479aad576

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for donut_ai_evaluate-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 05fdcd2193102d57fad153e20a61649dbfcbaec58d13365b35d0efacf9b85397
MD5 1b83f77ed7a78dc9757819e2f3cd470b
BLAKE2b-256 e5a4fa9c3a66905082b1618d4248b1c2110b8503ac400f47804556a233bf094d

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