--- license: cc-by-4.0 language: - en metrics: - accuracy - f1 pipeline_tag: image-classification --- # Model Card for Bacterial Morphology Classification This model classifies bacterial images into three morphological categories: cocci, bacilli, and spirilla. ## Model Details ### Model Description It leverages the MobileNetV2 architecture as a base for feature extraction, followed by custom dense layers for classification. The model was fine-tuned on a dataset of bacterial images with images preprocessed to ensure compatibility. - **Model Developed by:** Taraka Ram Donepudi, University of Michigan-Flint, Graduate Student - **Model Card Author:** Yola Charara, University of Michigan-Flint, M.S Data Science-Student - **Model type:** Image classification (multi-class) - **Language(s) (NLP):** English - **License:** CC BY 4.0 - **Finetuned from model:** MobileNetV2 (pre-trained on ImageNet) ## Uses ### Direct Use This model is suitable for classifying bacterial morphology into three categories based on visual features in microscopy images. It is intended for educational and research purposes. ### Out-of-Scope Use The model is not intended for clinical diagnosis or medical decision-making. Misuse includes applying it to unrelated image classification tasks or using it with non-bacterial images. ## Bias, Risks, and Limitations The model was trained and validated on a specific dataset of bacterial images, which may not represent all possible imaging conditions or bacterial morphologies. It may perform poorly on data outside its training distribution, such as images from different microscopes, lighting conditions, or bacterial species not represented in the dataset. ### Recommendations Users should test the model on other datasets to ensure generalizability and account for variations in bacterial imaging conditions. Misclassification risks should be acknowledged, especially in critical applications. ## How to Get Started with the Model **Here is a sample code snippet to use the model:** * import tensorflow as tf * from tensorflow.keras.utils import load_img, img_to_array * import numpy as np * Load and preprocess an image: * img_path = 'path_to_image.jpg' * img = load_img(img_path, target_size=(224, 224)) * img_array = img_to_array(img) / 255.0 * img_array = np.expand_dims(img_array, axis=0) * Predict with the model: * prediction = model.predict(img_array) * predicted_class = prediction.argmax() * print(f"Predicted class: {predicted_class}") ## Training Details ### Training Data The model was trained on the [BacterialMorphologyClassification Dataset] (https://huggingface.co/datasets/yolac/BacterialMorphologyClassification). The model was trained on a dataset of bacterial images with 360 training samples across three classes: cocci, bacilli, and spirilla. Images were preprocessed by resizing to 224x224 and normalized to pixel values between 0 and 1. ### Training Procedure * Base Model: MobileNetV2 (frozen weights) * Optimizer: Adam (learning rate: 0.0001) * Loss Function: Categorical Crossentropy * Metrics: Accuracy * Regularization: Dropout layer with 50% dropout rate * Early Stopping: Monitored validation loss with a patience of 3 epochs #### Preprocessing All images were resized to 224x224 and normalized by dividing pixel values by 255. Image augmentation was not applied during this training. #### Training Hyperparameters * Epochs: Up to 50 (early stopping applied) * Batch size: 32 * Dropout: 0.5 on dense layers ## Evaluation ### Testing Data, Factors & Metrics #### Testing Data The test dataset included unseen images with filenames provided in a separate file. Images were resized and normalized in the same way as training and validation data. #### Metrics * Accuracy * F1 Score ### Results The model achieved 0.85 accuracy and F1 score on the Codalab test set. Codalab leaderboard: https://codalab.lisn.upsaclay.fr/competitions/20680?secret_key=b04da988-294a-4491-831c-3f4b55529a0b #### Summary This bacterial morphology classification model effectively categorizes images into three classes: cocci, bacilli, and spirilla. Leveraging the MobileNetV2 architecture, the model achieves high performance with an accuracy and F1 score of 0.85 on the Codalab test set. It is efficient for educational and research purposes, though not suitable for diagnostic applications without further validation. ### Model Architecture and Objective The model uses the MobileNetV2 architecture with the top layers replaced for the classification task. The objective is to minimize categorical crossentropy loss for three classes. ## Model Card Contact email: yolac@umich.edu