Spaces:
Runtime error
Runtime error
File size: 2,800 Bytes
47ae8bb 8cc72a8 47ae8bb fe5fc8c 47ae8bb 8045318 fe5fc8c 6973085 86bf09b a317c9c 49c795b d0a1a0a 8ea5273 d2c2419 0d42ce8 6973085 b5eb59d cf82463 73adea4 cf82463 b5eb59d cf82463 0101f9c 90e8d13 cf82463 86bf09b 3aaf0d3 5a90c9c 49c795b 5a90c9c 86bf09b 5a90c9c edb457c 5a90c9c edb457c 8045318 |
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 90 91 92 93 94 95 |
import numpy as np
import gradio as gr
demo = gr.Blocks()
def flip_text(x):
return x[::-1]
def flip_image(x):
return np.fliplr(x)
with demo:
gr.Markdown("Flip text or image files using this demo.")
with gr.Tabs():
with gr.TabItem("Flip Text"):
text_input = gr.Textbox()
text_output = gr.Textbox()
text_button = gr.Button("Flip")
with gr.TabItem("Flip Image"):
with gr.Row():
image_input = gr.Image()
image_output = gr.Image()
image_button = gr.Button("Flip")
text_button.click(flip_text, inputs=text_input, outputs=text_output)
image_button.click(flip_image, inputs=image_input, outputs=image_output)
demo.launch()
# import ktrain
# import gradio as gr
# from gradio import Blocks, Interface, Parallel, Tabs, TabItem, Markdown
# Tabs
# gr.Blocks()
# gr.Tabs()
# gr.TabbedInterface()
"""
from gradio import Blocks, Interface, Parallel, Tabs, TabItem, Markdown, Textbox
with Blocks() as demo:
Markdown("Text")
with Tabs():
with TabItem("Name 1"):
text_input = Textbox()
text_output = Textbox()
"""
"""
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 = Interface(fn=BERT, inputs="text", outputs="text")
mental_io = Interface(fn=MentalBERT, inputs="text", outputs="text")
phs_io = 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 = Interface(fn=model, inputs="text", outputs="text")
# interfaces = [vs, hm]
# interface_names = ["Vaccine Sentiment Task", "Health Mention Task"]
# TabbedInterface(interfaces, interface_names).launch()
""" |