Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
tags:
|
| 6 |
+
- yolo
|
| 7 |
+
- anomaly-detection
|
| 8 |
+
- industrial-inspection
|
| 9 |
+
- valve-well
|
| 10 |
+
- computer-vision
|
| 11 |
+
- object-detection
|
| 12 |
+
library_name: ultralytics
|
| 13 |
+
pipeline_tag: object-detection
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
# Anomaly Detection YOLOv8s — Underground Gas Valve Well Inspection
|
| 17 |
+
|
| 18 |
+
## Overview
|
| 19 |
+
|
| 20 |
+
A YOLOv8s-based object detection model for identifying and localizing anomalies in underground gas valve well inspection photos. This model is trained on VLM-annotated real-world inspection images and detects 6 types of anomalies commonly found in valve wells.
|
| 21 |
+
|
| 22 |
+
## Model Performance
|
| 23 |
+
|
| 24 |
+
| Metric | Value |
|
| 25 |
+
|--------|-------|
|
| 26 |
+
| **mAP50** | 0.312 |
|
| 27 |
+
| **mAP50-95** | 0.194 |
|
| 28 |
+
| **Precision** | 0.624 |
|
| 29 |
+
| **Recall** | 0.306 |
|
| 30 |
+
| **Model Size** | 22.5 MB (PyTorch) / 44.7 MB (ONNX) |
|
| 31 |
+
| **Parameters** | 11.1M |
|
| 32 |
+
| **GFLOPs** | 28.4 |
|
| 33 |
+
|
| 34 |
+
## Anomaly Classes
|
| 35 |
+
|
| 36 |
+
| ID | Class | mAP50 | Recall | Description |
|
| 37 |
+
|----|-------|-------|--------|-------------|
|
| 38 |
+
| 0 | water_accumulation | 0.577 | 0.704 | Standing water on the floor |
|
| 39 |
+
| 1 | water_seepage | 0.140 | 0.115 | Water traces/seepage on walls |
|
| 40 |
+
| 2 | corrosion_rust | 0.223 | 0.059 | Rust on metal parts |
|
| 41 |
+
| 3 | coating_damage | 0.007 | 0.000 | Peeling or damaged coating |
|
| 42 |
+
| 4 | wall_crack | 0.650 | 0.600 | Cracks in walls or structure |
|
| 43 |
+
| 5 | fog_condensation | 0.202 | 0.200 | Fog or condensation on lens |
|
| 44 |
+
|
| 45 |
+
## Training Details
|
| 46 |
+
|
| 47 |
+
- **Base Model**: YOLOv8s (pretrained on COCO)
|
| 48 |
+
- **Dataset**: 213 VLM-annotated images (173 train / 40 val)
|
| 49 |
+
- **Annotations**: 505 bounding boxes across 6 anomaly classes
|
| 50 |
+
- **Image Size**: 640×640
|
| 51 |
+
- **Batch Size**: 8
|
| 52 |
+
- **Optimizer**: AdamW (lr=0.001, momentum=0.9)
|
| 53 |
+
- **Epochs**: 64 (early stopped, patience=30)
|
| 54 |
+
- **Best Epoch**: 33
|
| 55 |
+
- **Device**: Apple M4 (MPS)
|
| 56 |
+
- **Augmentation**: Mosaic, MixUp, HSV, rotation, flip, copy-paste, random erasing
|
| 57 |
+
|
| 58 |
+
## Dataset
|
| 59 |
+
|
| 60 |
+
The training data consists of real underground gas valve well inspection photos collected from 701 inspection sites across Guangdong, Shaanxi, and Xinjiang provinces in China. Images are 2592×1944 resolution JPG files.
|
| 61 |
+
|
| 62 |
+
Annotations were generated using a Vision-Language Model (VLM) with expert review, providing precise bounding boxes for each anomaly type.
|
| 63 |
+
|
| 64 |
+
## Usage
|
| 65 |
+
|
| 66 |
+
### Python (PyTorch)
|
| 67 |
+
|
| 68 |
+
```python
|
| 69 |
+
from ultralytics import YOLO
|
| 70 |
+
|
| 71 |
+
# Load model
|
| 72 |
+
model = YOLO("best.pt")
|
| 73 |
+
|
| 74 |
+
# Run inference
|
| 75 |
+
results = model("your_image.jpg")
|
| 76 |
+
|
| 77 |
+
# Show results
|
| 78 |
+
for r in results:
|
| 79 |
+
r.show()
|
| 80 |
+
print(r.boxes)
|
| 81 |
+
```
|
| 82 |
+
|
| 83 |
+
### ONNX
|
| 84 |
+
|
| 85 |
+
```python
|
| 86 |
+
import onnxruntime as ort
|
| 87 |
+
import numpy as np
|
| 88 |
+
from PIL import Image
|
| 89 |
+
|
| 90 |
+
session = ort.InferenceSession("best.onnx")
|
| 91 |
+
image = Image.open("your_image.jpg").resize((640, 640))
|
| 92 |
+
input_tensor = np.array(image).transpose(2, 0, 1).astype(np.float32) / 255.0
|
| 93 |
+
input_tensor = input_tensor[np.newaxis]
|
| 94 |
+
|
| 95 |
+
outputs = session.run(None, {"images": input_tensor})
|
| 96 |
+
```
|
| 97 |
+
|
| 98 |
+
## Complete Pipeline
|
| 99 |
+
|
| 100 |
+
This model is part of a complete valve well inspection pipeline:
|
| 101 |
+
|
| 102 |
+
1. **Valve Detection** ([lg227210/valve-detection-yolov8s](https://huggingface.co/lg227210/valve-detection-yolov8s)) — mAP50=92.95%, 4 valve types
|
| 103 |
+
2. **Anomaly Classification** — EfficientNet-B0, 74.0% accuracy, 6 anomaly types + severity
|
| 104 |
+
3. **Anomaly Detection** (this model) — YOLOv8s, localizes anomalies with bounding boxes
|
| 105 |
+
|
| 106 |
+
## License
|
| 107 |
+
|
| 108 |
+
MIT License — Free for research and commercial use.
|
| 109 |
+
|
| 110 |
+
## Citation
|
| 111 |
+
|
| 112 |
+
```bibtex
|
| 113 |
+
@misc{anomaly_detection_yolov8s,
|
| 114 |
+
title={Anomaly Detection YOLOv8s for Underground Gas Valve Well Inspection},
|
| 115 |
+
author={ValveAI},
|
| 116 |
+
year={2026},
|
| 117 |
+
url={https://huggingface.co/lg227210/anomaly-detection-yolov8s}
|
| 118 |
+
}
|
| 119 |
+
```
|