/translation_layoutrecovery

This is a project that translates a .pdf file, preserving the original layout of that .pdf file. [UPDATED] We have achieved the Second Prize of the Cinnamon AI Bootcamp 2023. Simple fork. Easing out.

Primary LanguagePython

5tasy

A web app for Paper Translation with Layout Recovery!

Contributors

Name Profile
Phạm Khánh Trình @phkhanhtrinh23
Nguyễn Bảo Tín @nbtin
Yang Tuấn Anh @YangTuanAnh
Nguyễn Hoàng Ngọc Hà @ngochafromdn
Nguyễn Minh Lý @lynguyenminh

1. Table of Contents

2. About The Project

Translation with Layout Recovery is a cutting-edge approach in the field of natural language processing that goes beyond traditional machine translation methods. While conventional translation models focus solely on converting text from one language to another, 5tasy takes into account the visual layout and formatting of the text. This approach aims to preserve not only the linguistic content but also the spatial arrangement, font styles, and other visual elements present in the source text. Some detailed information can be found in this slide and our YouTube presentation.

3. Technical Overview

  • Frontend: NextJS, TailwindCSS, NodeJS, Yarn.
  • Backend: Django REST Framework.
  • Database: PostgreSQL.
  • Storage: Firebase Cloud Storage.
  • Deployment: Docker (Docker-compose).
  • AI Core:
    • NMT: envit5-translation.
    • Layout Recovery: MaskRCNN.
    • OCR: EasyOCR.
    • Spelling Correction (Japanese): JGEC

4. Repo Structure

.
├── Backend
│   ├── account
│   ├── services
│   └── translation
├── Frontend
│   ├── app
│   │   ├── api
│   │   ├── components
│   │   ├── history
│   │   │   └── api
│   │   ├── login
│   │   │   └── api
│   │   ├── profile
│   │   │   └── api
│   │   └── register
│   │       └── api
│   └── public
└── Model
    └── utils
    └── main.py

5. How to Install

To install and run the 5tasy web app, please follow the steps below:

  1. Ensure that Docker is installed on your system. You can download and install Docker from the official website: Docker Engine for Ubuntu or Docker Desktop.

  2. Clone this repository to your local machine using the following command:

    git clone https://github.com/phkhanhtrinh23/translation_layoutrecovery.git
  3. Navigate to the project directory:

    cd translation_layoutrecovery

    Important: Then, put the necessary environment files (.env) in this folder.

  4. Build the Docker image and run the container using the following command:

    docker compose up --build
  5. Wait for the installation process to complete. Once the downloading is done, the web app will be ready to use.

  6. To stop the web app, press Ctrl + C in the terminal and run the following command:

    docker compose down

6. Usage

To use the web app, follow the steps below:

  1. Open your web browser and navigate to http://localhost:3000.

  2. You first need to register the account and sign in to use the web functions.

  3. In the web app, you can browse and upload an English PDF file using the provided interface.

  4. Click to choose the target language and Hit the Translate button to start the translation process.

  5. The model will then process your file and return the translated PDF file with the same layout as the original one. Hit the Translated linklabel or open the History bar to view the result. Here you can open to view and download your files.

  6. You can also search for your files in the History bar by entering the keywords in the search box.

7. References

  • MaskRCNN - phamquiluan - PubLayNet
  • EasyOCR - JadedAI - jaded.ai
  • envit5-translation - Chinh Ngo, Trieu H. Trinh, Long Phan, Hieu Tran, Tai Dang, Hieu Nguyen, Minh Nguyen, Minh-Thang Luong - huggingface.co.
  • opus-mt-en-jap - Helsinki-NLP - huggingface.co.
  • GECToR - Kostiantyn Omelianchuk, Vitaliy Atrasevych, Artem Chernodub, Oleksandr Skurzhanskyi - aclanthology.org
  • Guides on using Docker for Python application - Docker docs.
  • Install Docker Engine on Ubuntu - Docker docs.

Contribution

Contributions are what make GitHub such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the project
  2. Create your Contribute branch: git checkout -b contribute/Contribute
  3. Commit your changes: git commit -m 'add your messages'
  4. Push to the branch: git push origin contribute/Contribute
  5. Open a pull request