This Django REST Framework API provides functionality for Optical Character Recognition (OCR) on medical Complete Blood Count (CBC) reports. It extracts details such as White Blood Cell (WBC) count, Red Blood Cell (RBC) count, Platelet Count, and Hemoglobin levels from uploaded images of CBC reports.
To set up this API locally, follow these steps:
- Clone this repository to your local machine:
git clone <repository-url>
- Navigate to the project directory:
cd <project-directory>
- Create a virtual environment (optional but recommended):
python -m venv venv
-
Activate the virtual environment:
- On Windows:
venv\Scripts\activate
- On macOS and Linux:
source venv/bin/activate
- Install the required dependencies:
pip install -r requirements.txt
- Run migrations to set up the database (assuming you have Django models):
python manage.py migrate
- Start the Django development server:
python manage.py runserver
Send a POST request to the endpoint /ocr/
with a multipart form containing an image file named image
. The API will perform OCR on the uploaded image and extract details from the CBC report.
The API returns a JSON response with the extracted details and patient status:
{
"status_patient": "Good",
"details_OCR_CBC": {
"WBC": 7.2,
"RBC": 5.5,
"Platelet Count": 280,
"Hemoglobin": 15.6
}
}
The status_patient
field indicates whether the patient's CBC report falls within acceptable ranges. If any detail is outside the acceptable range, status_patient
will be set to "Not Good".
https://radwan-ocr-api.onrender.com/
- Python (3.x recommended)
- Django (3.x)
- Django REST Framework (3.x)
- OpenCV (for image processing)
- Pytesseract (for OCR)
- numpy
- re