Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -107,13 +107,16 @@ config = BertConfig.from_pretrained(
|
|
| 107 |
id2label=id2label,
|
| 108 |
label2id=label2id)
|
| 109 |
|
| 110 |
-
|
| 111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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)
|