Spaces:
Runtime error
Runtime error
File size: 4,350 Bytes
37751e8 3048647 ed4d1bb 37751e8 d21c450 4de6981 3048647 ed4d1bb 37751e8 ed4d1bb ac955e7 37751e8 ed4d1bb a9828c4 ac955e7 37751e8 ed4d1bb ac955e7 37751e8 ed4d1bb 37751e8 ed4d1bb d21c450 4de6981 d21c450 ac955e7 d21c450 ac955e7 d21c450 ac955e7 d21c450 37751e8 ac955e7 37751e8 ac955e7 37751e8 ac955e7 d6e50e0 ac955e7 37751e8 ed4d1bb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
import ktrain
from gradio import Interface, Parallel, TabbedInterface
vs_examples = [
["I only get my kids the ones I got....I've turned down many so called 'vaccines'"],
["In child protective services, further providing for definitions, for immunity from liability"],
["Lol what? Measles is a real thing. Get vaccinated"]]
vs_title = "Vaccine Sentiment Task"
vs_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 more details, please refer to the VS2 dataset description in our paper (link provided in the corresponding Hugging Face repository)."
vs_predictor_bert = ktrain.load_predictor('vs/bert')
vs_predictor_mental = ktrain.load_predictor('vs/mentalbert')
vs_predictor_phs = ktrain.load_predictor('vs/phsbert')
def vs_BERT(text):
results = vs_predictor_bert.predict(str(text))
return "BERT:" + str(results)
def vs_MentalBERT(text):
results = vs_predictor_mental.predict(str(text))
return "MentalBERT:" + str(results)
def vs_PHSBERT(text):
results = vs_predictor_phs.predict(str(text))
return "PHS-BERT:" + str(results)
vs_bert_io = Interface(fn=vs_BERT, inputs="text", outputs="text")
vs_mental_io = Interface(fn=vs_MentalBERT, inputs="text", outputs="text")
vs_phs_io = Interface(fn=vs_PHSBERT, inputs="text", outputs="text")
vs = Parallel(vs_bert_io, vs_mental_io, vs_phs_io,
examples=vs_examples,
title=vs_title,
description=vs_desc)
hm_examples = [
["Serious as a heart attack question/thought Riddle me this. Why, oh why, does cold brew coffee get warm after sitting to long. Taste terrible. And Hot coffee get literally COLD after sitting too long. Tastes terrible. Like what. Why don't cold stay cold and hot only get warm?"],
["It's odd how humans are considered predators when they have a heart attack and run like mad when a small insect is running straight towards them."],
["The older we get the less likely we are to view a sudden massive heart attack as a tragedy than a stroke of good luck."]]
hm_title = "Health Mention Task"
hm_desc = "Enter health-related tweets to generate classification from 3 models (BERT, MentalBERT, PHS-BERT). Label 0='Figurative Mentions', 1='Non-Health Mentions', 2='Health mentions'. The three provided examples have true labels 0,1,2 respectively. For more details, please refer to the RHMD dataset description in our paper (link provided in the corresponding Hugging Face repository)."
hm_predictor_bert = ktrain.load_predictor('hm/bert')
hm_predictor_mental = ktrain.load_predictor('hm/mentalbert')
hm_predictor_phs = ktrain.load_predictor('hm/phsbert')
def hm_BERT(text):
results = hm_predictor_bert.predict(str(text))
return "BERT:" + str(results)
def hm_MentalBERT(text):
results = hm_predictor_mental.predict(str(text))
return "MentalBERT" + str(results)
def hm_PHSBERT(text):
results = hm_predictor_phs.predict(str(text))
return "PHS-BERT" + str(results)
hm_bert_io = Interface(fn=hm_BERT, inputs="text", outputs="text")
hm_mental_io = Interface(fn=hm_MentalBERT, inputs="text", outputs="text")
hm_phs_io = Interface(fn=hm_PHSBERT, inputs="text", outputs="text")
hm = Parallel(hm_bert_io, hm_mental_io, hm_phs_io,
examples=hm_examples,
title=hm_title,
description=hm_desc)
dep_title = "Depression Task"
covid_title = "COVID Related Task"
suicide_title = "Suicide Task"
stress_title = "Stress Task"
other_title = "Other Health Related Task"
desc = "Task is currently unavailable."
def model(text):
return "Predictions are currently unavailable."
dep = Interface(fn=model, inputs="text", outputs="text", title=dep_title, description=desc)
covid = Interface(fn=model, inputs="text", outputs="text", title=covid_title, description=desc)
suicide = Interface(fn=model, inputs="text", outputs="text", title=suicide_title, description=desc)
stress = Interface(fn=model, inputs="text", outputs="text", title=stress_title, description=desc)
other = Interface(fn=model, inputs="text", outputs="text", title=other_title, description=desc)
interfaces = [vs, hm, dep, covid, suicide, stress, other]
interface_names = [vs_title, hm_title, dep_title, covid_title, suicide_title, stress_title, other_title]
TabbedInterface(interfaces, interface_names).launch()
|