Spaces:
Runtime error
Runtime error
Commit
·
f870db8
1
Parent(s):
1b8f4a0
Update app.py
Browse files
app.py
CHANGED
@@ -1,67 +0,0 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
# import ktrain
|
5 |
-
# import gradio as gr
|
6 |
-
# from gradio import Blocks, Interface, Parallel, Tabs, TabItem, Markdown
|
7 |
-
# Tabs
|
8 |
-
# gr.Blocks()
|
9 |
-
# gr.Tabs()
|
10 |
-
# gr.TabbedInterface()
|
11 |
-
|
12 |
-
"""
|
13 |
-
from gradio import Blocks, Interface, Parallel, Tabs, TabItem, Markdown, Textbox
|
14 |
-
|
15 |
-
with Blocks() as demo:
|
16 |
-
Markdown("Text")
|
17 |
-
with Tabs():
|
18 |
-
with TabItem("Name 1"):
|
19 |
-
text_input = Textbox()
|
20 |
-
text_output = Textbox()
|
21 |
-
"""
|
22 |
-
|
23 |
-
"""
|
24 |
-
examples = [
|
25 |
-
["I only get my kids the ones I got....I've turned down many so called 'vaccines'"],
|
26 |
-
["In child protective services, further providing for definitions, for immunity from liability"],
|
27 |
-
["Lol what? Measles is a real thing. Get vaccinated"]]
|
28 |
-
title = "Vaccine Sentiment Task - VS2"
|
29 |
-
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)."
|
30 |
-
|
31 |
-
predictor_bert = ktrain.load_predictor('bert')
|
32 |
-
predictor_mental = ktrain.load_predictor('mentalbert')
|
33 |
-
predictor_phs = ktrain.load_predictor('phsbert')
|
34 |
-
|
35 |
-
def BERT(text):
|
36 |
-
results = predictor_bert.predict(str(text))
|
37 |
-
return str(results)
|
38 |
-
|
39 |
-
def MentalBERT(text):
|
40 |
-
results = predictor_mental.predict(str(text))
|
41 |
-
return str(results)
|
42 |
-
|
43 |
-
def PHSBERT(text):
|
44 |
-
results = predictor_phs.predict(str(text))
|
45 |
-
return str(results)
|
46 |
-
|
47 |
-
bert_io = Interface(fn=BERT, inputs="text", outputs="text")
|
48 |
-
mental_io = Interface(fn=MentalBERT, inputs="text", outputs="text")
|
49 |
-
phs_io = Interface(fn=PHSBERT, inputs="text", outputs="text")
|
50 |
-
|
51 |
-
vs = Parallel(bert_io, mental_io, phs_io,
|
52 |
-
examples=examples,
|
53 |
-
title=title,
|
54 |
-
description=desc,
|
55 |
-
theme="peach")
|
56 |
-
|
57 |
-
def model(text):
|
58 |
-
return "Predictions unavailable - to be completed."
|
59 |
-
|
60 |
-
hm = Interface(fn=model, inputs="text", outputs="text")
|
61 |
-
|
62 |
-
# interfaces = [vs, hm]
|
63 |
-
# interface_names = ["Vaccine Sentiment Task", "Health Mention Task"]
|
64 |
-
|
65 |
-
# TabbedInterface(interfaces, interface_names).launch()
|
66 |
-
|
67 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|