Spaces:
Running
A newer version of the Streamlit SDK is available:
1.52.2
title: Tunnel Crack Detection
emoji: π
colorFrom: blue
colorTo: red
sdk: streamlit
sdk_version: 1.28.0
app_file: app.py
pinned: false
license: agpl-3.0
π Tunnel Crack Detection
A state-of-the-art web application for detecting cracks and defects in tunnel infrastructure using YOLOv12-DINO deep learning model. Deployed on Hugging Face Spaces for easy access and sharing.
Features
- π Real-time crack detection using YOLOv12-DINO
- πΌοΈ Interactive web interface built with Streamlit
- π Detailed analysis with charts and detection tables
- π Large file support (up to 5GB model weights)
- π Detection history and results export
- π― Configurable parameters (confidence, IoU thresholds)
π Quick Start
This application is deployed on Hugging Face Spaces. Simply:
- Upload your YOLOv12-DINO model weights (.pt file) using the sidebar
- Upload a tunnel image for analysis
- Click "Analyze for Cracks" to get instant results!
π οΈ Local Setup
Prerequisites
- Python 3.8 or higher
- YOLOv12-DINO trained model weights (.pt file)
Installation
Clone or navigate to the project directory:
cd /Users/sompoteyouwai/env/deploy_tunnel_crackCreate a virtual environment (recommended):
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activateInstall dependencies:
pip install -r requirements.txt
Running the Application
Start the Streamlit app:
streamlit run streamlit_app.pyOpen your browser and navigate to
http://localhost:8501Load the model:
- If the default model exists at
/Users/sompoteyouwai/env/model_weight/segment_defect.pt, click "Load Default Model" - Alternatively, upload your own model weights (.pt file)
- If the default model exists at
Upload an image and click "Detect Cracks" to analyze
Usage
Model Loading
- Default Model: The app automatically detects if the default model is available
- Custom Model: Upload your own YOLOv12-DINO trained weights
- Device Selection: Choose between CPU, CUDA (GPU), or MPS (Apple Silicon)
Detection Parameters
- Confidence Threshold: Minimum confidence score for detections (0.01-1.0)
- IoU Threshold: Intersection over Union threshold for Non-Maximum Suppression (0.01-1.0)
- Image Size: Input resolution for the model (320-1280 pixels)
Results
- Annotated Images: View detected cracks with bounding boxes
- Detection Summary: Count and classification of detected defects
- Interactive Charts: Pie charts and confidence distributions
- Detailed Table: Exportable CSV with detection coordinates and metadata
- History: Track multiple detection sessions
File Structure
deploy_tunnel_crack/
βββ streamlit_app.py # Main Streamlit application
βββ inference.py # YOLOv12-DINO inference engine
βββ requirements.txt # Python dependencies
βββ README.md # This file
βββ run.sh # Quick start script
Model Information
The application expects a YOLOv12-DINO model trained for crack/defect detection. The default model path is:
/Users/sompoteyouwai/env/model_weight/segment_defect.pt
Supported Model Features:
- Object detection and segmentation
- Multiple defect classes
- Configurable inference parameters
- GPU acceleration support
Troubleshooting
Common Issues:
- Model not found: Ensure the model file exists at the specified path or upload a custom model
- CUDA errors: Install appropriate PyTorch version for your GPU
- Memory issues: Reduce image size or use CPU device for large images
- Import errors: Ensure all dependencies are installed:
pip install -r requirements.txt
Performance Tips:
- Use GPU (CUDA/MPS) for faster inference
- Optimize image size based on your hardware capabilities
- Adjust confidence threshold to filter false positives
Development
To modify or extend the application:
- Streamlit App: Edit
streamlit_app.pyfor UI changes - Inference Engine: Modify
inference.pyfor model-related changes - Dependencies: Update
requirements.txtfor new packages
License
This project is for tunnel infrastructure monitoring and maintenance applications.