Spaces:
Sleeping
Sleeping
Commit
·
6553e18
1
Parent(s):
7484466
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,9 +18,22 @@ import streamlit as st
|
|
| 18 |
|
| 19 |
# Prog3: Zero Shot Classifier
|
| 20 |
|
| 21 |
-
classifier2 = pipeline("zero-shot-classification")
|
| 22 |
-
res = classifier2(
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
)
|
| 26 |
-
st.write(res)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
# Prog3: Zero Shot Classifier
|
| 20 |
|
| 21 |
+
# classifier2 = pipeline("zero-shot-classification")
|
| 22 |
+
# res = classifier2(
|
| 23 |
+
# "This is a course for Python List comprehension",
|
| 24 |
+
# candidate_labels = ["education","politics","business"]
|
| 25 |
+
# )
|
| 26 |
+
# st.write(res)
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
# Prog4: Using Automodel and Autotokenizer
|
| 30 |
+
|
| 31 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 32 |
+
|
| 33 |
+
model_name = "distilbert-base-uncased-finetuned-sst-2-english"
|
| 34 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
| 35 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 36 |
+
|
| 37 |
+
classifier3 = pipeline("sentiment-analysis",model=model,tokenizer=tokenizer)
|
| 38 |
+
|
| 39 |
+
res = classifier3("Newton has been the biggest physicist")
|