Spaces:
Sleeping
Sleeping
File size: 608 Bytes
963e978 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# 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)
|