Spaces:
Sleeping
Sleeping
Download doc_intelligence/src/data/schema.py from vettri06/Document_intelligence: direct link, hf CLI and curl.
- Browser
- Download file 925 Bytes
-
https://huggingface.co/spaces/vettri06/Document_intelligence/resolve/main/doc_intelligence/src/data/schema.py
- Command line
-
hf download hf://spaces/vettri06/Document_intelligence/doc_intelligence/src/data/schema.py
-
curl -L -o schema.py https://huggingface.co/spaces/vettri06/Document_intelligence/resolve/main/doc_intelligence/src/data/schema.py
925 Bytes
| from typing import List, Dict, Optional, Any | |
| from pydantic import BaseModel, Field | |
| class OCRWord(BaseModel): | |
| text: str | |
| bbox: List[int] = Field(default_factory=lambda: [0, 0, 0, 0]) # [xmin, ymin, xmax, ymax] | |
| conf: float = 1.0 | |
| class DocumentRecord(BaseModel): | |
| doc_id: str | |
| source_dataset: str | |
| doc_class: str # "invoice" | "receipt" | "application_form" | |
| image_path: str | |
| ocr_words: List[OCRWord] = Field(default_factory=list) | |
| fields: Dict[str, Optional[Any]] = Field(default_factory=dict) | |
| CLASS_FIELD_SCHEMAS = { | |
| "invoice": [ | |
| "invoice_number", | |
| "invoice_date", | |
| "seller_name", | |
| "buyer_name", | |
| "total_amount" | |
| ], | |
| "receipt": [ | |
| "company_name", | |
| "date", | |
| "address", | |
| "total_amount" | |
| ], | |
| "application_form": [ | |
| "applicant_name", | |
| "date", | |
| "address", | |
| "other_key_value_pairs" | |
| ] | |
| } | |