Spaces:
Sleeping
Sleeping
| # app.py | |
| import joblib | |
| import gradio as gr | |
| # load model | |
| model = joblib.load("cat_model.joblib") | |
| def predict_category(text: str): | |
| # returns predicted label (string) | |
| pred = model.predict([text])[0] | |
| return {"label": pred} | |
| # gradio interface (textbox -> JSON) | |
| iface = gr.Interface( | |
| fn=predict_category, | |
| inputs=gr.Textbox(lines=3, placeholder="Paste complaint here..."), | |
| outputs=gr.JSON(), | |
| title="Civic Complaint Categorizer", | |
| description="Predict department/category for civic complaints" | |
| ) | |
| if __name__ == "__main__": | |
| iface.launch(server_name="0.0.0.0", server_port=7860) | |