Instructions to use mancooper/lung_cancer_detection with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use mancooper/lung_cancer_detection with Keras:
# !pip install -U keras tensorflow huggingface_hub # Keras needs TensorFlow installed to read "hf://" paths, so the tensorflow backend is selected here; # "jax" and "torch" also work for computation once TensorFlow is installed. import os os.environ["KERAS_BACKEND"] = "tensorflow" import keras model = keras.saving.load_model("hf://mancooper/lung_cancer_detection") - Notebooks
- Google Colab
- Kaggle
Lung Cancer Detection Using CNN Model Description A convolutional neural network (CNN) built with TensorFlow and Keras to classify lung MRI images into two dataset categories: cancer and no_cancer.
This is an experimental image-classification project for educational and research purposes. It is not a clinically validated diagnostic system and must not be used to make medical decisions. Model Details
- Architecture: Custom CNN
- Framework: TensorFlow / Keras
- Task: Binary image classification
- Input image size: 128 ร 128 pixels
- Input channels: 3 (RGB)
- Preprocessing: Pixel values converted to float32 and normalized to the range [0, 1]
- Convolutional layers: 3, with 32, 64, and 128 filters
- Dense layer: 256 units with ReLU activation
- Output layer: 1 unit with sigmoid activation
- Optimizer: Adam
- Loss function: Binary cross-entropy
- Batch size: 32
- Training epochs: 20
- Random seed: 42
- Saved model filename: lung_cancer_model.keras Intended Use
- Educational demonstrations of CNN-based medical-image classification
- Experimentation with image preprocessing, model training, and inference
- Research prototypes that require further validation Out-of-Scope Use
- Clinical diagnosis or screening
- Treatment decisions or patient triage
- Use as a substitute for a radiologist or other qualified medical professional
- Deployment in clinical settings without appropriate independent validation, regulatory review, and clinical oversight Dataset and Training The code loads images from a directory with class subfolders using tf.keras.utils.image_dataset_from_directory. It creates a training split (80%) and validation split (20%), using seed 42. Images are resized to 128 ร 128 pixels and normalized by dividing pixel values by 255.
The dataset path in the original training script points to a Google Drive folder. The dataset name, source, licensing, number of images, patient-level separation, and class distribution are not documented in the supplied code and should be added when known. Evaluation The script evaluates the model on the validation split and prints validation loss and validation accuracy. No measured evaluation values are included in the supplied code, so no performance figures are claimed here.
For a stronger evaluation, report accuracy, precision, recall/sensitivity, specificity, F1 score, ROC-AUC, and a confusion matrix on a separate held-out test set. Ensure images from the same patient cannot leak across training and evaluation splits. Inference The prediction helper loads one image, resizes it to 128 ร 128, converts it to an array, normalizes pixel values to [0, 1], and passes it to the model.
Important implementation note: the model's sigmoid output represents the probability of the class encoded as label 1. The script's prediction function assumes a particular class order and reverses the probability for one label. Verify train_ds.class_names and the numeric label mapping before interpreting predictions or confidence scores. Limitations
- Performance and generalization have not been established by the supplied code alone.
- The code uses a validation split from the training directory; it does not define an independent test set.
- Dataset provenance, size, class balance, image acquisition details, and patient-level split strategy are unspecified.
- The script assumes three-channel RGB input, which may not preserve all relevant characteristics of the original MRI data.
- A displayed model confidence is not proof of diagnostic accuracy or clinical certainty. Ethical and Safety Considerations This model may produce false-positive and false-negative predictions. Medical imaging varies across scanners, institutions, patient populations, and acquisition protocols. Any research use should include expert review, representative external validation, privacy safeguards, and appropriate ethical and regulatory review. How to Load the Model import tensorflow as tf
model = tf.keras.models.load_model("lung_cancer_model.keras") How to Reproduce Training The supplied training script uses TensorFlow/Keras, a directory-based image dataset, a fixed random seed of 42, a batch size of 32, and 20 training epochs. Update the dataset path to match your environment before running it. License The MIT license is declared in this model card's metadata. Ensure this license is appropriate for the model weights and dataset, and include the corresponding license file in the repository.
- Downloads last month
- 36