NisalPerera/rail-defect-detection-api
0
๐ Rail Track Defect Detection API
This Hugging Face Space provides a FastAPI backend with Gradio interface for detecting defects in railway tracks using YOLOv8.
Features
- FastAPI Endpoints:
POST /detect- Upload image for defect detectionPOST /report- Submit defect reportsGET /health- Health checkGET /- API information
- Gradio Interface: Interactive web interface for testing the model
API Usage
Detect Defects
curl -X POST "https://your-space-name-username.hf.space/detect" \
-H "Content-Type: multipart/form-data" \
-F "file=@your_image.jpg"Health Check
curl -X GET "https://your-space-name-username.hf.space/health"Model
The application uses YOLOv8 for object detection. Place your trained best.pt model file in the repository root, or it will fall back to the default YOLOv8n model for demonstration.
Local Development
- Install dependencies:
pip install -r requirements.txt- Run the application:
python app.py- Access the API at
http://localhost:7860
Integration
This Space can be integrated with mobile applications and web dashboards by making HTTP requests to the API endpoints.
Example response:
{
"defects": [
{
"bbox": {
"x1": 100.0,
"y1": 150.0,
"x2": 200.0,
"y2": 250.0
},
"class": "broken_rail_high",
"confidence": 0.85
}
],
"total_detections": 1,
"status": "success"
}