Spaces:
Runtime error
Runtime error
Create README2.md
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129_\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_ _\\-------- **Image Data Extractor** -------\\_ _\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_
# Overview:The **Image Data Extractor** is a Python-based tool designed to extract and structure text data from images of visiting cards using **PaddleOCR**. The tool processes the extracted text to recognize key information such as name, designation, contact number, address, and company name, organizing the output into a well-defined structure. The **Mistral 7B model** is used for advanced text analysis, and if it becomes unavailable, the system seamlessly switches to the **Gliner urchade/gliner_mediumv2.1** model.
# Installation Guide:
1. **Create and Activate a Virtual Environment** ```bash python -m venv venv source venv/bin/activate # For Linux/Mac # or venv\Scripts\activate # For Windows ```
2. **Install Required Libraries** ```bash pip install -r requirements.txt ```
3. **Run the Application** - If Docker is being used: ```bash docker-compose up --build ``` - Without Docker: ```bash python app.py ```
4. **Set up Hugging Face Token** - Add your Hugging Face token in the `.env` file: ```bash HF_TOKEN=<your_huggingface_token> ```
# File Structure Overview:
```ImageDataExtractor/ββββ app.py # Main Flask appβββ requirements.txt # Dependenciesβββ Dockerfile # Docker container setupβββ docker-compose.yml # Docker Compose setupβ βββ utility/ β βββ utils.py # PaddleOCR integration, Image preprocessing and Mistral model processing β βββ template/ β βββ index.html # UI for image uploadsβ βββ result.html # Display extracted resultsβ βββ Backup/ β βββ modules/ # Base classes for data processing modelsβ β βββ base.py β β βββ data_proc.py β β βββ evaluator.py β β βββ layers.py β β βββ run_evaluation.py β β βββ span_rep.py β β βββ token_rep.py β βββ backup.py # Backup handlingβ βββ model.py # Gliner Model integration and backup logicβ βββ save_load.py # Mistral 7B model integration and backup logicβ βββ train.py # Mistral 7B model integration and backup logicβ βββ .env # Environment variables (includes Hugging Face token)```
# Program Overview:
### PaddleOCR Integration (utility/utils.py):- **Text Extraction**: The tool utilizes **PaddleOCR** to extract text from image-based inputs (PNG, JPG, JPEG) of visiting cards.- **Preprocessing**: Handles basic image preprocessing to enhance text recognition for OCR.
### Mistral 7B Integration (utility/utils.py):- **Data Structuring**: After text extraction, the **Mistral 7B model** processes the extracted data, structuring it into fields such as name, designation, contact number, address, and company name. ### Fallback Mechanism (Backup/backup.py):- **Gliner urchade/gliner_mediumv2.1 Model**: If the Mistral model is unavailable, the system uses the **Gliner urchade/gliner_mediumv2.1 model** to perform the same task, ensuring continuous service.- **Error Handling**: Manages failures in model availability and ensures smooth fallback.
### Web Interface (app.py):- **Flask API**: Provides endpoints for image uploads and displays the results in a structured manner.- **HTML Interface**: A frontend for users to upload images of visiting cards and view the parsed results.
# Tree Map of the Program:
```app.pyβββ Handles Flask API and web interfaceβββ Manages file uploadβββ Extracts text with PaddleOCRβββ Processes text with Mistral 7Bβββ Displays structured results
utility/utils.pyβββ PaddleOCR for text extractionβββ Mistral 7B for data structuring
Backup/backup.pyβββ Gliner urchade/gliner_mediumv2.1 as fallbackβββ Backup and error handling
Backup/model.pyβββ Mistral 7B integration and processing logic```
# Main Task:The main objective is to extract and structure text data from visiting cards. The system identifies and organizes:- **Name**- **Designation**- **Phone Number**- **Address**- **Company Name**
# References:
- [PaddleOCR Documentation](https://github.com/PaddlePaddle/PaddleOCR)- [Mistral 7B Documentation](https://huggingface.co/)- [Gliner urchade/gliner_mediumv2.1 Documentation](https://huggingface.co/)- [Flask Documentation](https://flask.palletsprojects.com/)- [Docker Documentation](https://docs.docker.com/)- [Virtual Environments in Python](https://docs.python.org/3/tutorial/venv.html)
---README2.mdAdded+129