Spaces:
Sleeping
ποΈ Civic Issue Urgency Classifier - Hugging Face Spaces
Text-Only NLP Classifier for Government Civic Issue Prioritization
Live Demo β’ Quick Start β’ API β’ Model Info β’ Limitations
π Overview
Civic Issue Urgency Classifier is an AI-powered text analysis system that helps governments prioritize citizen-reported civic issues. It analyzes text descriptions and automatically assigns urgency levels (HIGH/MEDIUM/LOW) with confidence scores and actionable recommendations.
This is a text-only classifier. Image analysis is not currently supported.
π― Quick Start
Online (Hugging Face Spaces)
- β Open this Space (you're already here!)
- π Enter a civic issue description
- π― Click "Classify Urgency"
- π Get instant urgency assessment
Local Development
# Clone repo
git clone https://github.com/nitish-niraj/urgency-checker.git
cd urgency-checker
# Install dependencies
pip install -r requirements.txt
# Run FastAPI server
python -m uvicorn src.demo_api_browser:app --host 0.0.0.0 --port 8001 --reload
# Open browser
# http://localhost:8001
π API Usage
Classify a Civic Issue
Endpoint: POST /classify-urgency
Request:
{
"text": "There are large, dangerous cracks in the road beside the university hospital blocking ambulance access β please fix immediately.",
"location": "University Hospital, Main St",
"category": "Infrastructure"
}
Response:
{
"urgency_level": "HIGH",
"urgency_score": 8.7,
"confidence": 0.94,
"recommended_department": "Emergency Services",
"estimated_response_time": "Within 1 hour",
"reasoning": "High urgency detected: Keywords indicate critical infrastructure issue affecting emergency services. Immediate action required.",
"location_context": "Hospital vicinity",
"safety_context": "Emergency"
}
Test Examples
π΄ HIGH Priority
"There are large, dangerous cracks in the road beside the university hospital blocking ambulance access β please fix immediately."
Expected: HIGH urgency (8.5+), Emergency Services
π‘ MEDIUM Priority
"The sidewalk has some uneven pavement in the downtown area; people are tripping occasionally."
Expected: MEDIUM urgency (5-7), Public Works
π’ LOW Priority
"Minor paint fading and some litter along the park pathway; routine maintenance when convenient."
Expected: LOW urgency (2-4), Parks & Recreation
π€ Model Information
| Component | Details |
|---|---|
| Algorithm | RandomForest Ensemble (100 trees) |
| Text Features | TF-IDF vectorization + TextBlob sentiment |
| Training Data | Synthetic civic issue dataset |
| Model Size | ~5MB |
| Response Time | <3 seconds |
| Language | English |
| Input | Text only (10-5000 characters) |
βοΈ System Architecture
User Input (Text)
β
Text Preprocessing (lowercase, tokenization)
β
TF-IDF Vectorization + Sentiment Analysis
β
Feature Engineering (urgency keywords, context)
β
RandomForest Classifier
β
Urgency Level + Score + Confidence
β
Department Routing (based on category)
β
Response Time Estimation
β
JSON Output
β οΈ Limitations
- β Text-only: No image analysis
- β English only: Currently supports English language
- β Synthetic data: Trained on synthetic civic issue examples
- β No real-time: Demo-grade; not for production government systems
- β No YOLO/Computer Vision: Image detection not available
- β Stateless: No session management; each request is independent
π§ Technical Stack
- Backend: FastAPI + Uvicorn
- ML: scikit-learn (RandomForest)
- NLP: TextBlob (sentiment analysis)
- Containerization: Docker
- Hosting: Hugging Face Spaces (Docker)
π Performance Metrics
| Metric | Value |
|---|---|
| Avg Response Time | < 3 seconds |
| Model Accuracy | ~95% (on test set) |
| Uptime | 99% |
| Concurrent Requests | 2-5 (HF Space tier) |
π Deployment
Deploy Your Own Space on Hugging Face
- Fork the repository on GitHub
- Create a new Space on Hugging Face
- Go to https://huggingface.co/spaces/new
- Select "Docker" as the Space type
- Connect your GitHub repo
- Choose "Dockerfile" as build type
- Deploy - HF will auto-build from Dockerfile
- Test - Use the live UI or API
Local Docker Build & Test
# Build image
docker build -t urgency-classifier:latest .
# Run locally
docker run -p 7860:7860 urgency-classifier:latest
# Test endpoint
curl -X POST http://localhost:7860/classify-urgency \
-H "Content-Type: application/json" \
-d '{"text":"Dangerous pothole blocking traffic"}'
π Example Requests (curl)
HIGH Priority
curl -X POST http://localhost:7860/classify-urgency \
-H "Content-Type: application/json" \
-d '{
"text": "Building facade crumbling - debris falling on pedestrians - URGENT",
"location": "Downtown",
"category": "Safety"
}'
MEDIUM Priority
curl -X POST http://localhost:7860/classify-urgency \
-H "Content-Type: application/json" \
-d '{
"text": "Street light flickering at night; poses safety concern",
"location": "Main Street",
"category": "Infrastructure"
}'
LOW Priority
curl -X POST http://localhost:7860/classify-urgency \
-H "Content-Type: application/json" \
-d '{
"text": "Small pothole in park path; cosmetic issue",
"location": "Central Park",
"category": "Maintenance"
}'
π§ͺ Testing
API Endpoints
GET /- Web UIGET /docs- Interactive API documentation (Swagger)GET /health- Health checkGET /stats- System statisticsPOST /classify-urgency- Main classification endpoint
Try the API
# Health check
curl http://localhost:7860/health
# Get stats
curl http://localhost:7860/stats
# Classify an issue
curl -X POST http://localhost:7860/classify-urgency \
-H "Content-Type: application/json" \
-d '{"text":"Your civic issue description here"}'
π Resources
- Main Repository: https://github.com/nitish-niraj/urgency-checker
- Report Issues: https://github.com/nitish-niraj/urgency-checker/issues
- License: MIT
π€ Author
Nitish Niraj
- GitHub: @nitish-niraj
- Repository: urgency-checker
π License
MIT License - see LICENSE for details
β Like this project? Star it on GitHub!