This project is structured into three main parts, each fulfilling a critical role in the overall functionality of the application. Here’s a quick overview of each component:
-
Backend (Folder:
back
)- The backend of this application is developed using FastAPI, a modern, fast (high-performance), web framework for building APIs with Python 3.6+ based on standard Python type hints. This component is responsible for handling all server-side logic, including API endpoints, database interactions, and server-side processing.
-
Frontend (Folder:
front/thoraxinsight
)- The frontend is built using React, a popular JavaScript library for building user interfaces. This part of the application handles the client-side rendering, providing a dynamic and interactive user experience. All the UI components, state management, and client-side routing are implemented here.
-
Neural Network Training (Folder:
training
)- This folder contains all the Python scripts necessary for training the neural network. It includes the data preprocessing scripts, model definition, training loop, and evaluation metrics. Additionally, the final trained model is exported and stored as a file, which is utilized by the backend for making predictions.
Below, you will find detailed instructions on how to set up and run each part of the project.
- Clone the repository to your local machine:
git clone https://github.com/AML4206-MINE20242/Proyecto_AML.git cd Proyecto_AML
-
Navigate to the
back
directory:cd back
-
Create a virtual environment and activate it:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the required dependencies:
pip install -r requirements.txt
-
Run the FastAPI server:
uvicorn main:app --reload
The backend server will be running at
http://127.0.0.1:8000
.
-
Navigate to the
front/thoraxinsight
directory:cd front/thoraxinsight
-
Install the required dependencies:
npm install
-
Start the React development server:
npm start
The frontend will be running at
http://localhost:3000
.
For a containerized deployment, you can use the provided Dockerfile
for backend and frontend.
-
Navigate to the root directory of the project (if not already there):
cd Proyecto_AML
-
Build the Docker image for the backend and worker:
docker build -t proyecto_aml_backend_worker .
-
Run the Docker container for the backend and worker:
docker run -p 8000:8000 proyecto_aml_backend_worker
-
Navigate to the
front
directory:cd front
-
Build the Docker image for the frontend:
docker build -t proyecto_aml_front .
-
Run the Docker container for the frontend:
docker run -p 3000:3000 proyecto_aml_front
This will start both the backend service and the frontend inside Docker containers. Ensure the frontend is configured to communicate with the backend via the appropriate API endpoints.
By following these steps, you should have the entire project up and running, allowing you to interact with the backend API, use the frontend interface, and train the neural network model.
The chosen model for deployment is DenseNet121 from Torch library. To train the model follow the next steps:
- Navigate to the
training
directory:cd training
- Enter to the dataset folder where CheXPert dataset will be located
cd CheXpert-v1.0-small
- Download the CheXPert database from the following link
- Unzip the folder to obtain the dataset
unzip CheXpert-v1.0-small.zip
- Locate yourself at the level of the folder training
cd ..
- Run the main3.py
python main3.py