Tevfik istanbullu commited on
Commit
7a733a2
·
verified ·
1 Parent(s): 7fdacf0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -38
app.py CHANGED
@@ -1,41 +1,3 @@
1
- import gradio as gr
2
- import joblib
3
-
4
- model = joblib.load('arabic_text_classifier.pkl')
5
- vectorizer = joblib.load('tfidf_vectorizer.pkl')
6
- label_encoder = joblib.load('label_encoder.pkl')
7
-
8
- def predict_category(text):
9
- text_vector = vectorizer.transform([text])
10
- probabilities = model.predict_proba(text_vector)[0]
11
- max_prob = max(probabilities)
12
- predicted_category = model.predict(text_vector)[0]
13
-
14
-
15
- if max_prob < 0.5:
16
- return "Other"
17
-
18
-
19
- predicted_label = label_encoder.inverse_transform([predicted_category])[0]
20
- return predicted_label
21
-
22
-
23
- iface = gr.Interface(
24
- fn=predict_category,
25
- inputs=gr.Textbox(
26
- lines=5,
27
- placeholder="Enter text in Arabic here...",
28
- label="Text"
29
- ),
30
- outputs=gr.Label(label="Predicted Category"),
31
- title="Arabic Text Classification",
32
- description="Enter an Arabic text to get its classification based on the trained model.",
33
- )
34
-
35
-
36
- iface.launch(share=True)
37
-
38
-
39
  import gradio as gr
40
  import joblib
41
  import os
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
  import joblib
3
  import os