nichaphat commited on
Commit
43c35de
·
1 Parent(s): 5be9aba

Create new file

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ from transformers import pipeline
5
+
6
+ text_generator = pipeline("text-generation",model="distilbert-base-uncased-finetuned-sst-2-english")
7
+
8
+ def main():
9
+ st.title("Text-generation")
10
+
11
+ with st.form("text_field"):
12
+ text = st.text_area('enter your text:')
13
+ # clicked==True only when the button is clicked
14
+ clicked = st.form_submit_button("Generate")
15
+ if clicked:
16
+ results = text_generator([text], max_length=200, do_sample=False))
17
+ st.json(results)
18
+
19
+ if __name__ == "__main__":
20
+ main()