Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,42 +1,7 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
|
3 |
-
|
4 |
-
from transformers import AutoTokenizer
|
5 |
-
from transformers import GenerationConfig
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
model_name = 'google/flan-t5-base'
|
11 |
-
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
|
12 |
-
|
13 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name, use_fast=True)
|
14 |
-
|
15 |
-
# select an example
|
16 |
-
example_index = [40]
|
17 |
-
|
18 |
-
# get the dialogue
|
19 |
-
dialogue = dataset['test'][example_index]['dialogue']
|
20 |
-
|
21 |
-
# get the human summary
|
22 |
-
summary = dataset['test'][example_index]['summary']
|
23 |
-
|
24 |
-
# Configurations
|
25 |
-
# generation_config = GenerationConfig(max_new_tokens=50, do_sample=True, temperature=0.7)
|
26 |
-
generation_config = GenerationConfig(max_new_tokens=50)
|
27 |
-
|
28 |
-
# Encode input:
|
29 |
-
inputs_encoded = tokenizer(dialogue, return_tensors='pt')
|
30 |
-
|
31 |
-
# Model Output:
|
32 |
-
model_output = model.generate(inputs_encoded["input_ids"], generation_config=generation_config)[0]
|
33 |
-
|
34 |
-
# Decode the output
|
35 |
-
zero_output = tokenizer.decode(model_output, skip_special_tokens=True)
|
36 |
-
|
37 |
-
|
38 |
-
print("Input: ", dialogue)
|
39 |
-
print(dash_line)
|
40 |
-
print( "Human summary: ", summary)
|
41 |
-
print(dash_line)
|
42 |
-
print("Model Output: ", zero_output)
|
|
|
1 |
+
import streamlit as st from transformers import pipeline
|
2 |
+
classifier = pipeline("sentiment-analysis")
|
3 |
+
text = st.text_enter("Enter your text")
|
|
|
|
|
4 |
|
5 |
+
if text :
|
6 |
+
out = classifier(text)
|
7 |
+
st.json(out)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|