Chan Lee commited on
Commit
7811d35
1 Parent(s): 538f828
Files changed (1) hide show
  1. app.py +29 -53
app.py CHANGED
@@ -56,26 +56,6 @@ other_examples = [
56
  other_title = "Other Health Related Task"
57
  other_desc = "Enter drug-related tweets to generate labels from 3 models (BERT, MentalBERT, PHS-BERT). Label 0='no adverse drug reaction', 1='adverse drug reaction'. The three provided examples have true labels 0,0,1 respectively. For more details, please refer to the SMM4H T1 dataset description in our paper (link provided in the corresponding Hugging Face repository)."
58
 
59
- # vs_predictor_bert = ktrain.load_predictor('vs/bert')
60
- # vs_predictor_mental = ktrain.load_predictor('vs/mentalbert')
61
- # vs_predictor_phs = ktrain.load_predictor('vs/phsbert')
62
-
63
- # def vs_BERT(text):
64
- # results = vs_predictor_bert.predict(str(text))
65
- # return "BERT:" + str(results)
66
-
67
- # def vs_MentalBERT(text):
68
- # results = vs_predictor_mental.predict(str(text))
69
- # return "MentalBERT:" + str(results)
70
-
71
- # def vs_PHSBERT(text):
72
- # results = vs_predictor_phs.predict(str(text))
73
- # return "PHS-BERT:" + str(results)
74
-
75
- # vs_bert_io = Interface(fn=vs_BERT, inputs="text", outputs="text")
76
- # vs_mental_io = Interface(fn=vs_MentalBERT, inputs="text", outputs="text")
77
- # vs_phs_io = Interface(fn=vs_PHSBERT, inputs="text", outputs="text")
78
-
79
  def make_interfaces(folder):
80
  predictor_bert = ktrain.load_predictor(folder + "bert")
81
  predictor_mental = ktrain.load_predictor(folder + "mentalbert")
@@ -100,50 +80,46 @@ def make_interfaces(folder):
100
  return bert_io, mental_io, phs_io
101
 
102
  vs_bert_io, vs_mental_io, vs_phs_io = make_interfaces("vs/")
103
-
104
  vs = Parallel(vs_bert_io, vs_mental_io, vs_phs_io,
105
  examples=vs_examples,
106
  title=vs_title,
107
  description=vs_desc)
108
 
109
- # hm_predictor_bert = ktrain.load_predictor('hm/bert')
110
- # hm_predictor_mental = ktrain.load_predictor('hm/mentalbert')
111
- # hm_predictor_phs = ktrain.load_predictor('hm/phsbert')
112
-
113
- # def hm_BERT(text):
114
- # results = hm_predictor_bert.predict(str(text))
115
- # return "BERT:" + str(results)
116
-
117
- # def hm_MentalBERT(text):
118
- # results = hm_predictor_mental.predict(str(text))
119
- # return "MentalBERT" + str(results)
120
-
121
- # def hm_PHSBERT(text):
122
- # results = hm_predictor_phs.predict(str(text))
123
- # return "PHS-BERT" + str(results)
124
-
125
- # hm_bert_io = Interface(fn=hm_BERT, inputs="text", outputs="text")
126
- # hm_mental_io = Interface(fn=hm_MentalBERT, inputs="text", outputs="text")
127
- # hm_phs_io = Interface(fn=hm_PHSBERT, inputs="text", outputs="text")
128
-
129
  hm_bert_io, hm_mental_io, hm_phs_io = make_interfaces("hm/")
130
-
131
  hm = Parallel(hm_bert_io, hm_mental_io, hm_phs_io,
132
  examples=hm_examples,
133
  title=hm_title,
134
  description=hm_desc)
135
 
136
-
137
- desc = "Task is currently unavailable."
138
-
139
- def model(text):
140
- return "Predictions are currently unavailable."
141
-
142
- dep = Interface(fn=model, inputs="text", outputs="text", title=dep_title, description=desc)
143
- covid = Interface(fn=model, inputs="text", outputs="text", title=covid_title, description=desc)
144
- suicide = Interface(fn=model, inputs="text", outputs="text", title=suicide_title, description=desc)
145
- stress = Interface(fn=model, inputs="text", outputs="text", title=stress_title, description=desc)
146
- other = Interface(fn=model, inputs="text", outputs="text", title=other_title, description=desc)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
 
148
  interfaces = [vs, hm, dep, covid, suicide, stress, other]
149
  interface_names = [vs_title, hm_title, dep_title, covid_title, suicide_title, stress_title, other_title]
 
56
  other_title = "Other Health Related Task"
57
  other_desc = "Enter drug-related tweets to generate labels from 3 models (BERT, MentalBERT, PHS-BERT). Label 0='no adverse drug reaction', 1='adverse drug reaction'. The three provided examples have true labels 0,0,1 respectively. For more details, please refer to the SMM4H T1 dataset description in our paper (link provided in the corresponding Hugging Face repository)."
58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  def make_interfaces(folder):
60
  predictor_bert = ktrain.load_predictor(folder + "bert")
61
  predictor_mental = ktrain.load_predictor(folder + "mentalbert")
 
80
  return bert_io, mental_io, phs_io
81
 
82
  vs_bert_io, vs_mental_io, vs_phs_io = make_interfaces("vs/")
 
83
  vs = Parallel(vs_bert_io, vs_mental_io, vs_phs_io,
84
  examples=vs_examples,
85
  title=vs_title,
86
  description=vs_desc)
87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  hm_bert_io, hm_mental_io, hm_phs_io = make_interfaces("hm/")
 
89
  hm = Parallel(hm_bert_io, hm_mental_io, hm_phs_io,
90
  examples=hm_examples,
91
  title=hm_title,
92
  description=hm_desc)
93
 
94
+ dep_bert_io, dep_mental_io, dep_phs_io = make_interfaces("dp/")
95
+ dep = Parallel(dep_bert_io, dep_mental_io, dep_phs_io,
96
+ examples=dep_examples,
97
+ title=dep_title,
98
+ description=dep_desc)
99
+
100
+ covid_bert_io, covid_mental_io, covid_phs_io = make_interfaces("cv/")
101
+ covid = Parallel(covid_bert_io, covid_mental_io, covid_phs_io,
102
+ examples=covid_examples,
103
+ title=covid_title,
104
+ description=covid_desc)
105
+
106
+ suicide_bert_io, suicide_mental_io, suicide_phs_io = make_interfaces("sc/")
107
+ suicide = Parallel(suicide_bert_io, suicide_mental_io, suicide_phs_io,
108
+ examples=suicide_examples,
109
+ title=suicide_title,
110
+ description=suicide_desc)
111
+
112
+ stress_bert_io, stress_mental_io, stress_phs_io = make_interfaces("st/")
113
+ stress = Parallel(stress_bert_io, stress_mental_io, stress_phs_io,
114
+ examples=stress_examples,
115
+ title=stress_title,
116
+ description=stress_desc)
117
+
118
+ other_bert_io, other_mental_io, other_phs_io = make_interfaces("ot/")
119
+ other = Parallel(other_bert_io, other_mental_io, other_phs_io,
120
+ examples=other_examples,
121
+ title=other_title,
122
+ description=other_desc)
123
 
124
  interfaces = [vs, hm, dep, covid, suicide, stress, other]
125
  interface_names = [vs_title, hm_title, dep_title, covid_title, suicide_title, stress_title, other_title]