Spaces:
Sleeping
Sleeping
File size: 3,073 Bytes
60965e7 05becdd 60965e7 05becdd | 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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | ---
title: Bus Inspection Classifier
emoji: π
colorFrom: blue
colorTo: green
sdk: gradio
sdk_version: 6.2.0
app_file: app.py
pinned: false
license: mit
---
# π Bus Inspection Classifier - SigLIP v2 ONNX
An automated bus component classification system using the **SigLIP v2** vision model, optimized with ONNX Runtime for fast inference.
## π― Model Details
- **Model**: SigLIP v2 (Sigmoid Loss for Language-Image Pre-training)
- **Format**: ONNX (372.6 MB)
- **Input**: RGB images (224x224)
- **Classes**: 18 bus component categories
- **Inference Time**: ~50-100ms per image (CPU)
## π Supported Classes
The model can classify the following bus components:
1. AC Mat
2. Alco brake camera
3. Alco-brake device
4. Back windshield
5. Bus back side
6. Bus front side
7. Bus side
8. Cabin
9. Driver grooming
10. First aid kit
11. Floormats & POS
12. Front windshield
13. Hat rack
14. ITMS Device
15. Jack & Spare tyre
16. Luggage compartment
17. RFID Card
18. Seats
## π API Usage
### Using the Gradio Client (Recommended)
```python
from gradio_client import Client
# Connect to the Space
client = Client("YOUR-USERNAME/bus-inspection")
# Make a prediction
result = client.predict("path/to/bus_image.jpg")
print(result)
# Output: {
# "class_name": "Bus front side",
# "confidence": "98.45%",
# "inference_time_ms": "87.32"
# }
```
### Using Python Requests
```python
import requests
import json
from PIL import Image
import io
# Your Space URL
API_URL = "https://YOUR-USERNAME-bus-inspection.hf.space/api/predict"
# Load image
with open("bus_image.jpg", "rb") as f:
files = {"data": f}
response = requests.post(API_URL, files=files)
result = response.json()
print(f"Class: {result['class_name']}")
print(f"Confidence: {result['confidence']}")
print(f"Inference Time: {result['inference_time_ms']} ms")
```
### Using cURL
```bash
curl -X POST https://YOUR-USERNAME-bus-inspection.hf.space/api/predict \
-F "data=@bus_image.jpg"
```
## π Response Format
The API returns a JSON object with the following fields:
```json
{
"class_name": "Bus front side",
"confidence": "98.45%",
"inference_time_ms": "87.32"
}
```
- **class_name**: The predicted bus component category
- **confidence**: Model confidence score as a percentage
- **inference_time_ms**: Total inference time in milliseconds
## π Example Use Cases
- **Quality Control**: Automated inspection of bus components during manufacturing
- **Maintenance Checks**: Verify proper installation of safety equipment
- **Documentation**: Automatically categorize bus inspection photos
- **Training**: Help inspectors identify components correctly
## π οΈ Technical Implementation
- **Framework**: Gradio for UI and API
- **Runtime**: ONNX Runtime (CPU optimized)
- **Preprocessing**: SigLIP normalization (mean=0.5, std=0.5)
- **Deployment**: Hugging Face Spaces with Git LFS
## π License
MIT License - Free for commercial and personal use
## π Acknowledgments
Built with SigLIP (Sigmoid Loss for Language-Image Pre-training) from Google Research. |