Spaces:
Sleeping
Sleeping
Commit
·
e122fa9
1
Parent(s):
1ba4bc9
deploy
Browse files
app.py
CHANGED
|
@@ -5,9 +5,14 @@ import torch
|
|
| 5 |
import matplotlib.pyplot as plt
|
| 6 |
import time
|
| 7 |
import os
|
| 8 |
-
os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
# Load model and tokenizer
|
| 11 |
model_name = "tabularisai/multilingual-sentiment-analysis"
|
| 12 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 13 |
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
|
@@ -38,7 +43,9 @@ st.title("Sentiment Analysis App")
|
|
| 38 |
st.write("Upload a CSV or Excel file containing text data for sentiment analysis.")
|
| 39 |
|
| 40 |
# File upload
|
| 41 |
-
uploaded_file = st.file_uploader("Upload a CSV or Excel file", type=["csv", "xlsx"])
|
|
|
|
|
|
|
| 42 |
|
| 43 |
if uploaded_file is not None:
|
| 44 |
try:
|
|
|
|
| 5 |
import matplotlib.pyplot as plt
|
| 6 |
import time
|
| 7 |
import os
|
| 8 |
+
import os
|
| 9 |
+
|
| 10 |
+
# Use a custom cache directory for Hugging Face models
|
| 11 |
+
os.environ["HF_HOME"] = "./hf_cache"
|
| 12 |
+
|
| 13 |
+
# Ensure directory exists and is writable
|
| 14 |
+
os.makedirs("./hf_cache", exist_ok=True)
|
| 15 |
|
|
|
|
| 16 |
model_name = "tabularisai/multilingual-sentiment-analysis"
|
| 17 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 18 |
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
|
|
|
| 43 |
st.write("Upload a CSV or Excel file containing text data for sentiment analysis.")
|
| 44 |
|
| 45 |
# File upload
|
| 46 |
+
# uploaded_file = st.file_uploader("Upload a CSV or Excel file", type=["csv", "xlsx"])
|
| 47 |
+
uploaded_file = st.file_uploader("Upload a CSV or Excel file", type=["csv", "xlsx"], accept_multiple_files=False)
|
| 48 |
+
|
| 49 |
|
| 50 |
if uploaded_file is not None:
|
| 51 |
try:
|