Tevfik istanbullu commited on
Commit
de2c551
1 Parent(s): ed3bdd4

Upload 4 files

Browse files
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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)
arabic_text_classifier.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0da3d2df4b2ae20905c1338418c6b259ba00d7e06e8972fe19c2fa5c6cb68e03
3
+ size 38329167
label_encoder.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8fef4330d855f86185760e1a1a161644f270de3f0aec51fbd4a5cdb188b9ffbc
3
+ size 614
tfidf_vectorizer.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:19e5cb9af2cdad61789ecc1c8971412086eec11cce9cb910158234daa68f951e
3
+ size 19655535