File size: 2,850 Bytes
e9a9023
 
 
 
 
 
4ace498
e9a9023
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4ace498
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
---
title: Bacteria Detection System
emoji: 🦠
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 5.49.1
app_file: app.py
pinned: false
license: mit
short_description: Classifies bacteria images into Gram+/- cocci and bacilli wi
---

# 🦠 Bacteria Detection System

A deep learning application for detecting and classifying bacteria in microscope images using YOLOv8.

## 🎯 Overview

This application automatically detects and classifies bacteria based on:

- **Gram staining:** Gram-positive (G+) vs Gram-negative (G-)
- **Shape:** Cocci (spherical) vs Bacilli (rod-shaped)

## 🔬 Features

- **Real-time Detection:** Upload microscope images and get instant results
- **4 Classes:**
  - G- Cocci (Gram-negative cocci)
  - G+ Cocci (Gram-positive cocci)
  - G- Bacilli (Gram-negative bacilli)
  - G+ Bacilli (Gram-positive bacilli)
- **Visual Results:** Color-coded bounding boxes with confidence scores
- **Detailed Statistics:** Class distribution and detection counts

## 🚀 How to Use

1. **Upload Image:** Click the upload area or drag & drop a microscope image
2. **Detect:** Click the "🔬 Detect Bacteria" button
3. **View Results:** See detected bacteria with bounding boxes and classification

## 🧬 Model Details

- **Architecture:** YOLOv8 Nano
- **Training Dataset:** Clinical Bacteria Detection Dataset (6,005 images)
- **Performance:**
  - Precision: ~87%
  - Recall: ~82%
  - mAP50: ~87%
  - mAP50-95: ~64%
- **Confidence Threshold:** 25%
- **IoU Threshold:** 45%

## 📊 Classes

| Class      | Description           | Gram Stain             | Shape      |
| ---------- | --------------------- | ---------------------- | ---------- |
| G- Cocci   | Gram-negative cocci   | Negative (Pink/Red)    | Spherical  |
| G+ Cocci   | Gram-positive cocci   | Positive (Purple/Blue) | Spherical  |
| G- Bacilli | Gram-negative bacilli | Negative (Pink/Red)    | Rod-shaped |
| G+ Bacilli | Gram-positive bacilli | Positive (Purple/Blue) | Rod-shaped |

## 🛠️ Technology Stack

- **Model:** YOLOv8 (Ultralytics)
- **Framework:** Gradio
- **Backend:** PyTorch
- **Image Processing:** OpenCV

## 📖 Clinical Relevance

Gram staining and bacterial shape identification are crucial for:

- Initial antibiotic selection
- Infection diagnosis
- Treatment planning
- Laboratory screening

**Note:** This is a research tool and should not replace professional medical diagnosis.

## 🔗 Links

- [Dataset Paper](https://www.nature.com/articles/s41597-024-03370-5)
- [YOLOv8 Documentation](https://docs.ultralytics.com/)
- [Gradio Documentation](https://gradio.app/)

## 📝 License

MIT License

## 🙏 Acknowledgments

- Dataset: Clinical Bacteria Detection Dataset (Nature Scientific Data)
- Model: YOLOv8 by Ultralytics
- Interface: Gradio by Hugging Face

---

**Made with ❤️ for medical research and education**