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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file donut_ai_evaluate-0.1.4.tar.gz.
File metadata
- Download URL: donut_ai_evaluate-0.1.4.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ac6ba1b588b46b3020359dfd1cd47c459bc831e5ffaa1a3a323f75e8f65a8ba
|
|
| MD5 |
54e396672522c1710d04352359fb9b73
|
|
| BLAKE2b-256 |
43eb78472e906c4cdd5d73bc7471affd0a103d2bf90f1ad67cf123e4c465d733
|
File details
Details for the file donut_ai_evaluate-0.1.4-py3-none-any.whl.
File metadata
- Download URL: donut_ai_evaluate-0.1.4-py3-none-any.whl
- Upload date:
- Size: 20.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4065b98159e2a959a79c66a44332b8691ee209ef0ad10d12f3a285a53d9bbe28
|
|
| MD5 |
2edbde8022e6f65608f1cf6931d4988d
|
|
| BLAKE2b-256 |
f51cd86a8621807685df3fd1ac9cfc90f13396773aea6db0674ddffdd270dcdd
|