Spaces:
Running
Running
Update: Fetching model from Hub instead of local path
Browse files- src/streamlit_app.py +12 -4
src/streamlit_app.py
CHANGED
|
@@ -63,13 +63,21 @@ def save_smart_data(text, ai_label, ai_score, corrected_label=None):
|
|
| 63 |
df.to_csv(FEEDBACK_FILE, mode='a', header=False, index=False)
|
| 64 |
|
| 65 |
# --- MODEL ENGINE PATH FIX ---
|
| 66 |
-
#
|
| 67 |
MODEL_PATH = "SumedhGajbhiye/Sentiment-Analyzer"
|
| 68 |
|
| 69 |
@st.cache_resource
|
| 70 |
-
def load_engine(
|
| 71 |
-
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
# --- HEADER SECTION ---
|
| 75 |
st.title("Sentiment Analyzer")
|
|
|
|
| 63 |
df.to_csv(FEEDBACK_FILE, mode='a', header=False, index=False)
|
| 64 |
|
| 65 |
# --- MODEL ENGINE PATH FIX ---
|
| 66 |
+
# 1. This must be your EXACT Model Repo name from Screenshot 281
|
| 67 |
MODEL_PATH = "SumedhGajbhiye/Sentiment-Analyzer"
|
| 68 |
|
| 69 |
@st.cache_resource
|
| 70 |
+
def load_engine():
|
| 71 |
+
try:
|
| 72 |
+
# We use the repo name directly.
|
| 73 |
+
# Transformers will automatically download it if it's not local.
|
| 74 |
+
return pipeline("sentiment-analysis", model=MODEL_PATH, tokenizer=MODEL_PATH)
|
| 75 |
+
except Exception as e:
|
| 76 |
+
st.error(f"Error loading model: {e}")
|
| 77 |
+
return None
|
| 78 |
+
|
| 79 |
+
# Remove or comment out any code that does:
|
| 80 |
+
# if not os.path.exists(MODEL_PATH): st.error("Not found")
|
| 81 |
|
| 82 |
# --- HEADER SECTION ---
|
| 83 |
st.title("Sentiment Analyzer")
|