Spaces:
Runtime error
Runtime error
import ktrain | |
import gradio as gr | |
from gradio import Parallel, Blocks | |
from gradio import TabbedInterfaces | |
""" | |
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"]] | |
title = "Vaccine Sentiment Task - VS2" | |
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)." | |
predictor_bert = ktrain.load_predictor('bert') | |
predictor_mental = ktrain.load_predictor('mentalbert') | |
predictor_phs = ktrain.load_predictor('phsbert') | |
def BERT(text): | |
results = predictor_bert.predict(str(text)) | |
return str(results) | |
def MentalBERT(text): | |
results = predictor_mental.predict(str(text)) | |
return str(results) | |
def PHSBERT(text): | |
results = predictor_phs.predict(str(text)) | |
return str(results) | |
bert_io = gr.Interface(fn=BERT, inputs="text", outputs="text") | |
mental_io = gr.Interface(fn=MentalBERT, inputs="text", outputs="text") | |
phs_io = gr.Interface(fn=PHSBERT, inputs="text", outputs="text") | |
vs = Parallel(bert_io, mental_io, phs_io, | |
examples=examples, | |
title=title, | |
description=desc, | |
theme="peach") | |
def model(text): | |
return "Predictions unavailable - to be completed." | |
# hm = gr.Interface(fn=model, inputs="text", outputs="text") | |
# interfaces = [vs, hm] | |
# interface_names = ["Vaccine Sentiment Task", "Health Mention Task"] | |
# TabbedInterface(interfaces, interface_names).launch() | |
""" |