Spaces:
Sleeping
Sleeping
Commit
·
0c5f557
1
Parent(s):
28d11de
Update app.py
Browse files
app.py
CHANGED
|
@@ -36,11 +36,14 @@ def english_sum_pipeline(link):
|
|
| 36 |
|
| 37 |
return transcript_text, output_text
|
| 38 |
|
| 39 |
-
def english_qa_pipeline(
|
| 40 |
nlp = pipeline("question-answering", model='distilbert-base-uncased-distilled-squad')
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
| 44 |
#Collect inputs and create the interface
|
| 45 |
def main():
|
| 46 |
header = st.container()
|
|
@@ -55,11 +58,11 @@ def main():
|
|
| 55 |
|
| 56 |
with model:
|
| 57 |
st.header("Modelo para sumarização")
|
| 58 |
-
|
| 59 |
with model_1:
|
| 60 |
language = st.selectbox('Qual a linguagem do seu modelo?', ('Português (pt)', 'Inglês (en)', 'Outra'))
|
| 61 |
link = st.text_area(label="Coloque o link do seu vídeo do YouTube!", height=25, placeholder="Digite seu link...")
|
| 62 |
-
questions = st.text_area(label="Coloque suas perguntas separadas por vírgula!", height=50, placeholder="Digite suas perguntas...").split(",
|
| 63 |
submit_1 = st.button('Gerar soluções!')
|
| 64 |
|
| 65 |
with model_2:
|
|
@@ -68,17 +71,17 @@ def main():
|
|
| 68 |
if language == 'Português (pt)':
|
| 69 |
#outputs = portuguese_sum_pipeline(link)
|
| 70 |
st.write("Modelo ainda não implementado.")
|
| 71 |
-
|
| 72 |
elif language == 'Inglês (en)':
|
| 73 |
outputs = english_sum_pipeline(link)
|
| 74 |
-
answers = english_qa_pipeline(
|
| 75 |
-
|
| 76 |
else:
|
| 77 |
st.write("Erro na seleção de linguagem.")
|
| 78 |
|
| 79 |
st.write("Sumário.....................................................................: \n {} \n \n".format(outputs[1]))
|
| 80 |
st.write("Resposta....................................................................: \n")
|
| 81 |
-
|
| 82 |
for i in range(len(answers)):
|
| 83 |
st.write(questions[i] + ": " + answers[i])
|
| 84 |
|
|
|
|
| 36 |
|
| 37 |
return transcript_text, output_text
|
| 38 |
|
| 39 |
+
def english_qa_pipeline(questions, context):
|
| 40 |
nlp = pipeline("question-answering", model='distilbert-base-uncased-distilled-squad')
|
| 41 |
+
answers = []
|
| 42 |
+
for question in questions:
|
| 43 |
+
result = nlp(question=question, context=context)
|
| 44 |
+
answers.append(result["answer"])
|
| 45 |
+
return answers
|
| 46 |
+
|
| 47 |
#Collect inputs and create the interface
|
| 48 |
def main():
|
| 49 |
header = st.container()
|
|
|
|
| 58 |
|
| 59 |
with model:
|
| 60 |
st.header("Modelo para sumarização")
|
| 61 |
+
|
| 62 |
with model_1:
|
| 63 |
language = st.selectbox('Qual a linguagem do seu modelo?', ('Português (pt)', 'Inglês (en)', 'Outra'))
|
| 64 |
link = st.text_area(label="Coloque o link do seu vídeo do YouTube!", height=25, placeholder="Digite seu link...")
|
| 65 |
+
questions = st.text_area(label="Coloque suas perguntas separadas por vírgula!", height=50, placeholder="Digite suas perguntas...").split(",")
|
| 66 |
submit_1 = st.button('Gerar soluções!')
|
| 67 |
|
| 68 |
with model_2:
|
|
|
|
| 71 |
if language == 'Português (pt)':
|
| 72 |
#outputs = portuguese_sum_pipeline(link)
|
| 73 |
st.write("Modelo ainda não implementado.")
|
| 74 |
+
|
| 75 |
elif language == 'Inglês (en)':
|
| 76 |
outputs = english_sum_pipeline(link)
|
| 77 |
+
answers = english_qa_pipeline(questions, outputs[0])
|
| 78 |
+
|
| 79 |
else:
|
| 80 |
st.write("Erro na seleção de linguagem.")
|
| 81 |
|
| 82 |
st.write("Sumário.....................................................................: \n {} \n \n".format(outputs[1]))
|
| 83 |
st.write("Resposta....................................................................: \n")
|
| 84 |
+
|
| 85 |
for i in range(len(answers)):
|
| 86 |
st.write(questions[i] + ": " + answers[i])
|
| 87 |
|