CoolFace
Modelpublic

HuggingPanda/docling-layout

sourceHugging Faceupdated 1y agoView on Hugging Face
6likes4.7kdownloads
README.md75 linesDownload Raw Back to root
1---2language:3- en4base_model:5- ds4sd/docling-models6pipeline_tag: object-detection7---8# Docling Model for Layout9 10This is the **Docling model for layout detection**, designed to facilitate easy importing and usage like any other Hugging Face model.11 12This model is part of the [Docling repository](https://huggingface.co/ds4sd/docling-models), which provides document layout analysis tools.13 14## **Usage Example**15Here's how you can load and use the model:16 17```python18import torch19from PIL import Image20from transformers import RTDetrForObjectDetection, RTDetrImageProcessor21 22# Load the model and processor23image_processor = RTDetrImageProcessor.from_pretrained("HuggingPanda/docling-layout")24model = RTDetrForObjectDetection.from_pretrained("HuggingPanda/docling-layout")25 26# Load an image27image = Image.open("hocr_output_page-0001.jpg")28 29# Preprocess the image30resize = {"height":640, "width":640}31inputs = image_processor(32    images=image,33    return_tensors="pt",34    size=resize,35)36 37# Perform inference38with torch.no_grad():39    outputs = model(**inputs)40 41# Post-process results42results = image_processor.post_process_object_detection(43    outputs, 44    target_sizes=torch.tensor([image.size[::-1]]), 45    threshold=0.346)47 48# Print detected objects49for result in results:50    for score, label_id, box in zip(result["scores"], result["labels"], result["boxes"]):51        score, label = score.item(), label_id.item()52        box = [round(i, 2) for i in box.tolist()]53        print(f"{model.config.id2label[label+1]}: {score:.2f} {box}")54 55```56 57 58## **Model Information**59- **Base Model:** RT-DETR (Robust Transformer-based Object Detector)60- **Intended Use:** Layout detection for documents61- **Framework:** [Hugging Face Transformers](https://huggingface.co/docs/transformers/index)62- **Dataset Used:** Internal dataset for document structure recognition63- **License:** Apache 2.064 65## **Citing This Model**66If you use this model in your work, please cite the main **Docling repository**:67 68```69@misc{docling2024, title={Docling Models for Document Layout Analysis}, author={DS4SD Team}, year={2024}, howpublished={Hugging Face Repository}, url={https://huggingface.co/ds4sd/docling-models} }70```71 72For more details, visit the main repo: [ds4sd/docling-models](https://huggingface.co/ds4sd/docling-models).73 74## **Contact**75For questions or issues, please open a discussion on Hugging Face or contact [pandahd75@gmail.com].