justheuristic commited on
Commit
9cbeca2
1 Parent(s): fc66f32

test app.py

Browse files
Files changed (2) hide show
  1. app.py +18 -0
  2. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import transformers
3
+
4
+
5
+ model = transformers.AutoModelForCausalLM.from_pretrained("distilgpt2")
6
+ tokenizer = transformers.AutoTokenizer.from_pretrained("distilgpt2")
7
+
8
+ user_inputed_text = st.text_input("Insert text")
9
+
10
+ outputs = model.generate(
11
+ **tokenizer([user_inputed_text], return_tensors='pt'),
12
+ max_new_tokens=50, do_sample=True,
13
+ )
14
+
15
+
16
+ outputs_text = tokenizer.decode(outputs[0])
17
+
18
+ st.text_area(label='output', value="your text is :" + user_inputed_text[::-1])
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ torch
2
+ transformers