File size: 2,165 Bytes
85d22aa
 
5cc7f8f
85d22aa
 
 
 
 
 
 
 
 
5cc7f8f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
title: PIPECOUNTv2
emoji: 🎯
colorFrom: blue
colorTo: yellow
sdk: gradio
sdk_version: 5.47.2
app_file: app.py
pinned: false
license: mit
---

# PVC Pipe Counter

PVC pipe counting web application powered by a custom Ultralytics ONNX model. The interface mirrors the CountThings workflow with guided settings, annotated visual QA, and export-friendly results, ready for deployment on Hugging Face Spaces.

## Key Features
- 🧠 **ONNX-powered detection** – wraps `model/best.onnx` with ONNX Runtime for fast CPU inference.
- 🎯 **CountThings-inspired UX** – upload, tune thresholds, and view highlighted detections with running totals.
- πŸ“Š **Structured output** – per-pipe coordinate table for downstream auditing or exporting.
- ☁️ **Space-ready** – Gradio front end with requirements and configuration for automatic builds.

## Project Structure
```
.
β”œβ”€β”€ app.py                 # Gradio Blocks UI and event wiring
β”œβ”€β”€ pipe_counter/          # Inference helpers
β”‚   β”œβ”€β”€ __init__.py
β”‚   └── inference.py       # Letterbox preprocessing, ONNX Runtime session, post-processing
β”œβ”€β”€ model/
β”‚   └── best.onnx          # Trained Ultralytics YOLO model (single PVC class)
β”œβ”€β”€ requirements.txt       # Runtime dependencies for Spaces / local use
β”œβ”€β”€ huggingface.yaml       # Hugging Face Space metadata (Gradio SDK)
└── README.md
```

## Local Development
1. Create and activate a Python 3.10 environment.
2. Install dependencies:
   ```bash
   pip install -r requirements.txt
   ```
3. Run the app locally:
   ```bash
   python app.py
   ```
   Gradio launches a local server and prints the URL for testing.

## Deployment Notes
- Upload or push all repository contents (including `model/best.onnx`) to the Space; `.gitattributes` is already configured for Git LFS so large models sync correctly.
- The ONNX metadata indicates Ultralytics YOLO v8 (`stride=32`, `imgsz=640`). Adjust the confidence/IoU sliders in the UI to suit different camera angles or lighting conditions.
- For markedly different bundle layouts, fine-tune the model and replace `model/best.onnx` with the new weights.