Spaces:
Runtime error
Runtime error
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() | |