Update app.py
Browse files
app.py
CHANGED
@@ -1,22 +1,19 @@
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
|
|
|
|
|
4 |
classifier = pipeline("translation", model="t5-base")
|
5 |
def main():
|
6 |
-
st.title("Text
|
7 |
|
8 |
with st.form("text_field"):
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
output = model.generate(input_ids = encoded_input.input_ids,
|
17 |
-
attention_mask = encoded_input.attention_mask)
|
18 |
-
output = tokenizer.decode(output[0], skip_special_tokens=True)
|
19 |
-
print(output)
|
20 |
-
|
21 |
if __name__ == "__main__":
|
22 |
main()
|
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
#model = AutoModelForSeq2SeqLM.from_pretrained("t5-base")
|
5 |
+
#tokenizer = AutoTokenizer.from_pretrained("t5-base")
|
6 |
classifier = pipeline("translation", model="t5-base")
|
7 |
def main():
|
8 |
+
st.title("Text translation")
|
9 |
|
10 |
with st.form("text_field"):
|
11 |
+
text = st.text_area('enter some text:')
|
12 |
+
# clicked==True only when the button is clicked
|
13 |
+
clicked = st.form_submit_button("Submit")
|
14 |
+
if clicked:
|
15 |
+
results = classifier([text])
|
16 |
+
st.json(results)
|
17 |
+
|
|
|
|
|
|
|
|
|
|
|
18 |
if __name__ == "__main__":
|
19 |
main()
|