File size: 1,251 Bytes
a980198
a9cf73b
 
 
18fcef9
 
a9cf73b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18fcef9
a9cf73b
 
a96982b
a9cf73b
 
a96982b
fdbe424
a9cf73b
 
 
 
 
 
fdbe424
a9cf73b
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
from components.get_predictions import get_predictions
from gradio.components import Textbox
from gradio.interface import Interface
from gradio.themes import Monochrome


def get_input_fields() -> Textbox:
    """Get Input Fields

    Returns:
        Textbox: Input Field as gradio TextBox
    """
    return Textbox(
        lines=2,
        placeholder="Enter The Text",
        value="",
        label="Text to Predict",
    )


def get_output_fields() -> list[Textbox]:
    """Gets Output Fields

    Returns:
        list[Textbox...]: output fields as gradio textbox
    """

    return [
        Textbox(type="text", label="Aggression Prediction"),
        Textbox(type="text", label="Misogyny Prediction"),
    ]


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__":
    interface = get_interface()

    # Launch the interface
    interface.launch(share=False, debug=True)