{"id":19526691,"url":"https://github.com/layout-parser/layout-model-training","last_synced_at":"2025-04-09T15:04:22.056Z","repository":{"id":43874488,"uuid":"277918429","full_name":"Layout-Parser/layout-model-training","owner":"Layout-Parser","description":"The scripts for training Detectron2-based Layout Models on popular layout analysis datasets ","archived":false,"fork":false,"pushed_at":"2023-09-26T07:22:34.000Z","size":24,"stargazers_count":209,"open_issues_count":16,"forks_count":56,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-09T15:03:37.925Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Layout-Parser.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-07-07T20:44:41.000Z","updated_at":"2025-04-08T14:08:36.000Z","dependencies_parsed_at":"2024-01-14T15:22:38.348Z","dependency_job_id":"f4cd874b-718c-4865-98bb-12892a03760e","html_url":"https://github.com/Layout-Parser/layout-model-training","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Layout-Parser%2Flayout-model-training","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Layout-Parser%2Flayout-model-training/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Layout-Parser%2Flayout-model-training/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Layout-Parser%2Flayout-model-training/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Layout-Parser","download_url":"https://codeload.github.com/Layout-Parser/layout-model-training/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248055276,"owners_count":21040156,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T01:11:43.898Z","updated_at":"2025-04-09T15:04:21.985Z","avatar_url":"https://github.com/Layout-Parser.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Scripts for training Layout Detection Models using Detectron2\n\n## Usage\n\n### Directory Structure\n\n- In `tools/`, we provide a series of handy scripts for converting data formats and training the models.\n- In `scripts/`, it lists specific command for running the code for processing the given dataset. \n- The `configs/` contains the configuration for different deep learning models, and is organized by datasets.\n\n### How to train the models? \n\n- Get the dataset and annotations -- if you are not sure, feel free to check [this tutorial](https://github.com/Layout-Parser/layout-parser/tree/main/examples/Customizing%20Layout%20Models%20with%20Label%20Studio%20Annotation). \n- Duplicate and modify the config files and training scripts\n    - For example, you might want to copy [`configs/prima/fast_rcnn_R_50_FPN_3x`](configs/prima/fast_rcnn_R_50_FPN_3x.yaml) to [`configs/your-dataset-name/fast_rcnn_R_50_FPN_3x`](configs/prima/fast_rcnn_R_50_FPN_3x.yaml), and you can create your own `scripts/train_\u003cyour-dataset-name\u003e.sh` based on [`scripts/train_prima.sh`](scripts/train_prima.sh).\n    - You'll modify the `--dataset_name`, `--json_annotation_train`, `--image_path_train`, `--json_annotation_val`, `--image_path_val`, and `--config-file` args appropriately. \n- If you have a dataset with segmentation masks, you can try to train with the [`mask_rcnn model`](configs/prima/mask_rcnn_R_50_FPN_3x.yaml); otherwise you might want to start with the [`fast_rcnn model`](configs/prima/fast_rcnn_R_50_FPN_3x.yaml)\n    - If you see error `AttributeError: Cannot find field 'gt_masks' in the given Instances!` during training, this means you should not use \n\n## Supported Datasets\n\n- Prima Layout Analysis Dataset [`scripts/train_prima.sh`](https://github.com/Layout-Parser/layout-model-training/blob/master/scripts/train_prima.sh)\n    - You will need to download the dataset from the [official website](https://www.primaresearch.org/dataset/) and put it in the `data/prima` folder. \n    - As the original dataset is stored in the [PAGE format](https://www.primaresearch.org/tools/PAGEViewer), the script will use [`tools/convert_prima_to_coco.py`](https://github.com/Layout-Parser/layout-model-training/blob/master/tools/convert_prima_to_coco.py) to convert it to COCO format. \n    - The final dataset folder structure should look like:\n        ```bash\n        data/\n        └── prima/\n            ├── Images/\n            ├── XML/\n            ├── License.txt\n            └── annotations*.json\n        ```\n\n## Reference \n\n- **[cocosplit](https://github.com/akarazniewicz/cocosplit)**  A script that splits the coco annotations into train and test sets.\n- **[Detectron2](https://github.com/facebookresearch/detectron2)** Detectron2 is Facebook AI Research's next generation software system that implements state-of-the-art object detection algorithms. ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flayout-parser%2Flayout-model-training","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flayout-parser%2Flayout-model-training","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flayout-parser%2Flayout-model-training/lists"}