samithcs commited on
Commit
73d289c
·
verified ·
1 Parent(s): a2ad275

Update src/components/model_nlp_intent.py

Browse files
Files changed (1) hide show
  1. src/components/model_nlp_intent.py +6 -6
src/components/model_nlp_intent.py CHANGED
@@ -4,21 +4,21 @@ from huggingface_hub import snapshot_download
4
  import joblib
5
  import os
6
 
7
- # Download the entire repository once at startup
8
- print("Downloading model from Hugging Face...")
9
  repo_path = snapshot_download(
10
  repo_id="samithcs/nlp_intent_model",
11
  repo_type="model"
12
  )
13
- print(f"Model downloaded to: {repo_path}")
14
 
15
- # Construct paths to subdirectories
 
16
  MODEL_PATH = os.path.join(repo_path, "nlp_intent", "intent_model")
17
  TOKENIZER_PATH = os.path.join(repo_path, "nlp_intent", "intent_tokenizer")
18
  LABEL_PATH = os.path.join(repo_path, "nlp_intent", "label_encoder.joblib")
19
 
20
- # Load model, tokenizer, and label encoder from local paths
21
- model = TFDistilBertForSequenceClassification.from_pretrained(MODEL_PATH, from_tf=True)
22
  tokenizer = DistilBertTokenizer.from_pretrained(TOKENIZER_PATH)
23
  label_encoder = joblib.load(LABEL_PATH)
24
 
 
4
  import joblib
5
  import os
6
 
7
+
8
+
9
  repo_path = snapshot_download(
10
  repo_id="samithcs/nlp_intent_model",
11
  repo_type="model"
12
  )
 
13
 
14
+
15
+
16
  MODEL_PATH = os.path.join(repo_path, "nlp_intent", "intent_model")
17
  TOKENIZER_PATH = os.path.join(repo_path, "nlp_intent", "intent_tokenizer")
18
  LABEL_PATH = os.path.join(repo_path, "nlp_intent", "label_encoder.joblib")
19
 
20
+
21
+ model = TFDistilBertForSequenceClassification.from_pretrained(MODEL_PATH)
22
  tokenizer = DistilBertTokenizer.from_pretrained(TOKENIZER_PATH)
23
  label_encoder = joblib.load(LABEL_PATH)
24