parthraninga/contextClassifier
By parthraninga · ↓ 0 · ♥ 0 · Updated 2025-07-20
What's in this repo
This page lists the files in parthraninga/contextClassifier, including contextClassifier.onnx.
- 1 ONNX models (.onnx files)
- 2552 files, including 1181 .py, 1179 .pyc, 23 .typed, 23 .exe, 21 .txt, 6 .md
- Last updated 2025-07-20
ONNX files
| File | Size | Download |
|---|---|---|
| contextClassifier.onnx | — | Download |
How to use
These ONNX files can be loaded with ONNX Runtime. To inspect a model graph, upload the file to the Netron viewer. Download links point to the original files on Hugging Face.
README
title: Content Classifier emoji: 🔍 colorFrom: blue colorTo: purple sdk: docker pinned: false license: mit app_port: 7860
Content Classifier API
A FastAPI-based content classification service using an ONNX model for threat detection and sentiment analysis.
Features
- Content threat classification
- Sentiment analysis
- RESTful API with automatic documentation
- Health check endpoints
- Model information endpoints
- Docker support for easy deployment
API Endpoints
POST /predict- Classify text contentGET /- API statusGET /health- Health checkGET /model-info- Model informationGET /docs- Interactive API documentation (Swagger)
Installation
- Install dependencies:
pip install -r requirements.txt
- Run the application:
python app.py
The API will be available at http://localhost:8000
Usage
Example Request
curl -X POST "http://localhost:8000/predict" \
-H "Content-Type: application/json" \
-d '{"text": "This is a sample text to classify"}'
Example Response
{
"is_threat": false,
"final_confidence": 0.75,
"threat_prediction": 0.25,
"sentiment_analysis": {
"label": "POSITIVE",
"score": 0.5
},
"onnx_prediction": {
"threat_probability": 0.25,
"raw_output": [[0.75, 0.25]]
},
"models_used": ["contextClassifier.onnx"],
"raw_predictions": {
"onnx": {
"threat_probability": 0.25,
"raw_output": [[0.75, 0.25]]
},
"sentiment": {
"label": "POSITIVE",
"score": 0.5
}
}
}
Docker Deployment
- Build the Docker image:
docker build -t content-classifier .
- Run the container:
docker run -p 8000:8000 content-classifier
Hugging Face Spaces Deployment
To deploy on Hugging Face Spaces:
- Create a new Space on Hugging Face
- Upload all files to your Space repository
- The Space will automatically build and deploy
Model Requirements
The ONNX model should accept text inputs and return classification predictions. You may need to adjust the preprocessing and postprocessing functions in app.py based on your specific model requirements.
Configuration
You can modify the following in app.py:
MODEL_PATH: Path to your ONNX model filemax_length: Maximum text length for processing- Preprocessing and postprocessing logic based on your model's requirements
Model info
Created: 2025-07-19
Updated: 2025-07-20
View on Hugging FaceFiles (2552)
Related models
More from parthraninga
No other models by this author.
More models
No task type declared.