Brain_ Tumor_ Detector_swin

Devarshi

Introduction

The Brain Tumor Detector Swin model is a fine-tuned version of Microsoft's swin-base-patch4-window7-224-in22k model, optimized for image classification tasks on the imagefolder dataset. It demonstrates high performance metrics on the evaluation set, achieving an accuracy of 99.81%, an F1 score of 99.85%, recall of 99.90%, and precision of 99.80%.

Architecture

This model utilizes the Swin Transformer architecture, which is known for its efficiency in handling image classification tasks. The fine-tuning process enhances its capability to detect and classify images of brain tumors with high accuracy using a window-based self-attention mechanism.

Training

The model was trained with specific hyperparameters, including a learning rate of 5e-05, a train batch size of 32, and a total train batch size of 128 due to gradient accumulation steps. The optimizer used was Adam, with a linear learning rate scheduler that included a warmup ratio of 0.1. The training spanned three epochs. During training, the model progressively improved, evidenced by a final validation loss of 0.0054 and high performance metrics.

Guide: Running Locally

  1. Setup Environment: Ensure Python is installed, and create a virtual environment. Install the required libraries using pip:

    pip install torch transformers datasets
    
  2. Download Model: Use the Hugging Face Transformers library to load the model:

    from transformers import SwinForImageClassification, SwinConfig
    model = SwinForImageClassification.from_pretrained('Devarshi/Brain_Tumor_Detector_swin')
    
  3. Prepare Data: Ensure that your dataset is in the correct format (imagefolder).

  4. Inference: Use the model on your input data for predictions.

    # Example inference code
    from transformers import SwinFeatureExtractor
    feature_extractor = SwinFeatureExtractor.from_pretrained('Devarshi/Brain_Tumor_Detector_swin')
    
  5. Cloud GPUs: For better performance, consider using cloud GPU services such as AWS EC2, Google Cloud, or Azure to handle computational demands efficiently.

License

The Brain Tumor Detector Swin model is licensed under the Apache 2.0 License, allowing for wide use and distribution with minimal restrictions.

More Related APIs in Image Classification