Spaces:
Sleeping
Sleeping
Upload 17 files
Browse files- .gitattributes +0 -4
- .gitignore +15 -2
- Dockerfile +0 -2
- requirements.txt +15 -15
- src/prediction.py +27 -6
.gitattributes
CHANGED
|
@@ -37,7 +37,3 @@ src/Negative[[:space:]]-[[:space:]]Topic[[:space:]]Activities[[:space:]]Over[[:s
|
|
| 37 |
src/Negative[[:space:]]-[[:space:]]Wordcloud.png filter=lfs diff=lfs merge=lfs -text
|
| 38 |
src/Positive[[:space:]]-[[:space:]]Topic[[:space:]]Activities[[:space:]]Over[[:space:]]Time.png filter=lfs diff=lfs merge=lfs -text
|
| 39 |
src/Positive[[:space:]]-[[:space:]]Wordcloud.png filter=lfs diff=lfs merge=lfs -text
|
| 40 |
-
src/src/Negative[[:space:]]-[[:space:]]Topic[[:space:]]Activities[[:space:]]Over[[:space:]]Time.png filter=lfs diff=lfs merge=lfs -text
|
| 41 |
-
src/src/Negative[[:space:]]-[[:space:]]Wordcloud.png filter=lfs diff=lfs merge=lfs -text
|
| 42 |
-
src/src/Positive[[:space:]]-[[:space:]]Topic[[:space:]]Activities[[:space:]]Over[[:space:]]Time.png filter=lfs diff=lfs merge=lfs -text
|
| 43 |
-
src/src/Positive[[:space:]]-[[:space:]]Wordcloud.png filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 37 |
src/Negative[[:space:]]-[[:space:]]Wordcloud.png filter=lfs diff=lfs merge=lfs -text
|
| 38 |
src/Positive[[:space:]]-[[:space:]]Topic[[:space:]]Activities[[:space:]]Over[[:space:]]Time.png filter=lfs diff=lfs merge=lfs -text
|
| 39 |
src/Positive[[:space:]]-[[:space:]]Wordcloud.png filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
.gitignore
CHANGED
|
@@ -1,9 +1,22 @@
|
|
| 1 |
# Hugging Face cache
|
| 2 |
.cache/
|
|
|
|
| 3 |
|
| 4 |
-
#
|
|
|
|
|
|
|
|
|
|
| 5 |
.streamlit/
|
|
|
|
| 6 |
|
| 7 |
# Python bytecode
|
| 8 |
__pycache__/
|
| 9 |
-
*.pyc
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# Hugging Face cache
|
| 2 |
.cache/
|
| 3 |
+
hf_cache/
|
| 4 |
|
| 5 |
+
# NLTK data
|
| 6 |
+
nltk_data/
|
| 7 |
+
|
| 8 |
+
# Streamlit cache & config
|
| 9 |
.streamlit/
|
| 10 |
+
.streamlit/*
|
| 11 |
|
| 12 |
# Python bytecode
|
| 13 |
__pycache__/
|
| 14 |
+
*.pyc
|
| 15 |
+
*.pyo
|
| 16 |
+
*.pyd
|
| 17 |
+
|
| 18 |
+
# Logs & temp
|
| 19 |
+
*.log
|
| 20 |
+
tmp/
|
| 21 |
+
*.sqlite3
|
| 22 |
+
*.db
|
Dockerfile
CHANGED
|
@@ -8,8 +8,6 @@ RUN apt-get update && apt-get install -y \
|
|
| 8 |
git \
|
| 9 |
&& rm -rf /var/lib/apt/lists/*
|
| 10 |
|
| 11 |
-
ENV HF_HOME=/app/.cache/huggingface
|
| 12 |
-
|
| 13 |
COPY requirements.txt ./
|
| 14 |
COPY src/ ./src/
|
| 15 |
|
|
|
|
| 8 |
git \
|
| 9 |
&& rm -rf /var/lib/apt/lists/*
|
| 10 |
|
|
|
|
|
|
|
| 11 |
COPY requirements.txt ./
|
| 12 |
COPY src/ ./src/
|
| 13 |
|
requirements.txt
CHANGED
|
@@ -1,16 +1,16 @@
|
|
| 1 |
-
streamlit==1.44.0
|
| 2 |
-
pandas==2.2.3
|
| 3 |
-
seaborn
|
| 4 |
-
matplotlib
|
| 5 |
-
plotly
|
| 6 |
-
pillow
|
| 7 |
-
numpy
|
| 8 |
-
fastopic==1.0.1
|
| 9 |
-
topmost==1.0.2
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
joblib==1.2.0
|
| 14 |
-
scikit-learn==1.6.1
|
| 15 |
-
tensorflow==2.20.0
|
| 16 |
nltk
|
|
|
|
| 1 |
+
streamlit==1.44.0
|
| 2 |
+
pandas==2.2.3
|
| 3 |
+
seaborn
|
| 4 |
+
matplotlib
|
| 5 |
+
plotly
|
| 6 |
+
pillow
|
| 7 |
+
numpy
|
| 8 |
+
fastopic==1.0.1
|
| 9 |
+
topmost==1.0.2
|
| 10 |
+
torchvision==0.21.0
|
| 11 |
+
gensim==4.3.3
|
| 12 |
+
torch==1.11.0
|
| 13 |
+
joblib==1.2.0
|
| 14 |
+
scikit-learn==1.6.1
|
| 15 |
+
tensorflow==2.20.0
|
| 16 |
nltk
|
src/prediction.py
CHANGED
|
@@ -37,22 +37,35 @@ st.markdown(
|
|
| 37 |
)
|
| 38 |
|
| 39 |
# ============================================
|
| 40 |
-
# Hugging Face Hub Repo
|
| 41 |
# ============================================
|
| 42 |
repo_id = "BesottenJenny/acre-sentiment-models"
|
|
|
|
| 43 |
|
| 44 |
# ============================================
|
| 45 |
# Cached Loading Functions
|
| 46 |
# ============================================
|
| 47 |
@st.cache_resource
|
| 48 |
def load_sentiment_model():
|
| 49 |
-
path = hf_hub_download(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
return keras.models.load_model(path)
|
| 51 |
|
| 52 |
@st.cache_resource
|
| 53 |
def load_tokenizer_params():
|
| 54 |
-
tokenizer_path = hf_hub_download(
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
with open(tokenizer_path, "rb") as f:
|
| 57 |
tokenizer = pickle.load(f)
|
| 58 |
with open(params_path, "rb") as f:
|
|
@@ -61,8 +74,16 @@ def load_tokenizer_params():
|
|
| 61 |
|
| 62 |
@st.cache_resource
|
| 63 |
def load_topic_models():
|
| 64 |
-
neg_path = hf_hub_download(
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
neg_model = joblib.load(neg_path)
|
| 67 |
pos_model = joblib.load(pos_path)
|
| 68 |
return neg_model, pos_model
|
|
|
|
| 37 |
)
|
| 38 |
|
| 39 |
# ============================================
|
| 40 |
+
# Hugging Face Hub Repo & Cache Dir
|
| 41 |
# ============================================
|
| 42 |
repo_id = "BesottenJenny/acre-sentiment-models"
|
| 43 |
+
hf_cache_dir = os.path.join("/tmp", "hf_cache")
|
| 44 |
|
| 45 |
# ============================================
|
| 46 |
# Cached Loading Functions
|
| 47 |
# ============================================
|
| 48 |
@st.cache_resource
|
| 49 |
def load_sentiment_model():
|
| 50 |
+
path = hf_hub_download(
|
| 51 |
+
repo_id=repo_id,
|
| 52 |
+
filename="best_model.keras",
|
| 53 |
+
cache_dir=hf_cache_dir
|
| 54 |
+
)
|
| 55 |
return keras.models.load_model(path)
|
| 56 |
|
| 57 |
@st.cache_resource
|
| 58 |
def load_tokenizer_params():
|
| 59 |
+
tokenizer_path = hf_hub_download(
|
| 60 |
+
repo_id=repo_id,
|
| 61 |
+
filename="tokenizer.pkl",
|
| 62 |
+
cache_dir=hf_cache_dir
|
| 63 |
+
)
|
| 64 |
+
params_path = hf_hub_download(
|
| 65 |
+
repo_id=repo_id,
|
| 66 |
+
filename="params.pkl",
|
| 67 |
+
cache_dir=hf_cache_dir
|
| 68 |
+
)
|
| 69 |
with open(tokenizer_path, "rb") as f:
|
| 70 |
tokenizer = pickle.load(f)
|
| 71 |
with open(params_path, "rb") as f:
|
|
|
|
| 74 |
|
| 75 |
@st.cache_resource
|
| 76 |
def load_topic_models():
|
| 77 |
+
neg_path = hf_hub_download(
|
| 78 |
+
repo_id=repo_id,
|
| 79 |
+
filename="fastopic_negative_model.pkl",
|
| 80 |
+
cache_dir=hf_cache_dir
|
| 81 |
+
)
|
| 82 |
+
pos_path = hf_hub_download(
|
| 83 |
+
repo_id=repo_id,
|
| 84 |
+
filename="fastopic_positive_model.pkl",
|
| 85 |
+
cache_dir=hf_cache_dir
|
| 86 |
+
)
|
| 87 |
neg_model = joblib.load(neg_path)
|
| 88 |
pos_model = joblib.load(pos_path)
|
| 89 |
return neg_model, pos_model
|