Spaces:
Runtime error
Runtime error
thoristhor
commited on
Commit
•
699a98b
1
Parent(s):
459b405
Update app.py
Browse files
app.py
CHANGED
@@ -28,8 +28,8 @@ def load_model():
|
|
28 |
nltk.download('omw-1.4')
|
29 |
## summary_mod_name = os.environ["summary_mod_name"]
|
30 |
## question_mod_name = os.environ["question_mod_name"]
|
31 |
-
summary_mod_name = "t5-
|
32 |
-
question_mod_name= "t5-
|
33 |
summary_model = T5ForConditionalGeneration.from_pretrained(summary_mod_name)
|
34 |
summary_tokenizer = T5Tokenizer.from_pretrained(summary_mod_name)
|
35 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
@@ -43,6 +43,13 @@ from nltk.corpus import wordnet as wn
|
|
43 |
from nltk.tokenize import sent_tokenize
|
44 |
from nltk.corpus import stopwords
|
45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
def load_file():
|
48 |
"""Load text from file"""
|
@@ -52,18 +59,21 @@ def load_file():
|
|
52 |
raw_text = str(uploaded_file.read(),"utf-8")
|
53 |
return raw_text
|
54 |
|
|
|
55 |
# Loading Model
|
56 |
-
summary_model, summary_tokenizer, question_tokenizer, question_model =
|
57 |
|
58 |
# App title and description
|
59 |
-
st.title("
|
60 |
-
st.write("Upload text,
|
61 |
|
|
|
|
|
62 |
|
63 |
# Load file
|
64 |
|
65 |
default_text = load_raw_text()
|
66 |
-
raw_text = st.text_area("
|
67 |
|
68 |
# raw_text = load_file()
|
69 |
start_time = str(datetime.datetime.now())
|
@@ -101,4 +111,15 @@ if raw_text != None and raw_text != '':
|
|
101 |
"""
|
102 |
st.markdown(html_str , unsafe_allow_html=True)
|
103 |
st.markdown("-----")
|
104 |
-
questions.append(ques)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
nltk.download('omw-1.4')
|
29 |
## summary_mod_name = os.environ["summary_mod_name"]
|
30 |
## question_mod_name = os.environ["question_mod_name"]
|
31 |
+
summary_mod_name = "t5-large"
|
32 |
+
question_mod_name = "t5-large"
|
33 |
summary_model = T5ForConditionalGeneration.from_pretrained(summary_mod_name)
|
34 |
summary_tokenizer = T5Tokenizer.from_pretrained(summary_mod_name)
|
35 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
|
43 |
from nltk.tokenize import sent_tokenize
|
44 |
from nltk.corpus import stopwords
|
45 |
|
46 |
+
def csv_downloader(df):
|
47 |
+
res = df.to_csv(index=False,sep="\t").encode('utf-8')
|
48 |
+
st.download_button(
|
49 |
+
label="Download logs data as CSV separated by tab",
|
50 |
+
data=res,
|
51 |
+
file_name='df_quiz_log_file_v1.csv',
|
52 |
+
mime='text/csv')
|
53 |
|
54 |
def load_file():
|
55 |
"""Load text from file"""
|
|
|
59 |
raw_text = str(uploaded_file.read(),"utf-8")
|
60 |
return raw_text
|
61 |
|
62 |
+
|
63 |
# Loading Model
|
64 |
+
summary_model, summary_tokenizer, question_tokenizer, question_model =load_model()
|
65 |
|
66 |
# App title and description
|
67 |
+
st.title("Exam Assistant")
|
68 |
+
st.write("Upload text, Get ready for answering autogenerated questions")
|
69 |
|
70 |
+
# Load file
|
71 |
+
st.text("Disclaimer: This app stores user's input for model improvement purposes !!")
|
72 |
|
73 |
# Load file
|
74 |
|
75 |
default_text = load_raw_text()
|
76 |
+
raw_text = st.text_area("Enter text here - press Ctrl + enter to submit", height=250, max_chars=1000000, )
|
77 |
|
78 |
# raw_text = load_file()
|
79 |
start_time = str(datetime.datetime.now())
|
|
|
111 |
"""
|
112 |
st.markdown(html_str , unsafe_allow_html=True)
|
113 |
st.markdown("-----")
|
114 |
+
questions.append(ques)
|
115 |
+
output_path = "results/df_quiz_log_file_v1.csv"
|
116 |
+
res_df = pd.DataFrame({"TimeStamp":[start_time]*len(ans_list),\
|
117 |
+
"Input":[str(raw_text)]*len(ans_list),\
|
118 |
+
"Question":questions,"Option1":option1,\
|
119 |
+
"Option2":option2,\
|
120 |
+
"Option3":option3,\
|
121 |
+
"Option4":option4,\
|
122 |
+
"Correct Answer":ans_list})
|
123 |
+
res_df.to_csv(output_path, mode='a', index=False, sep="\t", header= not os.path.exists(output_path))
|
124 |
+
# st.dataframe(pd.read_csv(output_path,sep="\t").tail(5))
|
125 |
+
csv_downloader(pd.read_csv(output_path,sep="\t"))
|