Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -29,11 +29,6 @@ def generation_model():
|
|
29 |
generator = pipeline(model=model_name, tokenizer=model_name, task="text-generation")
|
30 |
return generator
|
31 |
|
32 |
-
@st.cache(show_spinner=False, allow_output_mutation=True)
|
33 |
-
def sentiment_model():
|
34 |
-
sentiment_analysis = pipeline("sentiment-analysis")
|
35 |
-
return sentiment_analysis
|
36 |
-
|
37 |
if option == "Extractive question answering":
|
38 |
st.markdown("<h2 style='text-align: center; color:red;'>Extract answer from text</h2>", unsafe_allow_html=True)
|
39 |
source = st.radio("How would you like to start? Choose an option below", ["I want to input some text", "I want to upload a file"])
|
@@ -103,15 +98,4 @@ elif option == "Text generation":
|
|
103 |
generator = generation_model()
|
104 |
with st.spinner(text="Generating text..."):
|
105 |
generated_text = generator(text, max_length=50)
|
106 |
-
st.write(generated_text[0]["generated_text"])
|
107 |
-
|
108 |
-
elif option == "Sentiment analysis":
|
109 |
-
st.markdown("<h2 style='text-align: center; color:grey;'>Classify review</h2>", unsafe_allow_html=True)
|
110 |
-
text = st.text_input(label='Enter a sentence to get its sentiment analysis')
|
111 |
-
button = st.button("Get sentiment analysis")
|
112 |
-
if button:
|
113 |
-
with st.spinner(text="Loading sentiment analysis model..."):
|
114 |
-
sentiment_analysis = sentiment_model()
|
115 |
-
with st.spinner(text="Getting sentiment analysis..."):
|
116 |
-
sentiment = sentiment_analysis(text)
|
117 |
-
st.write(sentiment[0]["label"])
|
|
|
29 |
generator = pipeline(model=model_name, tokenizer=model_name, task="text-generation")
|
30 |
return generator
|
31 |
|
|
|
|
|
|
|
|
|
|
|
32 |
if option == "Extractive question answering":
|
33 |
st.markdown("<h2 style='text-align: center; color:red;'>Extract answer from text</h2>", unsafe_allow_html=True)
|
34 |
source = st.radio("How would you like to start? Choose an option below", ["I want to input some text", "I want to upload a file"])
|
|
|
98 |
generator = generation_model()
|
99 |
with st.spinner(text="Generating text..."):
|
100 |
generated_text = generator(text, max_length=50)
|
101 |
+
st.write(generated_text[0]["generated_text"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|