Spaces:
Sleeping
Sleeping
| 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. |