Spaces:
Runtime error
Runtime error
new update
Browse files
app.py
CHANGED
@@ -1,9 +1,48 @@
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
|
|
|
4 |
pipe = pipeline('sentiment-analysis')
|
5 |
test = st.text_area('enter the text:')
|
6 |
|
7 |
if test:
|
8 |
out = pipe(test)
|
9 |
-
st.json(out)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# The one with 'sentiment-analysis'
|
5 |
pipe = pipeline('sentiment-analysis')
|
6 |
test = st.text_area('enter the text:')
|
7 |
|
8 |
if test:
|
9 |
out = pipe(test)
|
10 |
+
st.json(out)
|
11 |
+
|
12 |
+
# The one with "text-classification"
|
13 |
+
pipe = pipeline('text-classification')
|
14 |
+
test = st.text_area('enter the text:')
|
15 |
+
|
16 |
+
if test:
|
17 |
+
out = pipe(test)
|
18 |
+
st.json(out)
|
19 |
+
|
20 |
+
|
21 |
+
|
22 |
+
|
23 |
+
|
24 |
+
|
25 |
+
|
26 |
+
# text generation from youtube vid
|
27 |
+
# st.write("And now for something completely different...")
|
28 |
+
#
|
29 |
+
# default_value = "See how a modern neural network auto-completes your text using HuggingFace"
|
30 |
+
# st.write("\n\nThe King of Text Generation, GPT-2 comes in four available sizes, only three of which have been made publicly available.")
|
31 |
+
#
|
32 |
+
# sent = st.text_area("Text", defalut_value, height=275)
|
33 |
+
# max_length = st.sidebar.slider("Max Length", min_value = 10, max_value=30)
|
34 |
+
# temperature = st.sidebar.slider("Temperature", value = 1.0, min_value=0.0, max_value=1.0, step=0.05)
|
35 |
+
# top_k = st.sidebar.slider("Top-k", min_value=0, max_value=5, value=0)
|
36 |
+
# top_p = st.sidebar.slider("top-p", min_value=0.0, max_value=1.0, step=0.05, value=0.9)
|
37 |
+
# num_return_sequences = st.sidebar.number_input('Number of Return Sequences', min_value=1, max_value=5, value=1, step=1)
|
38 |
+
#
|
39 |
+
# encoded_prompt = tokenizer.encode(sent, add_special_tokens=False, return_tensors="pt")
|
40 |
+
# if encoded_prompt.size()[-1] == 0:
|
41 |
+
# input_ids = None
|
42 |
+
# else:
|
43 |
+
# input_ids = encoded_prompt
|
44 |
+
#
|
45 |
+
# output_sequences = infer(input_ids, max_length, temperature, top_k, top_p, num_return_sequences)
|
46 |
+
#
|
47 |
+
# for generated_sequence_idx, generated_sequence in enumerate(output_sequences):
|
48 |
+
# print(f"=== GENERATED SEQUENCE {generated_sequence_idx + 1} ===")
|