CoolFace
Modelpublic

aoiandroid/PP-DocLayoutV3-safetensors-CoreML

sourceHugging Faceapache-2.0updated 4mo agoView on Hugging Face
0likes19downloads
Model Card

PP-DocLayoutV3 safetensors Core ML (mlprogram)

Private distribution of the Core ML export for PaddlePaddle/PP-DocLayoutV3_safetensors, built for TranslateBlue on-device layout detection.

Source weights: PaddlePaddle/PP-DocLayoutV3 / PP-DocLayoutV3_safetensors.

Files

FileDescription
PP-DocLayoutV3-safetensors.mlpackage/Core ML mlprogram (iOS 18+, float32)
preprocessor_config.jsonHF image processor contract (800×800)
conversion-status.jsonExport metadata
parity-report.jsonPyTorch vs Core ML tensor diff (smoke image)

Input / output (in-package)

TensorShapeDtype
pixel_values (in)[1, 3, 800, 800]float32
logits (out)[1, 300, 25]float32
pred_boxes (out)[1, 300, 4]float32 (normalized cxcywh)
order_logits (out)[1, 300, 300]float32

Preprocessing

Match PPDocLayoutV3ImageProcessor:

  • Resize to 800×800 (bicubic, antialias=False in Transformers export)
  • Rescale: pixel / 255
  • Normalize: mean [0,0,0], std [1,1,1]

See preprocessor_config.json.

Post-processing (not in Core ML)

Apply the same logic as PPDocLayoutV3ImageProcessor.post_process_object_detection in Python or Swift:

  • Sigmoid + top-k on logits
  • Reading order from order_logits
  • Optional polygon masks require full PyTorch path (masks omitted in this export)

Conversion notes

  • Export script: TranslateBlue Scripts/export_pp_doclayout_v3_safetensors_coreml/
  • numpy<2.4 required for coremltools convert (coremltools#2633)
  • compute_precision=float32 (fp16 MIL cast diverges)
  • Fixed 800×800 input (trace); other sizes are unsupported

Parity (reference)

On bus.jpg (TranslateBlue smoke):

Tensormax abs diff vs export wrapper
logits7.2e-5
pred_boxes9.7e-6
order_logits0.04

License

Apache 2.0 (same family as PaddlePaddle/PP-DocLayoutV3).