Spaces:
Sleeping
Sleeping
Download commonforms/utils.py from tsalkar/pdf-field-extractor-backend: direct link, hf CLI and curl.
- Browser
- Download file 665 Bytes
-
https://huggingface.co/spaces/tsalkar/pdf-field-extractor-backend/resolve/main/commonforms/utils.py
- Command line
-
hf download hf://spaces/tsalkar/pdf-field-extractor-backend/commonforms/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/tsalkar/pdf-field-extractor-backend/resolve/main/commonforms/utils.py
665 Bytes
| from __future__ import annotations | |
| from typing import Literal | |
| from pydantic import BaseModel | |
| from dataclasses import dataclass | |
| from PIL import Image | |
| class BoundingBox(BaseModel): | |
| x0: float | |
| y0: float | |
| x1: float | |
| y1: float | |
| def from_yolo(cls, cx: float, cy: float, w: float, h: float) -> BoundingBox: | |
| return cls(x0=cx - w / 2, y0=cy - h / 2, x1=cx + w / 2, y1=cy + h / 2) | |
| class Widget(BaseModel): | |
| widget_type: Literal[ | |
| "TextBox", | |
| "ChoiceButton", | |
| "Signature", | |
| ] | |
| bounding_box: BoundingBox | |
| page: int | |
| class Page: | |
| image: Image.Image | |
| width: float | |
| height: float | |