This project is a web application that allows users to upload images and extract text from those images using Optical Character Recognition (OCR). It leverages FastAPI for the backend and includes real-time notifications via WebSocket to inform users about the upload and processing status.
- Image Upload: Users can upload image files through a simple web interface.
- OCR Processing: The application uses Tesseract to extract text from uploaded images.
- Real-Time Notifications: Users receive real-time updates about the upload and processing status.
- Extracted Text Display: The extracted text is displayed on the webpage once processing is complete.
- Backend: FastAPI
- OCR Library: Tesseract
- Frontend: HTML, CSS, JavaScript
- Database: PostgreSQL (optional for extended functionality)
- WebSocket: For real-time notifications
- Containerization: Docker
- Docker
- Docker Compose
- (Optional) PostgreSQL installed on your machine if you plan to use it directly instead of in Docker.
-
Clone the repository:
git clone https://github.com/ankikumar1018/fastapi-ocr-webapp.git cd <repository-directory>
-
Build and run the Docker containers:
docker-compose up --build
-
Access the application: Open your web browser and go to
http://127.0.0.1:8000/
.
-
Clone the repository:
git clone <repository-url> cd <repository-directory>
-
Create a virtual environment::
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install required packages:
pip install fastapi uvicorn python-multipart aiofiles pytesseract pillow psycopg2-binary websockets
-
Install Tesseract:
git clone <repository-url> cd <repository-directory>
-
Install Tesseract:
- Follow the instructions for your operating system to install Tesseract.
- Ensure Tesseract is added to your system's PATH.
-
Start the FastAPI server:
uvicorn app:app --reload
-
Access the application: Open your web browser and go to
http://127.0.0.1:8000/
.
- Use the upload form to select an image file and click the "Upload" button.
- Watch for real-time notifications that indicate the status of your upload and OCR processing.
- After processing is complete, The extracted text will be displayed below the upload form.
To enable PostgreSQL storage for extracted data:
- Install PostgreSQL on your machine.
- Create a database and configure your connection in the FastAPI application (if implemented).
- Modify the code to store the extracted text and metadata in the database.
This project is licensed under the MIT License.
Contributions are welcome! Feel free to submit a pull request or open an issue for improvements or bugs.