This repository contains a Flask-based web application for osteoarthritis (OA) prediction and detection. The application integrates multiple machine learning models to process clinical data and X-ray images, and it uses a Retrieval-Augmented Generation (RAG) pipeline to automatically generate patient reports. A separate FAISS index is used to quickly retrieve context from a document (e.g., report_rules.txt) to guide report generation.
- Clinical Data Processing
- Accepts clinical parameters via a form.
- Uses a pre-trained TensorFlow model and XGBoost classifiers for multi-class (including KL scoring) and binary OA predictions.
- Image Processing
- Upload X-ray images for model prediction using TensorFlow-based image processing.
- Fusion of Predictions
- Combines predictions from both clinical data and image analysis.
- RAG-based Patient Report Generation
- Uses a separate FAISS index built from a report rules document (
report_rules.txt) to retrieve relevant context. - Augments the patient report query with retrieved context and uses the OpenAI API (via a proxy) to generate a concise, evidence-based report.
- Uses a separate FAISS index built from a report rules document (
- Chatbot Integration
- Provides a chatbot interface (via the
/chatroute) that supports a RAG-based dialogue system for answering user queries.
- Provides a chatbot interface (via the
- Markdown Support
- A custom Jinja filter converts text wrapped in
**to bold HTML, enhancing report readability.
- A custom Jinja filter converts text wrapped in
- Security & Configuration
- Uses environment variables (via python-dotenv) to securely manage API tokens and configuration settings.
- Python 3.8+
- pip
- Virtualenv (recommended)
-
Clone the repository:
git clone https://github.com/yourusername/oafinalllm.git cd oafinalllm/oa_detection_app -
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use: venv\Scripts\activate
-
Install the required packages:
pip install -r requirements.txt
A sample
requirements.txtmight include:Flask tensorflow numpy pandas joblib xgboost scikit-learn faiss-cpu openai python-dotenv
-
Environment Variables:
Create a
.envfile in the root of the project (or in theoa_detection_appdirectory) with the following keys:AIPROXY_TOKEN=your_actual_token_here API_BASE_URL=https://aiproxy.sanand.workers.dev/openai/v1 replace it with your base and token