Update app.py
Browse files
app.py
CHANGED
@@ -3,12 +3,14 @@ import transformers
|
|
3 |
from transformers import pipeline
|
4 |
from transformers import AutoTokenizer, AutoModelForMaskedLM
|
5 |
import pandas as pd
|
|
|
|
|
6 |
|
7 |
|
8 |
tokenizer = AutoTokenizer.from_pretrained("moussaKam/AraBART", padding= True, truncation=True, max_length=128)
|
9 |
model = AutoModelForMaskedLM.from_pretrained("moussaKam/AraBART")
|
10 |
|
11 |
-
|
12 |
def next_word(text, pipe):
|
13 |
res_dict= {
|
14 |
'Word':[],
|
@@ -31,4 +33,11 @@ pipe = pipeline("fill-mask", tokenizer = tokenizer, model = model)
|
|
31 |
dict_next_words = next_word(sent, pipe)
|
32 |
df = pd.DataFrame.from_dict(dict_next_words)
|
33 |
df.reset_index(drop=True, inplace=True)
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
from transformers import pipeline
|
4 |
from transformers import AutoTokenizer, AutoModelForMaskedLM
|
5 |
import pandas as pd
|
6 |
+
import seaborn as sns
|
7 |
+
import matplotlib.pyplot as plt
|
8 |
|
9 |
|
10 |
tokenizer = AutoTokenizer.from_pretrained("moussaKam/AraBART", padding= True, truncation=True, max_length=128)
|
11 |
model = AutoModelForMaskedLM.from_pretrained("moussaKam/AraBART")
|
12 |
|
13 |
+
#@st.cache
|
14 |
def next_word(text, pipe):
|
15 |
res_dict= {
|
16 |
'Word':[],
|
|
|
33 |
dict_next_words = next_word(sent, pipe)
|
34 |
df = pd.DataFrame.from_dict(dict_next_words)
|
35 |
df.reset_index(drop=True, inplace=True)
|
36 |
+
#design the graph theme
|
37 |
+
sns.set_theme(style="whitegrid")
|
38 |
+
sns.set_color_codes("pastel")
|
39 |
+
|
40 |
+
fig = sns.barplot(data=df, orient = 'h')
|
41 |
+
st.pyplot(fig)
|
42 |
+
|
43 |
+
#st.table(df)
|