publichealthsurveillance commited on
Commit
37751e8
1 Parent(s): 8da8b5c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -4
app.py CHANGED
@@ -1,6 +1,45 @@
1
- import gradio as gr
 
2
 
3
- io1= gr.Interface(lambda x:x, "text", "text")
4
- io2= gr.Interface(lambda x:x, "image", "image")
 
 
 
 
5
 
6
- gr.TabbedInterface([io1, io2]).launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import ktrain
2
+ from gradio import Interface, Parallel, TabbedInterface
3
 
4
+ examples = [
5
+ ["I only get my kids the ones I got....I've turned down many so called 'vaccines'"],
6
+ ["In child protective services, further providing for definitions, for immunity from liability"],
7
+ ["Lol what? Measles is a real thing. Get vaccinated"]]
8
+ title = "Vaccine Sentiment Task - VS2"
9
+ desc = "Enter vaccine-related tweets to generate sentiment from 3 models (BERT, MentalBERT, PHS-BERT). Label 0='vaccine critical', 1='neutral', 2='vaccine supportive'. The three provided examples have true labels 0,1,2 respectively. For details about VS2, please refer to our paper (linked provided in the corresponding Hugging Face repository)."
10
 
11
+ predictor_bert = ktrain.load_predictor('bert')
12
+ predictor_mental = ktrain.load_predictor('mentalbert')
13
+ predictor_phs = ktrain.load_predictor('phsbert')
14
+
15
+ def BERT(text):
16
+ results = predictor_bert.predict(str(text))
17
+ return str(results)
18
+
19
+ def MentalBERT(text):
20
+ results = predictor_mental.predict(str(text))
21
+ return str(results)
22
+
23
+ def PHSBERT(text):
24
+ results = predictor_phs.predict(str(text))
25
+ return str(results)
26
+
27
+ bert_io = Interface(fn=BERT, inputs="text", outputs="text")
28
+ mental_io = Interface(fn=MentalBERT, inputs="text", outputs="text")
29
+ phs_io = Interface(fn=PHSBERT, inputs="text", outputs="text")
30
+
31
+ vs = Parallel(bert_io, mental_io, phs_io,
32
+ examples=examples,
33
+ title=title,
34
+ description=desc,
35
+ theme="peach")
36
+
37
+ def model(text):
38
+ return "Predictions unavailable - to be completed."
39
+
40
+ hm = Interface(fn=model, inputs="text", outputs="text")
41
+
42
+ interfaces = [vs, hm]
43
+ interface_names = ["Vaccine Sentiment Task", "Health Mention Task"]
44
+
45
+ TabbedInterface(interfaces, interface_names).launch()