MUmairAB commited on
Commit
d1eaeb1
1 Parent(s): 81fdd06

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -1,18 +1,21 @@
1
  # import the module
2
  import streamlit as st
3
  from transformers import pipeline
 
 
 
 
 
 
 
4
 
5
 
6
  #This function accepts the masked text like: "How are [MASK]"
7
  # and feeds this text to the model and prints the output in which [MASK] is filled with the appropriate word.
8
  def print_the_mask(text):
9
-
10
- #Import the model
11
- model = pipeline(task="fill-mask",
12
- model="MUmairAB/bert-based-MaskedLM")
13
-
14
  #Apply the model
15
- model_out = model("I want to [MASK]")
16
 
17
  #First sort the list of dictionaries according to the score
18
  model_out = sorted(model_out, key=lambda x: x['score'],reverse=True)
@@ -30,7 +33,7 @@ def main():
30
  st.subheader(h1)
31
 
32
  st.write("Its code and other interesting projects are available on my [website](https://mumairab.github.io/)")
33
- h2 = "Enter your text and put \"[MASK]\" at the word which you want to predict, as shown in the following example: How are [MASK]"
34
  st.write(h2)
35
 
36
  text = st.text_input(label="Enter your text here:",
 
1
  # import the module
2
  import streamlit as st
3
  from transformers import pipeline
4
+ #Import the model
5
+ model = pipeline(task="fill-mask",
6
+ model="MUmairAB/bert-based-MaskedLM")
7
+ """
8
+ Typically, the model should be imported within a function. However, in this case, we are downloading it outside the function to avoid a significant delay that could annoy the user when downloading it inside the main function. By loading the model at this point, it will be downloaded when the app runs, and the user will overlook this initial loading time, as opposed to experiencing a delay after entering the input.
9
+ """
10
+
11
 
12
 
13
  #This function accepts the masked text like: "How are [MASK]"
14
  # and feeds this text to the model and prints the output in which [MASK] is filled with the appropriate word.
15
  def print_the_mask(text):
16
+
 
 
 
 
17
  #Apply the model
18
+ model_out = model(text)
19
 
20
  #First sort the list of dictionaries according to the score
21
  model_out = sorted(model_out, key=lambda x: x['score'],reverse=True)
 
33
  st.subheader(h1)
34
 
35
  st.write("Its code and other interesting projects are available on my [website](https://mumairab.github.io/)")
36
+ h2 = "Enter your text and put \"[MASK]\" at the word which you want to predict, as shown in the following example: Can we [MASK] to Paris?"
37
  st.write(h2)
38
 
39
  text = st.text_input(label="Enter your text here:",