Spaces:
Sleeping
Sleeping
File size: 1,519 Bytes
a980198 15c875a a9cf73b 15c875a 18fcef9 a9cf73b 15c875a a9cf73b 15c875a a9cf73b 15c875a a9cf73b 15c875a a9cf73b 18fcef9 a9cf73b a96982b a9cf73b a96982b fdbe424 a9cf73b 15c875a a9cf73b fdbe424 8134c89 |
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 |
from components.get_predictions import get_predictions
from gradio.components import Textbox, IOComponent, Plot
from gradio.interface import Interface
from gradio.themes import Monochrome
from components.utils import initialize
def get_input_fields() -> Textbox:
"""Get Input Fields
Returns:
Textbox: Input Field as gradio TextBox
"""
return Textbox(
lines=10,
placeholder="Enter The Text",
value="",
label="Text to Predict",
)
def get_output_fields() -> list[str | IOComponent]:
"""Gets Output Fields
Returns:
list[str | IOComponent]: output fields as gradio textbox
"""
return [
Textbox(type="text", label="Aggression Prediction"),
Textbox(type="text", label="Misogyny Prediction"),
Plot(label="Explanation of Aggression", scale=1),
Plot(label="Explanation of Misogyny", scale=1),
]
def get_interface() -> Interface:
"""Gets the Interface with Input and Outputs
Returns:
Interface: gradio interface
"""
interface = Interface(
get_predictions,
inputs=get_input_fields(),
outputs=get_output_fields(),
title="Aggression and Misogyny Predictor",
theme=Monochrome(),
live=False,
)
return interface
if __name__ == "__main__":
initialize()
interface = get_interface()
# Launch the interface
interface.launch(
server_name="0.0.0.0",
server_port=7860,
share=False,
)
|