lederyou commited on
Commit
3dab422
Β·
verified Β·
1 Parent(s): b0346ab

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +68 -0
README.md ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - image-classification
4
+ - bacteria
5
+ - microscopy
6
+ - transfer-learning
7
+ - efficientnet
8
+ library_name: timm
9
+ datasets:
10
+ - custom
11
+ pipeline_tag: image-classification
12
+ ---
13
+
14
+ # Bacteria Image Classifier (EfficientNet-B0)
15
+
16
+ A fine-tuned EfficientNet-B0 model for classifying microscopy images of bacteria
17
+ and fungi into 20 classes (10 organisms Γ— 2 imaging types: gram stain and media plate).
18
+
19
+ ## Classes
20
+
21
+ The model distinguishes between the following 20 classes:
22
+
23
+ | Organism | Gram Stain | Media Plate |
24
+ |----------|-----------|-------------|
25
+ | Aspergillus niger | βœ“ | βœ“ |
26
+ | Bacillus subtilis | βœ“ | βœ“ |
27
+ | Candida albicans | βœ“ | βœ“ |
28
+ | Clostridium sporogenes | βœ“ | βœ“ |
29
+ | Enterococcus faecalis | βœ“ | βœ“ |
30
+ | Escherichia coli | βœ“ | βœ“ |
31
+ | Klebsiella pneumoniae | βœ“ | βœ“ |
32
+ | Pseudomonas aeruginosa | βœ“ | βœ“ |
33
+ | Staphylococcus aureus | βœ“ | βœ“ |
34
+ | Streptococcus pyogenes | βœ“ | βœ“ |
35
+
36
+ ## Usage
37
+
38
+ ```python
39
+ import timm, torch, json
40
+ from torchvision import transforms
41
+ from PIL import Image
42
+ from huggingface_hub import hf_hub_download
43
+
44
+ repo_id = "lederyou/bacteria-classifier"
45
+ model_path = hf_hub_download(repo_id, "model.pth")
46
+ class_names = json.load(open(hf_hub_download(repo_id, "class_names.json")))
47
+
48
+ model = timm.create_model("efficientnet_b0", pretrained=False, num_classes=20)
49
+ model.load_state_dict(torch.load(model_path, map_location="cpu"))
50
+ model.eval()
51
+
52
+ transform = transforms.Compose([
53
+ transforms.Resize((224, 224)),
54
+ transforms.ToTensor(),
55
+ transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
56
+ ])
57
+
58
+ img = transform(Image.open("your_image.png").convert("RGB")).unsqueeze(0)
59
+ with torch.no_grad():
60
+ pred = model(img).argmax(1).item()
61
+ print(class_names[pred])
62
+ ```
63
+
64
+ ## Training
65
+
66
+ - **Base model**: EfficientNet-B0 (pretrained on ImageNet)
67
+ - **Method**: Two-phase transfer learning (frozen backbone β†’ full fine-tuning)
68
+ - **Dataset**: 629 images, 20 classes, 70/15/15 train/val/test split