Skip to content

amine0110/medical-imaging-classification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Medical Imaging Classification

Is Frozen Weight Transfer Learning Always the Answer?

This repo's main focus isn't on data processing or creating image classification models like Inception, Xception, VGG16, etc. However, it is about how you may improve your accuracy by changing just one parameter. Naturally, instructions and code for training a classification model will be given.

image

Dataset used

The dataset used for this task was Kvasir, it is available in Kaggle, if you want to learn more about it then you can check this link.

Important part of the repo

In the function return_model():

def return_model(input_dim, nb_classes, freeze=False, head=None):
    if head == 'xception' or head == 'Xception':
        base_model = Xception(include_top=False, weights='imagenet', input_shape=(input_dim, input_dim, 3))
    
    if head == 'vgg16' or head == 'VGG16':
        base_model = VGG16(include_top=False, weights='imagenet', input_shape=(input_dim, input_dim, 3))
    
    if head == 'inceptionv3' or 'Inceptionv3' or 'InceptionV3':
        base_model = InceptionV3(include_top=False, weights='imagenet', input_shape=(input_dim, input_dim, 3))
    
    if head == 'densenet121':
        base_model = DenseNet121(include_top=False, weights='imagenet', input_shape=(input_dim, input_dim, 3))
    
    if not head:
        print('Please choose the pretrained model')

    print('Chosen model is:', head)

    if freeze:
        for layer in base_model.layers:
            layer.trainable = False


    x = base_model.output
    x = GlobalAveragePooling2D()(x)
    # x = Dense(1024, activation='sigmoid')(x)

    predictions = Dense(nb_classes, activation='softmax')(x)
    model = Model(inputs=base_model.inputs, outputs=predictions)

    return model

The pre-trained model's weights should not be frozen because doing so increases the model's capacity for learning.

Run the inference

I added a script video_classification.py that helps you do the inference in a video using one of your models. And I added also a script predict_options.py that contains multiple inference options such as:

  • Predict one image
  • Predict one array
  • Predict a folder
  • Predict a video
  • Predict from the webcam

A Beginner Guide to Medical Imaging

Join the waitlist for the FREE medical imaging ebook!

This ebook serves as a guide for those who are new to the profession of medical imaging. It provides definitions and resources like where to learn anatomy. Where can you find quality papers? Where can you find good, cost-free datasets? plus more.

🆕 NEW

Learn how to effectively manage and process DICOM files in Python with our comprehensive course, designed to equip you with the skills and knowledge you need to succeed.

https://www.learn.pycad.co/course/dicom-simplified

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages