| title | LUNG AI |
|---|---|
| emoji | 🫁 |
| colorFrom | green |
| colorTo | gray |
| sdk | gradio |
| sdk_version | 6.5.1 |
| app_file | app.py |
| pinned | false |
LungAI is a deep learning project aimed at detecting and classifying lung cancer from CT scan images. This model uses a ResNet50 architecture with transfer learning to differentiate between cancerous and non-cancerous lung tissue, as well as classify specific types of lung cancer.
This model was trained for 50 epochs on the dorsar/lung-cancer dataset, achieving the following performance on the test set:
-
Final Test Accuracy: 83.73%
-
Best Validation Accuracy: 81.94%
-
Architecture/: Contains the core model script.
- architecture.py: Defines, trains, and evaluates the ResNet50 model.
-
Processed_Data/: (Not in repository) Directory created by the preprocessor.
-
app.py: Runs the Gradio web demo.
-
preprocess.py: Downloads and organizes data from Hugging Face.
-
requirements.txt: List of Python dependencies.
-
lung_cancer_detection_model.pth: (Generated) PyTorch weights.
-
lung_cancer_detection_model.onnx: (Generated) ONNX model for deployment.
The dataset is sourced from Hugging Face and is downloaded by the preprocess.py script:https://huggingface.co/datasets/dorsar/lung-cancer
Step 1: Install DependenciesFirst, ensure you have Python installed. Then, install the required Python libraries using the following command:
Bash
pip install -r requirements.txt
Step 2: Log in to Hugging FaceTo avoid rate-limiting errors when downloading the dataset, log in using the Hugging Face CLI:
Bash
huggingface-cli login
Step 3: Download and Preprocess DataRun the preprocessing script. This will download the dataset, map the classes, and save them in the correct Processed_Data directory.
Bash
python preprocess.py
Step 4: Train the ModelRun the training script. This will train the model using your GPU, print the progress, and save the final .pth and .onnx model files.
Bash
python Architecture/architecture.py
**Step 5: Run the Model (Demo)**Run the Gradio application to see your trained model in action.
Bash
python app.py
This will provide a local URL to open in your browser.
-
The preprocess.py script automatically creates the Processed_Data directory with train, validation, and test subdirectories.
-
The architecture.py script is set up to find these specific folders.
If you would like to contribute to this project, please fork the repository and submit a pull request. We welcome improvements, bug fixes, and new features.