Update app.py
Browse files
app.py
CHANGED
|
@@ -15,22 +15,18 @@ def normalize(text):
|
|
| 15 |
|
| 16 |
with st.spinner('Loading TaatikNet framework...'):
|
| 17 |
pipe = pipeline("text2text-generation", model='malper/taatiknet', device_map="auto")
|
| 18 |
-
|
| 19 |
st.success('Loaded!')
|
| 20 |
|
| 21 |
text = st.text_area('Enter text and press ctrl/command+enter:')
|
| 22 |
-
|
| 23 |
if text:
|
| 24 |
-
|
| 25 |
words = [normalize(x) for x in text.split() if contains_text(x)]
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
st.write(option)
|
|
|
|
| 15 |
|
| 16 |
with st.spinner('Loading TaatikNet framework...'):
|
| 17 |
pipe = pipeline("text2text-generation", model='malper/taatiknet', device_map="auto")
|
|
|
|
| 18 |
st.success('Loaded!')
|
| 19 |
|
| 20 |
text = st.text_area('Enter text and press ctrl/command+enter:')
|
|
|
|
| 21 |
if text:
|
|
|
|
| 22 |
words = [normalize(x) for x in text.split() if contains_text(x)]
|
| 23 |
+
if len(words) > 0:
|
| 24 |
+
outputs = pipe(words, max_length=200, num_beams=5, num_return_sequences=5)
|
| 25 |
+
texts = [
|
| 26 |
+
' '.join(x['generated_text'] for x in option)
|
| 27 |
+
for option in zip(*outputs)
|
| 28 |
+
]
|
| 29 |
+
st.write(texts[0])
|
| 30 |
+
st.write('Other options:')
|
| 31 |
+
for option in texts[1:]:
|
| 32 |
+
st.write(option)
|
|
|