laiBatool commited on
Commit
3abcb4d
·
verified ·
1 Parent(s): ed9257f

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +3 -0
src/streamlit_app.py CHANGED
@@ -1,6 +1,7 @@
1
  import streamlit as st
2
  from transformers import AutoTokenizer, AutoModelForSequenceClassification
3
  import torch
 
4
 
5
  # Load your model from Hugging Face Hub
6
  model_name = "laiBatool/laiba-spam-classifier-bert" # replace with your actual model repo name
@@ -8,6 +9,8 @@ model_name = "laiBatool/laiba-spam-classifier-bert" # replace with your actual
8
 
9
  @st.cache_resource
10
  def load_model():
 
 
11
  tokenizer = AutoTokenizer.from_pretrained(model_name)
12
  model = AutoModelForSequenceClassification.from_pretrained(model_name)
13
  return tokenizer, model
 
1
  import streamlit as st
2
  from transformers import AutoTokenizer, AutoModelForSequenceClassification
3
  import torch
4
+ import os
5
 
6
  # Load your model from Hugging Face Hub
7
  model_name = "laiBatool/laiba-spam-classifier-bert" # replace with your actual model repo name
 
9
 
10
  @st.cache_resource
11
  def load_model():
12
+
13
+ os.environ['HF_HOME'] = './hf_cache' # Safe cache location in HF Space
14
  tokenizer = AutoTokenizer.from_pretrained(model_name)
15
  model = AutoModelForSequenceClassification.from_pretrained(model_name)
16
  return tokenizer, model