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.5.tar.gz (17.4 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.5-py3-none-any.whl (20.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: donut_ai_evaluate-0.1.5.tar.gz
  • Upload date:
  • Size: 17.4 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.5.tar.gz
Algorithm Hash digest
SHA256 fdc2653dd8c798c0715e2261483536f0098f20a3a9c991239031563187d5e99d
MD5 41c3daf9ecaa020a31ce1d4d04e12253
BLAKE2b-256 0625e8532276010a3f2bcb6ab14ff085d36eb77be2bb96ea796b3c2fb44768c8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for donut_ai_evaluate-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 b9611f9bdbc2705dd65cfb6eabe2cda783cf4e8e7bb27511805de767493e6659
MD5 ab1cab02ba6e41d42423f28eddb933e4
BLAKE2b-256 c6966999a22ebf63e426a4edee8b5379fe982aa72ad99978129e4893316e0cad

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