CoolFace
Apppublic

NisalPerera/rail-defect-detection-api

sourceHugging Facemitupdated 1y agoView on Hugging Face
0likes
App README

๐Ÿš‚ 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 detection
  • โ€”POST /report - Submit defect reports
  • โ€”GET /health - Health check
  • โ€”GET / - API information
  • โ€”Gradio Interface: Interactive web interface for testing the model

API Usage

Detect Defects

bash
curl -X POST "https://your-space-name-username.hf.space/detect" \
     -H "Content-Type: multipart/form-data" \
     -F "file=@your_image.jpg"

Health Check

bash
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

  1. 1.Install dependencies:
bash
pip install -r requirements.txt
  1. 1.Run the application:
bash
python app.py
  1. 1.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:

json
{
  "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"
}