pipecountapp-dev / README.md
Khunndev
Cursor
Deploy offline-first PWA with in-browser ONNX inference
0e0cc3e
|
Raw History Blame Contribute Delete
2.12 kB
metadata
title: Pipe Count Dev
emoji: πŸ”§
colorFrom: blue
colorTo: green
sdk: docker
app_port: 7860
pinned: false

Pipe Counting PWA (Offline-First)

Modern offline-first PWA for counting pipes with in-browser ONNX inference, diameter clustering, and interactive correction.

Features

  • Offline inference β€” YOLOv5 model runs in the browser via ONNX Runtime Web (WebGPU / WASM)
  • Multi-diameter sorting β€” clusters pipes by bounding-box size (no retraining)
  • Interactive correction β€” add, delete, re-tag, and area-select pipes
  • Expected vs counted QA β€” optional per-group expected quantity
  • Export β€” annotated PNG, JSON, CSV (client-side)
  • Bilingual β€” Thai / English UI
  • Fast deploy β€” tiny Docker image (no PyTorch at runtime)

Architecture

Browser PWA  β†’  ONNX Runtime Web  β†’  YOLOv5 countmodel.onnx
     ↓
Diameter clustering + user corrections + export
     ↑
HF Space serves static files only (main.py)

Local development

Frontend only

cd frontend
npm install
npm run dev

Full stack (built PWA + API)

cd frontend && npm run build
# copy dist + models to static/
cd ..
pip install -r requirements-server.txt
uvicorn main:app --host 0.0.0.0 --port 7860

Export ONNX model (one-time / CI)

pip install -r requirements-export.txt
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
git clone --depth 1 https://github.com/ultralytics/yolov5.git
python scripts/export_onnx.py

API Endpoints

Endpoint Method Description
/ GET PWA shell
/health GET Health check

Hugging Face Spaces

  • SDK: Docker
  • Port: 7860
  • Hardware: Free CPU is sufficient (inference runs on client devices)
  • Build uses multi-stage Dockerfile: export ONNX β†’ build PWA β†’ serve static

Configuration

Variable Default Description
(none required) β€” Inference is client-side

Legacy server inference endpoints (/detectImage, /detect/json) were removed in v1.0.0.