Spaces:
Runtime error
Runtime error
reverting to the parsbert
Browse files
app.py
CHANGED
|
@@ -107,16 +107,13 @@ config = BertConfig.from_pretrained(
|
|
| 107 |
id2label=id2label,
|
| 108 |
label2id=label2id)
|
| 109 |
|
| 110 |
-
|
| 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)
|
|
@@ -147,5 +144,5 @@ gr.Interface(
|
|
| 147 |
predict,
|
| 148 |
inputs=gr.Textbox(label="Explore your sentence!",lines=2, placeholder="Type Here..."),
|
| 149 |
outputs=gr.outputs.Label(num_top_classes=3),
|
| 150 |
-
title="How are feeling
|
| 151 |
).launch()
|
|
|
|
| 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)
|
|
|
|
| 144 |
predict,
|
| 145 |
inputs=gr.Textbox(label="Explore your sentence!",lines=2, placeholder="Type Here..."),
|
| 146 |
outputs=gr.outputs.Label(num_top_classes=3),
|
| 147 |
+
title="How are feeling?!",
|
| 148 |
).launch()
|