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

Uploaded Python 3

File details

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

File metadata

  • Download URL: donut_ai_evaluate-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 c4a1c3d15ccd02da86019af944007249a7224c7dd0e304b4c9dc0b35d8102933
MD5 cd9e683cc958e66cd9b908282ed35800
BLAKE2b-256 620fd07200fe03fbf64c32fca85b7401feb86df3c594594d9bcbd37a248aa9e7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for donut_ai_evaluate-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 baf5ce6ad10415ffaeede8932141968d25e24dd332048c909ab19c1b065384bb
MD5 240cb5ea1f93f324ed596f8518a703a7
BLAKE2b-256 fe46eeb260bff183394a2d24759593c2426d112605969ce9a178fe1f25d412d8

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