Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -12,9 +12,9 @@ from data_predict import convert_to_stsb_features,convert_to_features
|
|
12 |
from huggingface_hub import hf_hub_download,snapshot_download
|
13 |
|
14 |
|
15 |
-
features_dict = {}
|
16 |
-
extra_feature_dict = {}
|
17 |
-
sentinews_location = ""
|
18 |
|
19 |
# df_document_croatian_test = pd.read_csv(sentinews_location+"textlabel.tsv", sep="\t")
|
20 |
# df_document_croatian_test = df_document_croatian_test[["content"]]
|
@@ -43,7 +43,8 @@ def predict():
|
|
43 |
}
|
44 |
|
45 |
features_dict = convert_to_features(dataset_dict, convert_func_dict)
|
46 |
-
|
|
|
47 |
|
48 |
|
49 |
#model_link = snapshot_download(repo_id="FFZG-cleopatra/Croatian-News-Classifier")
|
@@ -54,6 +55,7 @@ multitask_model.load_state_dict(torch.load(model_link, map_location=torch.device
|
|
54 |
# device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
55 |
# multitask_model.to(device)
|
56 |
predictions = []
|
|
|
57 |
for _, batch in enumerate(features_dict["document"]['test']):
|
58 |
for key, value in batch.items():
|
59 |
batch[key] = batch[key].to(device)
|
|
|
12 |
from huggingface_hub import hf_hub_download,snapshot_download
|
13 |
|
14 |
|
15 |
+
# features_dict = {}
|
16 |
+
# extra_feature_dict = {}
|
17 |
+
# sentinews_location = ""
|
18 |
|
19 |
# df_document_croatian_test = pd.read_csv(sentinews_location+"textlabel.tsv", sep="\t")
|
20 |
# df_document_croatian_test = df_document_croatian_test[["content"]]
|
|
|
43 |
}
|
44 |
|
45 |
features_dict = convert_to_features(dataset_dict, convert_func_dict)
|
46 |
+
|
47 |
+
return features_dict
|
48 |
|
49 |
|
50 |
#model_link = snapshot_download(repo_id="FFZG-cleopatra/Croatian-News-Classifier")
|
|
|
55 |
# device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
56 |
# multitask_model.to(device)
|
57 |
predictions = []
|
58 |
+
features_dict = predict()
|
59 |
for _, batch in enumerate(features_dict["document"]['test']):
|
60 |
for key, value in batch.items():
|
61 |
batch[key] = batch[key].to(device)
|