Amii2410 commited on
Commit
963e978
·
verified ·
1 Parent(s): fe5f65a

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+ import joblib
3
+ import gradio as gr
4
+
5
+ # load model
6
+ model = joblib.load("cat_model.joblib")
7
+
8
+ def predict_category(text: str):
9
+ # returns predicted label (string)
10
+ pred = model.predict([text])[0]
11
+ return {"label": pred}
12
+
13
+ # gradio interface (textbox -> JSON)
14
+ iface = gr.Interface(
15
+ fn=predict_category,
16
+ inputs=gr.Textbox(lines=3, placeholder="Paste complaint here..."),
17
+ outputs=gr.JSON(),
18
+ title="Civic Complaint Categorizer",
19
+ description="Predict department/category for civic complaints"
20
+ )
21
+
22
+ if __name__ == "__main__":
23
+ iface.launch(server_name="0.0.0.0", server_port=7860)