Spaces:
Runtime error
Runtime error
File size: 3,828 Bytes
f48bfec cd3659c 0df07e9 0177922 9ed5930 cd3659c 0df07e9 479b050 cd3659c 32ee8bd 0177922 f48bfec 0df07e9 f48bfec cd3659c f48bfec cd3659c fe38db6 cd3659c fe38db6 0df07e9 cd3659c fe38db6 cd3659c 0df07e9 0177922 cd3659c 0177922 9ed5930 0177922 0df07e9 fe38db6 cd3659c 0177922 9ed5930 0177922 0df07e9 0177922 fe38db6 cd3659c 0177922 9ed5930 cd3659c 9ed5930 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
import streamlit as st
from transformers import T5ForConditionalGeneration, T5Tokenizer
from fill_in_summary import FillInSummary
from paraphrase import PegasusParaphraser
import question_gen as q
default_text = "Apple was founded as Apple Computer Company on April 1, 1976, by Steve Jobs, Steve Wozniak and Ronald " \
"Wayne to develop and sell Wozniak's Apple I personal computer. It was incorporated by Jobs and " \
"Wozniak as Apple Computer, Inc. in 1977 and the company's next computer, the Apple II became a best " \
"seller. Apple went public in 1980, to instant financial success. The company went onto develop new " \
"computers featuring innovative graphical user interfaces, including the original Macintosh, " \
"announced in a critically acclaimed advertisement, '1984', directed by Ridley Scott. By 1985, " \
"the high cost of its products and power struggles between executives caused problems. Wozniak stepped " \
"back from Apple amicably, while Jobs resigned to found NeXT, taking some Apple employees with him. "
default_text2 = "The board of directors instructed Sculley to contain Jobs and his ability to launch expensive forays " \
"into untested products "
st.set_page_config(layout="centered")
st.title('Question Generator by Eddevs')
st.write('Please select the task you want to do.')
select = st.selectbox('Type', ['Question Generator', 'Paraphrasing', 'Summarization', 'Fill in the blank'])
if select == "Question Generator":
with st.form("question_gen"):
left_column, right_column = st.columns(2)
num_seq = left_column.slider('Question Count', 0, 10, 3)
beams = right_column.slider('Beams', 0, 10, 5)
max_length = st.slider('Max Length', 0, 1024, 300)
text_input = st.text_area("Input Text", value=default_text)
submitted = st.form_submit_button("Generate")
if submitted:
with st.spinner('Wait for it...'):
question_model = T5ForConditionalGeneration.from_pretrained('ramsrigouthamg/t5_squad_v1')
question_tokenizer = T5Tokenizer.from_pretrained('ramsrigouthamg/t5_squad_v1')
result = q.get_question(text_input, "", question_model, question_tokenizer, num_seq, beams, max_length)
st.write(result)
elif select == "Summarization":
with st.form("summarization"):
text_input = st.text_area("Input Text", value=default_text)
submitted = st.form_submit_button("Generate")
if submitted:
with st.spinner('Wait for it...'):
result = FillInSummary().summarize(text_input)
st.write(text_input)
elif select == "Fill in the blank":
with st.form("fill_in_the_blank"):
text_input = st.text_area("Input Text", value=default_text)
submitted = st.form_submit_button("Generate")
if submitted:
with st.spinner('Wait for it...'):
fill = FillInSummary()
result = fill.summarize(text_input)
result = fill.blank_ne_out(result)
st.write(result)
elif select == "Paraphrasing":
with st.form("paraphrasing"):
left_column, right_column = st.columns(2)
count = left_column.slider('Count', 0, 10, 3)
temperature = right_column.slider('Temperature', 0.0, 10.0, 1.5)
text_input = st.text_area("Input Text", value=default_text2)
submitted = st.form_submit_button("Generate")
if submitted:
with st.spinner('Wait for it...'):
paraphrase_model = PegasusParaphraser(num_return_sequences=count, temperature=temperature)
result = paraphrase_model.paraphrase(text_input)
st.write(result)
|