thak123 commited on
Commit
86f28e8
1 Parent(s): c96f714

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -27
app.py CHANGED
@@ -9,43 +9,49 @@ import pandas as pd
9
  # from data_5_LT23 import features_dict,extra_feature_dict
10
  from data_predict import convert_to_stsb_features,convert_to_features
11
 
 
 
 
12
  features_dict = {}
13
  extra_feature_dict = {}
14
  sentinews_location = ""
15
 
16
- df_document_croatian_test = pd.read_csv(sentinews_location+"textlabel.tsv", sep="\t")
17
- df_document_croatian_test = df_document_croatian_test[["content"]]
18
-
19
- # gather everyone if you want to have a single DatasetDict
20
- document = DatasetDict({
21
- # "train": Dataset.from_pandas(df_document_sl_hr_train),
22
- # "valid": Dataset.from_pandas(df_document_sl_hr_valid),
23
- "test": Dataset.from_pandas(df_document_croatian_test)
24
- })
25
-
26
- dataset_dict = {
27
- "document": document,
28
- }
29
-
30
- for task_name, dataset in dataset_dict.items():
31
- print(task_name)
32
- print(dataset_dict[task_name]["test"][0])
33
- print()
34
-
35
-
36
- convert_func_dict = {
37
- "document": convert_to_stsb_features,
38
- # "paragraph": convert_to_stsb_features,
39
- # "sentence": convert_to_stsb_features,
40
- }
 
 
41
 
42
- features_dict = convert_to_features(dataset_dict, convert_func_dict)
43
 
44
 
 
 
45
 
46
  # multitask_model.from_pretrained(, config="/media/gaurish/angela/projects/CroatianSlovenEnglishBert/i-got-u-brother-cleopatra-workshop/src/models/multitask_model_3ep/config.json")
47
  multitask_model.load_state_dict(torch.load(
48
- "multitask_model_3ep/pytorch_model.bin"
49
  ))
50
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
51
  multitask_model.to(device)
 
9
  # from data_5_LT23 import features_dict,extra_feature_dict
10
  from data_predict import convert_to_stsb_features,convert_to_features
11
 
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"]]
21
+ def predict():
22
+ # gather everyone if you want to have a single DatasetDict
23
+ document = DatasetDict({
24
+ # "train": Dataset.from_pandas(df_document_sl_hr_train),
25
+ # "valid": Dataset.from_pandas(df_document_sl_hr_valid),
26
+ "test": Dataset.from_dict({"content":["Volim ti"]})
27
+ })
28
+
29
+ dataset_dict = {
30
+ "document": document,
31
+ }
32
+
33
+ for task_name, dataset in dataset_dict.items():
34
+ print(task_name)
35
+ print(dataset_dict[task_name]["test"][0])
36
+ print()
37
+
38
+
39
+ convert_func_dict = {
40
+ "document": convert_to_stsb_features,
41
+ # "paragraph": convert_to_stsb_features,
42
+ # "sentence": convert_to_stsb_features,
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")
50
+ model_link = hf_hub_download(repo_id="FFZG-cleopatra/Croatian-News-Classifier",filename = "pytorch_model.bin")
51
 
52
  # multitask_model.from_pretrained(, config="/media/gaurish/angela/projects/CroatianSlovenEnglishBert/i-got-u-brother-cleopatra-workshop/src/models/multitask_model_3ep/config.json")
53
  multitask_model.load_state_dict(torch.load(
54
+ model_link #"multitask_model_3ep/pytorch_model.bin"
55
  ))
56
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
57
  multitask_model.to(device)