Spaces:
Runtime error
Runtime error
eduardo-meik
commited on
Commit
•
82c37b3
1
Parent(s):
413623a
Update app.py
Browse files
app.py
CHANGED
@@ -1,32 +1,39 @@
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
#
|
5 |
pipe = pipeline('sentiment-analysis')
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
col1, col2 = st.beta_columns([1,3])
|
11 |
-
|
12 |
-
with col1:
|
13 |
-
# Text area for input
|
14 |
-
text = st.text_area("Añade el texto a evaluar")
|
15 |
-
|
16 |
-
# Buttons for different analysis (for this example, I'm assuming just sentiment analysis, you can add more)
|
17 |
-
run_analysis = st.button("Evaluar Sentimiento")
|
18 |
-
|
19 |
-
with col2:
|
20 |
-
st.write("Resultados")
|
21 |
-
|
22 |
-
# Create a container for output to occupy the lower half of the layout
|
23 |
-
output_container = st.beta_container()
|
24 |
-
|
25 |
-
if run_analysis and text:
|
26 |
-
with output_container:
|
27 |
-
out = pipe(text)
|
28 |
-
st.json(out)
|
29 |
-
elif run_analysis and not text:
|
30 |
-
st.warning("Por favor, añade un texto para evaluar.")
|
31 |
|
|
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# Sentiment Analysis Pipeline
|
5 |
pipe = pipeline('sentiment-analysis')
|
6 |
|
7 |
+
# Toxicity Classifier
|
8 |
+
model_path = "citizenlab/distilbert-base-multilingual-cased-toxicity"
|
9 |
+
toxicity_classifier = pipeline("text-classification", model=model_path, tokenizer=model_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
+
st.title("Plataforma de Diálogos Participativos")
|
12 |
|
13 |
+
# Text area for input
|
14 |
+
text = st.text_area("Añade el texto a evaluar")
|
15 |
+
|
16 |
+
# Create buttons for different analyses
|
17 |
+
run_sentiment_analysis = st.button("Evaluar Sentimiento")
|
18 |
+
run_toxicity_analysis = st.button("Evaluar Toxicidad")
|
19 |
+
|
20 |
+
# Container for output
|
21 |
+
output_container = st.beta_container()
|
22 |
+
|
23 |
+
# Check if the sentiment analysis button has been pressed and if there's text in the text area
|
24 |
+
if run_sentiment_analysis and text:
|
25 |
+
with output_container:
|
26 |
+
sentiment_output = pipe(text)
|
27 |
+
st.write("Resultado del análisis de sentimiento:")
|
28 |
+
st.json(sentiment_output)
|
29 |
+
elif run_sentiment_analysis and not text:
|
30 |
+
st.warning("Por favor, añade un texto para evaluar el sentimiento.")
|
31 |
+
|
32 |
+
# Check if the toxicity analysis button has been pressed and if there's text in the text area
|
33 |
+
if run_toxicity_analysis and text:
|
34 |
+
with output_container:
|
35 |
+
toxicity_output = toxicity_classifier(text)
|
36 |
+
st.write("Resultado del análisis de toxicidad:")
|
37 |
+
st.json(toxicity_output)
|
38 |
+
elif run_toxicity_analysis and not text:
|
39 |
+
st.warning("Por favor, añade un texto para evaluar la toxicidad.")
|