# Layout Analysis

D-FINE Stage-2 B2 layout model with 12 classes. Detects page regions;
text recognition and reading order are handled by OXR.

## Files

- `last.pth`: inference-only model weights (no optimizer or training state).
- `metadata.json`: model identity, architecture, preprocessing, class IDs,
  checkpoint size and SHA-256 (schema version 1).

`model_version` is a public release version (`major.minor.patch`), not a
training-run identifier.

## Usage

Use the LA inference service in the OXR code repository at
`services/layout_analyze/`. Mount this directory into the service and set
`MODEL_PATH` to the mounted `last.pth` path.

The matching LA service reads `metadata.json` next to the checkpoint at startup
and validates its supported architecture, preprocessing, class IDs and weight
integrity. Both files must be mounted. `MODEL_METADATA_PATH` can override the
metadata path. Unsupported metadata or a mismatched checkpoint fails startup.
This is not a Transformers `AutoModel` configuration. Device, precision and
CUDA Graph settings are selected by the service, not by the model metadata.

Checkpoint verification:

```bash
shasum -a 256 layout_analysis/last.pth
# dff78ccf18439955362ca44a69eb28fb0b40222a7d278860589682de0176dc17
```
