An image translator app that auto-translates foreign language images into a language of your choice.
- Upload your image
- Call
EasyOCR
to perform text localisation - Call
OpenAI
's GPT model to translate - Use
Image
to cover bbox coordinates and dynamically overlays with text - Sends back images in a zipped file to client.
- Wala! Image translated!
The following instructions setups a new virtual environment for python and installs the needed libraries.
These instructions assumes that the user is using a Windows machine.
python -m venv .venv
.venv\Scripts\activate
To install CUDA-supported PyTorch: https://pytorch.org/get-started/locally/ (12.1 in this example)
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
Install dependencies from requirements.txt file:
pip install -r requirements.txt
This repository provides a guide to set up the React front-end application with the Flask back-end API.
Before getting started, make sure you have the following installed:
- Node.js and npm (for React)
- Python and pip (for Flask)
Navigate to the react-spa-template-master
folder and follow the README.md
instructions inside to setup.
Setup Flask environment variable inside Windows PowerShell
$env:FLASK_APP = "flask_server.app"
Check with this:
echo $env:FLASK_APP
Activate the virtual environment and run it
.venv\Scripts\activate
cd flask_server
flask run
You may need to enable cross-origin requests between your React app and Flask API. Modify the file FYP\flask_server\app.py
, at line 30: origins
to configure for your local production address.
CORS(app, origins=['https://localhost:5000', 'https://{insert your hostname}}'])
Install mkcert
with this guide.
Afterwards, installing it as such will create a local CA certificate and add it to your system's trust store, allowing mkcert to generate valid SSL certificates for local domains.
mkcert -install
Afterwards, navigate to settings_config
and run this command:
mkcert -key-file localhost.key -cert-file localhost.crt localhost
- Visit OpenAI website and get access to an API key.
- Create a
settings.py
file in.\language_translation\
and fill in your details as such:
OPEN_AI_KEY = "YOUR_API_KEY"
- Start both the React development server and the Flask API.
- Use Postman or send a file upload request from your React app to the Flask API.
- Verify that the file upload works and CORS headers are properly set.
Once everything has been set up properly, to start the app, simply double click the run_servers.bat
file.
If that doesn't work, you can run these codes below on separate terminals.
.venv\Scripts\activate
cd .\react-spa-template-master\
npm start
.venv\Scripts\activate
cd .\flask_server\
flask run
Contributions are welcome! If you find any issues or have suggestions for improvement, please open an issue or create a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.