Spaces:
Runtime error
Runtime error
Commit ·
3523c5d
1
Parent(s): bd074e8
Update details
Browse files- apps/classifier.py +15 -14
- apps/mlm.py +6 -4
apps/classifier.py
CHANGED
|
@@ -18,27 +18,28 @@ def load_model(input_text, model_name_or_path):
|
|
| 18 |
|
| 19 |
|
| 20 |
def app():
|
| 21 |
-
st.title("Marathi News Classifier")
|
| 22 |
|
| 23 |
st.markdown(
|
| 24 |
"This demo uses the below fine-tuned models for marathi news classification:\n"
|
| 25 |
"- [IndicNLP Marathi News Classifier](https://huggingface.co/flax-community/mr-indicnlp-classifier) fine-tuned on "
|
| 26 |
-
"[IndicNLP Marathi News Dataset](https://github.com/ai4bharat/indicnlp_corpus#indicnlp-news-article-classification-dataset)"
|
| 27 |
-
"
|
|
|
|
| 28 |
"- [iNLTK Marathi News Classifier](https://huggingface.co/flax-community/mr-inltk-classifier) fine-tuned on "
|
| 29 |
-
"[Marathi News Dataset](https://www.kaggle.com/disisbig/marathi-news-dataset)"
|
|
|
|
| 30 |
)
|
| 31 |
|
| 32 |
-
st.markdown("`IndicNLP Marathi News Dataset` consists of 3 classes - `['lifestyle', 'entertainment', 'sports']`")
|
| 33 |
-
st.markdown("`iNLTK Marathi News Dataset` consists of 3 classes - `['state', 'entertainment', 'sports']`")
|
| 34 |
-
|
| 35 |
st.markdown(
|
| 36 |
-
"Can't figure out where to get a sample text other than the predefined ones?
|
| 37 |
-
"
|
|
|
|
| 38 |
"- [entertainment](https://maharashtratimes.com/entertainment/articlelist/19359255.cms)\n"
|
| 39 |
"- [sports](https://maharashtratimes.com/sports/articlelist/2429056.cms)\n"
|
| 40 |
"- [lifestyle](https://maharashtratimes.com/lifestyle-news/articlelist/2429025.cms)\n"
|
| 41 |
-
"- [state](https://maharashtratimes.com/maharashtra/articlelist/2429066.cms)"
|
|
|
|
| 42 |
)
|
| 43 |
|
| 44 |
classifier = st.sidebar.selectbox("Select a Model", index=0, options=["IndicNLP", "iNLTK"])
|
|
@@ -56,8 +57,8 @@ def app():
|
|
| 56 |
)
|
| 57 |
|
| 58 |
sample_texts = [
|
| 59 |
-
"
|
| 60 |
-
"
|
| 61 |
"Custom",
|
| 62 |
]
|
| 63 |
model_name_or_path = cfg["models"][classifier]
|
|
@@ -73,5 +74,5 @@ def app():
|
|
| 73 |
with st.spinner("Generating prediction..."):
|
| 74 |
result = load_model(text_to_classify, model_name_or_path)
|
| 75 |
|
| 76 |
-
st.markdown("**Predicted label:**
|
| 77 |
-
st.markdown("**Score:**
|
|
|
|
| 18 |
|
| 19 |
|
| 20 |
def app():
|
| 21 |
+
st.title("मराठी Marathi News Classifier")
|
| 22 |
|
| 23 |
st.markdown(
|
| 24 |
"This demo uses the below fine-tuned models for marathi news classification:\n"
|
| 25 |
"- [IndicNLP Marathi News Classifier](https://huggingface.co/flax-community/mr-indicnlp-classifier) fine-tuned on "
|
| 26 |
+
"[IndicNLP Marathi News Dataset](https://github.com/ai4bharat/indicnlp_corpus#indicnlp-news-article-classification-dataset)\n\n"
|
| 27 |
+
"> `IndicNLP` model predicts one of these 3 classes - `['lifestyle', 'entertainment', 'sports']`"
|
| 28 |
+
"\n\n"
|
| 29 |
"- [iNLTK Marathi News Classifier](https://huggingface.co/flax-community/mr-inltk-classifier) fine-tuned on "
|
| 30 |
+
"[Marathi News Dataset](https://www.kaggle.com/disisbig/marathi-news-dataset)\n\n"
|
| 31 |
+
"> `iNLTK` model predicts one of these 3 classes - `['state', 'entertainment', 'sports']`"
|
| 32 |
)
|
| 33 |
|
|
|
|
|
|
|
|
|
|
| 34 |
st.markdown(
|
| 35 |
+
"❓ Can't figure out where to get a sample text other than the predefined ones? ❓\n\n We have provided "
|
| 36 |
+
"Marathi newspaper links (section wise) below. Head over to any section of your choice, "
|
| 37 |
+
"copy any headline and paste below to see if the model is predicting the respective class correctly or not?\n"
|
| 38 |
"- [entertainment](https://maharashtratimes.com/entertainment/articlelist/19359255.cms)\n"
|
| 39 |
"- [sports](https://maharashtratimes.com/sports/articlelist/2429056.cms)\n"
|
| 40 |
"- [lifestyle](https://maharashtratimes.com/lifestyle-news/articlelist/2429025.cms)\n"
|
| 41 |
+
"- [state](https://maharashtratimes.com/maharashtra/articlelist/2429066.cms)\n\n"
|
| 42 |
+
"> 📒 NOTE: Both models are not trained on above headlines! Feel free to use any headline from any newspaper"
|
| 43 |
)
|
| 44 |
|
| 45 |
classifier = st.sidebar.selectbox("Select a Model", index=0, options=["IndicNLP", "iNLTK"])
|
|
|
|
| 57 |
)
|
| 58 |
|
| 59 |
sample_texts = [
|
| 60 |
+
"रोहित शर्माने सरावाला सुरुवात करण्यापूर्वी भारतीय खेळाडूला दिला कानमंत्र, म्हणाला...",
|
| 61 |
+
"जॉनी लीवर यांनी नम्रता संभेरावला दिलं खास गिफ्ट, अभिनेत्रीने व्यक्त केल्या भावना",
|
| 62 |
"Custom",
|
| 63 |
]
|
| 64 |
model_name_or_path = cfg["models"][classifier]
|
|
|
|
| 74 |
with st.spinner("Generating prediction..."):
|
| 75 |
result = load_model(text_to_classify, model_name_or_path)
|
| 76 |
|
| 77 |
+
st.markdown(f"**Predicted label:** {result[0]["label"]}")
|
| 78 |
+
st.markdown(f"**Score:** {round(result[0]["score"], 2)}")
|
apps/mlm.py
CHANGED
|
@@ -19,7 +19,7 @@ def load_model(input_text, model_name_or_path):
|
|
| 19 |
|
| 20 |
|
| 21 |
def app():
|
| 22 |
-
st.title("RoBERTa Marathi")
|
| 23 |
|
| 24 |
st.markdown(
|
| 25 |
"This demo uses [RoBERTa for Marathi](https://huggingface.co/flax-community/roberta-base-mr) model "
|
|
@@ -27,13 +27,15 @@ def app():
|
|
| 27 |
)
|
| 28 |
|
| 29 |
st.markdown(
|
| 30 |
-
"Can't figure out where to get a sample text other than the predefined ones?
|
| 31 |
-
"[link](https://maharashtratimes.com/entertainment/articlelist/19359255.cms),
|
|
|
|
| 32 |
)
|
| 33 |
|
| 34 |
masked_texts = [
|
| 35 |
"मोठी बातमी! उद्या दुपारी <mask> वाजता जाहीर होणार दहावीचा निकाल",
|
| 36 |
-
"
|
|
|
|
| 37 |
]
|
| 38 |
|
| 39 |
input_text = st.sidebar.selectbox("Select a Text", options=masked_texts)
|
|
|
|
| 19 |
|
| 20 |
|
| 21 |
def app():
|
| 22 |
+
st.title("RoBERTa Marathi - मराठी भाषा")
|
| 23 |
|
| 24 |
st.markdown(
|
| 25 |
"This demo uses [RoBERTa for Marathi](https://huggingface.co/flax-community/roberta-base-mr) model "
|
|
|
|
| 27 |
)
|
| 28 |
|
| 29 |
st.markdown(
|
| 30 |
+
"❓Can't figure out where to get a sample text other than the predefined ones?❓\n\n"
|
| 31 |
+
"Use any custom sentence with masked word or copy any headline from [link](https://maharashtratimes.com/entertainment/articlelist/19359255.cms), and mask a word.\n"
|
| 32 |
+
"> 📒 NOTE: Supports only single `<mask>` word"
|
| 33 |
)
|
| 34 |
|
| 35 |
masked_texts = [
|
| 36 |
"मोठी बातमी! उद्या दुपारी <mask> वाजता जाहीर होणार दहावीचा निकाल",
|
| 37 |
+
"जॉनी लीवर यांनी नम्रता संभेरावला दिलं <mask> गिफ्ट, अभिनेत्रीने व्यक्त केल्या भावना"
|
| 38 |
+
# "अध्यक्ष <mask> पवार आणि उपमुख्यमंत्री अजित पवार यांची भेट घेतली.",
|
| 39 |
]
|
| 40 |
|
| 41 |
input_text = st.sidebar.selectbox("Select a Text", options=masked_texts)
|