{"id":20358022,"url":"https://github.com/arnabd64/layoutlm-annotator","last_synced_at":"2026-04-19T11:35:28.072Z","repository":{"id":190313413,"uuid":"680423878","full_name":"arnabd64/LayoutLM-Annotator","owner":"arnabd64","description":null,"archived":false,"fork":false,"pushed_at":"2023-08-27T15:37:29.000Z","size":14,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-15T01:42:03.033Z","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/arnabd64.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-19T07:31:56.000Z","updated_at":"2024-05-23T13:23:46.000Z","dependencies_parsed_at":"2024-11-14T23:26:33.716Z","dependency_job_id":"7de5c829-7631-4f2f-a4db-6a8ae3632458","html_url":"https://github.com/arnabd64/LayoutLM-Annotator","commit_stats":null,"previous_names":["arnabd64/layoutlm-annotator"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnabd64%2FLayoutLM-Annotator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnabd64%2FLayoutLM-Annotator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnabd64%2FLayoutLM-Annotator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnabd64%2FLayoutLM-Annotator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arnabd64","download_url":"https://codeload.github.com/arnabd64/LayoutLM-Annotator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241895297,"owners_count":20038511,"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-14T23:24:58.395Z","updated_at":"2026-04-19T11:35:23.033Z","avatar_url":"https://github.com/arnabd64.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Annotation Tool for LayoutLM\n\n## Overview\n\nAnnotating images for fine tuning the LayoutLM model requires a lot of manual work which includes the three major steps:\n\n1. Drawing bounding boxes around the texts\n2. Labelling the bounding boxes\n3. Manually type in the text in those bounding boxes\n\nThere are a lot of ML assisted annotation tools in the market that can make the job much easier but they can cost the user money. Thus I present the community with an annotation tool that automates steps 1 and 3. This can be acheived using __Label Studio__ and __PaddleOCR__, both of them are Open Source but the advantage of my tool is that you can use your own Models for Text Detection and/or Text Recognition Model (you have to overwrite a method in the code)\n\n### How it works?\n\n1. Copy-Paste all your images into the `images` folder.\n2. Run the `generate.py` script to create a __Label Studio Annotation Job__ (A JSON file). (In this step the __PaddleOCR__ model will detect the Text Bounding boxes and the Recognisied text. Thus completing steps 1 and 3, mentioned above).\n3. Upload this JSON file to Label Studio to start the Annotation Job.\n4. All you have to do is to label each bounding box and fix the bounding boxes and the OCR text.\n5. After the Annotation Job is done, export the annotation using `JSON-MIN` export option.\n6. Use `distill.py` to postprocess the annotations so that thet can be ingested by the LayoutLM model without any preporcessing. \n\n## Installation\n\n```bash\n$ git clone 'https://github.com/arnabd64/LayoutLM-Annotator.git'\n$ cd LayoutLM-Annotator\n\n# create a virtual environment\n# using conda\n$ conda create -n label python=3.10\n$ conda activate label\n\n# using venv\n$ python3 -m venv label\n$ source label/bin/activate\n\n# install packages\n$ pip3 install -r requirements.txt\n```\n\nOnce the process is done then the annotation tool has been installed.\n\n## Getting started with the Annotation\n\n### STEP 1:\n\nPut all your image data inside the `images` folder.\n\n### STEP 2: (Optional) \n\nThe `server.py` script will run a HTTP file server on `http://localhost:9000/` if you want to change the port from 9000 to a port of your choice replace the `PORT` variable on line 11.\n\n### STEP 3: (Important)\n\nOpen `generate.py` and change the `ANNOTATION_NAME` variable to what to want. Run the script\n\n### STEP 4: (Important)\n\nRun `server.py`\n\n### STEP 5:\n\nRun the Label Studio server byb executing: `label-studio --data-dir ./data`\n\n### STEP 6:\n\n- Do the usual Sign Up and Login In stuff.\n- Once Inside the application, create a project\n- Give it in an appropiate name\n- In `Data Import` Tab, Upload the `.json` file that was created by `generate.py`.\n- In the `Annotation` Tab, choose __Optical Character Recognition__.\n- Start the Project\n\n### STEP 7:\n\nOnce the Annotation Job is done then hit the `Export` button and export it under the `JSON-MIN` option.\n\n### STEP 8:\n\nOpen `distill.py` and the variables `LABEL_STUDIO_JSON_PATH` to the file name of the JSON export from label studio and optionally you can change the variable `DISTILLED_ANNOIATIONS` variable to change the name of the postprocessed JSON file.\n\nRun `distill.py`\n\n### All is Done\n\n# Issues and Forks\n\nIf you are facing any issues with the code and is unable to solve then do raise an issue on the github repo issues section. You have a faced an issue and have modified the code to solve then you can share it with other community members and me by raising an issue and writing down the solution in the comments section.\n\nOther members odf the community feel free to Fork this repo and do leave a star on this repo.\n\n# Acknowledgements\n\n1. [@AIOdysseyhub](https://www.youtube.com/@AIOdysseyhub/videos) YouTube channel for the inspiration as well as the first draft of the code.\n2. [Label Studio Documentation](https://labelstud.io/templates/optical_character_recognition.html)\n3. [PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farnabd64%2Flayoutlm-annotator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farnabd64%2Flayoutlm-annotator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farnabd64%2Flayoutlm-annotator/lists"}