vuminhtue commited on
Commit
7f83032
·
verified ·
1 Parent(s): 46dd42c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -1,21 +1,25 @@
1
  import gradio as gr
2
  from inference import SentimentClassifier
3
  from huggingface_hub import snapshot_download
 
4
  import os
5
 
6
  MODEL_ID = "vuminhtue/qwen3_sentiment_tinystories"
 
 
7
  LOCAL_DIR = os.path.join(os.getcwd(), "models", "qwen3_sentiment_tinystories")
8
 
9
- _ = snapshot_download(
10
- repo_id=MODEL_ID,
11
- local_dir=LOCAL_DIR,
12
- local_dir_use_symlinks=False, # safer in Spaces
13
- allow_patterns=["*.safetensors","config.json","tokenizer*","*.model","*.json"]
14
  )
15
 
16
 
17
  # Load classifier
18
- classifier = SentimentClassifier(".")
 
19
 
20
  def predict_sentiment(text):
21
  """Predict sentiment and return results"""
 
1
  import gradio as gr
2
  from inference import SentimentClassifier
3
  from huggingface_hub import snapshot_download
4
+ from huggingface_hub import hf_hub_download
5
  import os
6
 
7
  MODEL_ID = "vuminhtue/qwen3_sentiment_tinystories"
8
+ FILENAME = "Qwen3_200k_model_params.pt"
9
+
10
  LOCAL_DIR = os.path.join(os.getcwd(), "models", "qwen3_sentiment_tinystories")
11
 
12
+ weights_path = hf_hub_download(
13
+ repo_id=MODEL_REPO,
14
+ filename=FILENAME,
15
+ local_dir="models/qwen3_sentiment_tinystories", # any folder in runtime
16
+ local_dir_use_symlinks=None # not needed anymore; safe to omit
17
  )
18
 
19
 
20
  # Load classifier
21
+ classifier = SentimentClassifier(model_dir="models/qwen3_sentiment_tinystories",
22
+ weights_path=weights_path)
23
 
24
  def predict_sentiment(text):
25
  """Predict sentiment and return results"""