Daizzyy commited on
Commit
444b43c
·
verified ·
1 Parent(s): 287284d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -3,19 +3,19 @@ import joblib
3
  from huggingface_hub import hf_hub_download
4
  import os
5
 
 
6
  def load_model():
7
  """Download and load model from HF Hub"""
8
  try:
9
  print("Loading model from Hugging Face Hub...")
10
 
11
 
12
- HF_USERNAME = "Daizzyy"
13
- HF_MODEL = "cyberbullying-model"
14
  repo_id = f"{HF_USERNAME}/{HF_MODEL}"
15
 
16
  print(f"Downloading from: {repo_id}")
17
 
18
- # Download and load model
19
  try:
20
  model_file = hf_hub_download(
21
  repo_id=repo_id,
@@ -28,11 +28,10 @@ def load_model():
28
  print(f"❌ Error loading model: {e}")
29
  return None
30
 
31
- # Download and load vectorizer
32
  try:
33
  vectorizer_file = hf_hub_download(
34
  repo_id=repo_id,
35
- filename="vocab",
36
  cache_dir=".cache"
37
  )
38
  vectorizer = joblib.load(vectorizer_file)
@@ -41,7 +40,6 @@ def load_model():
41
  print(f"❌ Error loading vectorizer: {e}")
42
  vectorizer = None
43
 
44
-
45
  try:
46
  label_encoder_file = hf_hub_download(
47
  repo_id=repo_id,
@@ -76,6 +74,7 @@ else:
76
  print("✅ All models loaded successfully!")
77
 
78
 
 
79
  def predict(text):
80
  """Predict cyberbullying category"""
81
  if not text.strip():
 
3
  from huggingface_hub import hf_hub_download
4
  import os
5
 
6
+
7
  def load_model():
8
  """Download and load model from HF Hub"""
9
  try:
10
  print("Loading model from Hugging Face Hub...")
11
 
12
 
13
+ HF_MODEL = "cyberbullying-model"
 
14
  repo_id = f"{HF_USERNAME}/{HF_MODEL}"
15
 
16
  print(f"Downloading from: {repo_id}")
17
 
18
+
19
  try:
20
  model_file = hf_hub_download(
21
  repo_id=repo_id,
 
28
  print(f"❌ Error loading model: {e}")
29
  return None
30
 
 
31
  try:
32
  vectorizer_file = hf_hub_download(
33
  repo_id=repo_id,
34
+ filename="vocab.txt",
35
  cache_dir=".cache"
36
  )
37
  vectorizer = joblib.load(vectorizer_file)
 
40
  print(f"❌ Error loading vectorizer: {e}")
41
  vectorizer = None
42
 
 
43
  try:
44
  label_encoder_file = hf_hub_download(
45
  repo_id=repo_id,
 
74
  print("✅ All models loaded successfully!")
75
 
76
 
77
+
78
  def predict(text):
79
  """Predict cyberbullying category"""
80
  if not text.strip():