Spaces:
Build error
Build error
Added default model
Browse files
app.py
CHANGED
|
@@ -5,10 +5,20 @@ st.title("Sentiment Analysis App - beta")
|
|
| 5 |
st.header("This app is to analyze the sentiments behind a text. Currently it uses \
|
| 6 |
pre-trained models without fine-tuning.")
|
| 7 |
|
| 8 |
-
st.text_input("Enter your text:", value="Missing Sophie.Z...")
|
| 9 |
-
st.selectbox("Please select a model:" ("Model 1", "Model 2", "Model 3"))
|
|
|
|
|
|
|
| 10 |
|
| 11 |
if st.button("Analyze"):
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
else:
|
| 14 |
st.write("Go on! Try the app!")
|
|
|
|
| 5 |
st.header("This app is to analyze the sentiments behind a text. Currently it uses \
|
| 6 |
pre-trained models without fine-tuning.")
|
| 7 |
|
| 8 |
+
user_input = st.text_input("Enter your text:", value="Missing Sophie.Z...")
|
| 9 |
+
st.selectbox("Please select a model:", ("Model 1", "Model 2", "Model 3"))
|
| 10 |
+
|
| 11 |
+
|
| 12 |
|
| 13 |
if st.button("Analyze"):
|
| 14 |
+
model_name = "distilbert-base-uncased-finetuned-sst-2-english"
|
| 15 |
+
|
| 16 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
| 17 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 18 |
+
|
| 19 |
+
classifier = pipeline("sentiment-analysis", model=model, tokenizer=tokenizer)
|
| 20 |
+
res = classifier(user_input)
|
| 21 |
+
st.write(res)
|
| 22 |
+
|
| 23 |
else:
|
| 24 |
st.write("Go on! Try the app!")
|