Spaces:
Sleeping
Sleeping
use pipeline instead of direct model load
Browse files
app.py
CHANGED
|
@@ -16,15 +16,14 @@ import os
|
|
| 16 |
hf_api_key = os.getenv("API_KEY")
|
| 17 |
login(token=hf_api_key)
|
| 18 |
|
| 19 |
-
pipe = pipeline("text-
|
| 20 |
|
| 21 |
# Function to classify customer comments
|
| 22 |
-
@spaces.GPU
|
| 23 |
def classify_comments():
|
| 24 |
results = []
|
| 25 |
for comment in df['customer_comment']:
|
| 26 |
-
prompt =
|
| 27 |
-
category = pipe(prompt
|
| 28 |
results.append(category)
|
| 29 |
df['comment_category'] = results
|
| 30 |
return df[['customer_comment', 'comment_category']].to_html(index=False)
|
|
|
|
| 16 |
hf_api_key = os.getenv("API_KEY")
|
| 17 |
login(token=hf_api_key)
|
| 18 |
|
| 19 |
+
pipe = pipeline("text-classification", model="distilbert/distilbert-base-uncased-finetuned-sst-2-english")
|
| 20 |
|
| 21 |
# Function to classify customer comments
|
|
|
|
| 22 |
def classify_comments():
|
| 23 |
results = []
|
| 24 |
for comment in df['customer_comment']:
|
| 25 |
+
prompt = comment
|
| 26 |
+
category = pipe(prompt)[0]['label']
|
| 27 |
results.append(category)
|
| 28 |
df['comment_category'] = results
|
| 29 |
return df[['customer_comment', 'comment_category']].to_html(index=False)
|