zArabi commited on
Commit
2d6aba9
·
1 Parent(s): 1635166

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -107,13 +107,16 @@ config = BertConfig.from_pretrained(
107
  id2label=id2label,
108
  label2id=label2id)
109
 
110
- downloadedModelFile = hf_hub_download(repo_id="zArabi/Persian-Sentiment-Analysis", filename="persianModel")
111
- loaded_model = torch.load(downloadedModelFile,map_location="cpu")
 
 
 
 
112
 
113
 
114
  tokenizer = BertTokenizer.from_pretrained(modelName)
115
  max_len=512
116
- device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
117
 
118
  def predict(text):
119
  text = cleaning(text)
 
107
  id2label=id2label,
108
  label2id=label2id)
109
 
110
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
111
+
112
+ path = 'HooshvareLab-bert-fa-base-uncased-3class.bin'
113
+ downloadedModelDict = hf_hub_download(repo_id="zArabi/Persian-Sentiment-Analysis", filename=path)
114
+ loaded_model = SentimentModel(config=config).to(device)
115
+ loaded_model.load_state_dict(torch.load(downloadedModelDict, map_location="cpu"))
116
 
117
 
118
  tokenizer = BertTokenizer.from_pretrained(modelName)
119
  max_len=512
 
120
 
121
  def predict(text):
122
  text = cleaning(text)