ihoflaz commited on
Commit
4b43a1b
·
verified ·
1 Parent(s): 94f4d41

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +136 -0
README.md ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ tags:
4
+ - image-classification
5
+ - bacteria
6
+ - medical-imaging
7
+ - resnet
8
+ - pytorch
9
+ - dibas
10
+ datasets:
11
+ - custom
12
+ metrics:
13
+ - accuracy
14
+ - f1
15
+ library_name: timm
16
+ pipeline_tag: image-classification
17
+ ---
18
+
19
+ # ResNet50 for Bacterial Colony Classification
20
+
21
+ This model is a fine-tuned version of **ResNet50** on the [DIBaS (Digital Image of Bacterial Species)](http://misztal.edu.pl/software/databases/dibas/) dataset for classifying bacterial colony images into 33 species.
22
+
23
+ ## Model Description
24
+
25
+ - **Model Architecture:** ResNet50 (pretrained on ImageNet)
26
+ - **Task:** Multi-class image classification (33 bacterial species)
27
+ - **Dataset:** DIBaS - 660+ microscopy images of bacterial colonies
28
+ - **Framework:** PyTorch + timm
29
+
30
+ ## Performance
31
+
32
+ | Metric | Value |
33
+ |--------|-------|
34
+ | **Validation Accuracy** | 93.94% |
35
+ | **Macro F1-Score** | 0.939 |
36
+ | **Parameters** | 23.58M |
37
+ | **Model Size** | 90.2 MB |
38
+ | **GPU Latency** | 4.19 ms (RTX 4070 SUPER) |
39
+ | **CPU Latency** | 44.86 ms |
40
+
41
+ ### Comparison with Other Models
42
+
43
+ | Model | Params (M) | Val Accuracy |
44
+ |-------|------------|--------------|
45
+ | MobileNetV3-Large | 4.24 | **95.45%** |
46
+ | **ResNet50** | 23.58 | 93.94% |
47
+ | EfficientNet-B0 | 4.05 | 91.67% |
48
+
49
+ ## Training Details
50
+
51
+ - **Optimizer:** AdamW (lr=1e-3, weight_decay=1e-4)
52
+ - **Epochs:** 20
53
+ - **Batch Size:** 24
54
+ - **Image Size:** 224×224
55
+ - **Augmentation:** RandomResizedCrop, HorizontalFlip
56
+ - **Hardware:** NVIDIA RTX 4070 SUPER
57
+ - **Mixed Precision:** Enabled (AMP)
58
+ - **Train/Val/Test Split:** 70/20/10 (stratified, seed=42)
59
+
60
+ ## How to Use
61
+
62
+ ```python
63
+ import timm
64
+ import torch
65
+ from PIL import Image
66
+ from torchvision import transforms
67
+
68
+ # Load model
69
+ model = timm.create_model('resnet50', pretrained=False, num_classes=33)
70
+ state_dict = torch.load('pytorch_model.bin', map_location='cpu')
71
+ model.load_state_dict(state_dict)
72
+ model.eval()
73
+
74
+ # Preprocessing
75
+ transform = transforms.Compose([
76
+ transforms.Resize(256),
77
+ transforms.CenterCrop(224),
78
+ transforms.ToTensor(),
79
+ transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
80
+ ])
81
+
82
+ # Inference
83
+ image = Image.open('bacteria_image.jpg').convert('RGB')
84
+ input_tensor = transform(image).unsqueeze(0)
85
+
86
+ with torch.no_grad():
87
+ outputs = model(input_tensor)
88
+ predicted_class = outputs.argmax(dim=1).item()
89
+
90
+ print(f"Predicted class: {CLASS_NAMES[predicted_class]}")
91
+ ```
92
+
93
+ ### Class Labels
94
+
95
+ ```python
96
+ CLASS_NAMES = [
97
+ "Acinetobacter_baumannii", "Actinomyces_israelii", "Bacteroides_fragilis",
98
+ "Bifidobacterium_spp", "Candida_albicans", "Clostridium_perfringens",
99
+ "Enterococcus_faecalis", "Enterococcus_faecium", "Escherichia_coli",
100
+ "Fusobacterium", "Lactobacillus_casei", "Lactobacillus_crispatus",
101
+ "Lactobacillus_delbrueckii", "Lactobacillus_gasseri", "Lactobacillus_jensenii",
102
+ "Lactobacillus_johnsonii", "Lactobacillus_paracasei", "Lactobacillus_plantarum",
103
+ "Lactobacillus_reuteri", "Lactobacillus_rhamnosus", "Lactobacillus_salivarius",
104
+ "Listeria_monocytogenes", "Micrococcus_spp", "Neisseria_gonorrhoeae",
105
+ "Porphyromonas_gingivalis", "Propionibacterium_acnes", "Proteus",
106
+ "Pseudomonas_aeruginosa", "Staphylococcus_aureus", "Staphylococcus_epidermidis",
107
+ "Staphylococcus_saprophyticus", "Streptococcus_agalactiae", "Veillonella"
108
+ ]
109
+ ```
110
+
111
+ ## Limitations
112
+
113
+ - Trained on single laboratory/microscope setup (DIBaS dataset)
114
+ - May not generalize to different imaging conditions
115
+ - Not validated for clinical diagnostic use
116
+
117
+ ## Related Models
118
+
119
+ - [MobileNetV3-Large](https://huggingface.co/ihoflaz/dibas-mobilenet-v3-large) - Best accuracy (95.45%), smaller model
120
+ - [EfficientNet-B0](https://huggingface.co/ihoflaz/dibas-efficientnet-b0) - Lightweight alternative
121
+
122
+ ## Citation
123
+
124
+ ```bibtex
125
+ @inproceedings{hoflaz2025bacterial,
126
+ title={Lightweight CNNs Outperform Vision Transformers for Bacterial Colony Classification},
127
+ author={Hoflaz, Ibrahim},
128
+ booktitle={IEEE Conference},
129
+ year={2025}
130
+ }
131
+ ```
132
+
133
+ ## Resources
134
+
135
+ - **GitHub:** [ihoflaz/bacterial-colony-classification](https://github.com/ihoflaz/bacterial-colony-classification)
136
+ - **DIBaS Dataset:** [http://misztal.edu.pl/software/databases/dibas/](http://misztal.edu.pl/software/databases/dibas/)