nipunsadvilkar commited on
Commit
3523c5d
·
1 Parent(s): bd074e8

Update details

Browse files
Files changed (2) hide show
  1. apps/classifier.py +15 -14
  2. 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
- "\n"
 
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? Visit any of the following links, "
37
- "copy any headline and see if the model is predicting the respective class 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)"
 
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:** " + result[0]["label"])
77
- st.markdown("**Score:** " + str(round(result[0]["score"], 2)))
 
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? Visit this "
31
- "[link](https://maharashtratimes.com/entertainment/articlelist/19359255.cms), copy any headline and mask a word."
 
32
  )
33
 
34
  masked_texts = [
35
  "मोठी बातमी! उद्या दुपारी <mask> वाजता जाहीर होणार दहावीचा निकाल",
36
- "अध्यक्ष <mask> पआणि उपमुख्त्रअजिवा याची भेेत.",
 
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)