Spaces:
Build error
Build error
Tevfik istanbullu
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,7 +9,7 @@ login(token, add_to_git_credential=True,write_permission=True )
|
|
| 9 |
model = joblib.load('arabic_text_classifier.pkl')
|
| 10 |
vectorizer = joblib.load('tfidf_vectorizer.pkl')
|
| 11 |
label_encoder = joblib.load('label_encoder.pkl')
|
| 12 |
-
|
| 13 |
def predict_category(text):
|
| 14 |
text_vector = vectorizer.transform([text])
|
| 15 |
probabilities = model.predict_proba(text_vector)[0]
|
|
@@ -43,7 +43,27 @@ def classify_and_flag(text):
|
|
| 43 |
return prediction
|
| 44 |
|
| 45 |
|
| 46 |
-
interface = gr.Interface(fn=classify_and_flag,
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
interface.launch()
|
|
|
|
| 9 |
model = joblib.load('arabic_text_classifier.pkl')
|
| 10 |
vectorizer = joblib.load('tfidf_vectorizer.pkl')
|
| 11 |
label_encoder = joblib.load('label_encoder.pkl')
|
| 12 |
+
available_labels = label_encoder.classes_
|
| 13 |
def predict_category(text):
|
| 14 |
text_vector = vectorizer.transform([text])
|
| 15 |
probabilities = model.predict_proba(text_vector)[0]
|
|
|
|
| 43 |
return prediction
|
| 44 |
|
| 45 |
|
| 46 |
+
interface = gr.Interface(fn=classify_and_flag,
|
| 47 |
+
inputs=gr.Textbox(lines=5, placeholder= "Enter text in Arabic here...", label="Text" ),
|
| 48 |
+
outputs=gr.Label(label="Predicted Category"),
|
| 49 |
+
title="Arabic Text Classifier",
|
| 50 |
+
description="""
|
| 51 |
+
This interface allows you to classify Arabic text into different categories using a machine learning model trained on 190,000 real-world text samples.
|
| 52 |
+
|
| 53 |
+
**Model Overview**:
|
| 54 |
+
- The model is based on **Logistic Regression**, a simple but effective machine learning algorithm often used for text classification tasks.
|
| 55 |
+
- It was trained on a large dataset of **190,000 Arabic text entries**, ensuring robustness and accuracy in classifying Arabic text.
|
| 56 |
+
|
| 57 |
+
**How to use**:
|
| 58 |
+
- Enter any Arabic text in the input box or select one of the provided examples.
|
| 59 |
+
- The model will predict the category that the text most likely belongs to.
|
| 60 |
+
- If the model is uncertain, it will classify the text as 'Other'.
|
| 61 |
+
|
| 62 |
+
**Available Labels**:
|
| 63 |
+
The model can predict the following categories:
|
| 64 |
+
- {}
|
| 65 |
+
|
| 66 |
+
Try entering some text in Arabic or select one of the provided examples to see how the model works.
|
| 67 |
+
""".format(", ".join(available_labels)),theme="ParityError/Interstellar")
|
| 68 |
|
| 69 |
interface.launch()
|