sdutta28 commited on
Commit
a9cf73b
1 Parent(s): ea19f9d

Gradio upgraded

Browse files
Files changed (2) hide show
  1. README.md +1 -0
  2. app.py +49 -19
README.md CHANGED
@@ -5,6 +5,7 @@ colorTo: blue
5
  sdk: gradio
6
  app_file: app.py
7
  pinned: false
 
8
  ---
9
 
10
  # Agression and Misogyny Detection App
 
5
  sdk: gradio
6
  app_file: app.py
7
  pinned: false
8
+ python_version: 3.10.5
9
  ---
10
 
11
  # Agression and Misogyny Detection App
app.py CHANGED
@@ -1,27 +1,57 @@
1
  from components.get_predictions import get_predictions
2
- import gradio
 
 
3
 
4
 
5
- if __name__ == "__main__":
6
- interface = gradio.Interface(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  get_predictions,
8
- inputs=gradio.inputs.Textbox(
9
- lines=2,
10
- placeholder="Enter The Text",
11
- default="",
12
- label="Text to Predict",
13
- ),
14
- outputs=[
15
- gradio.outputs.Textbox(type="str", label="Aggression Prediction"),
16
- gradio.outputs.Textbox(type="str", label="Misogyny Prediction"),
17
- ],
18
  title="Aggression and Misogyny Predictor",
19
- theme="dark-huggingface",
20
- live=True,
21
  )
22
 
 
 
 
 
 
 
23
  # Launch the interface
24
- interface.launch(
25
- share=False,
26
- debug=True,
27
- )
 
1
  from components.get_predictions import get_predictions
2
+ from gradio.components import Textbox
3
+ from gradio.interface import Interface
4
+ from gradio.themes import Monochrome
5
 
6
 
7
+ def get_input_fields() -> Textbox:
8
+ """Get Input Fields
9
+
10
+ Returns:
11
+ Textbox: Input Field as gradio TextBox
12
+ """
13
+ return Textbox(
14
+ lines=2,
15
+ placeholder="Enter The Text",
16
+ value="",
17
+ label="Text to Predict",
18
+ )
19
+
20
+
21
+ def get_output_fields() -> list[Textbox]:
22
+ """Gets Output Fields
23
+
24
+ Returns:
25
+ list[Textbox...]: output fields as gradio textbox
26
+ """
27
+
28
+ return [
29
+ Textbox(type="text", label="Aggression Prediction"),
30
+ Textbox(type="text", label="Misogyny Prediction"),
31
+ ]
32
+
33
+
34
+ def get_interface() -> Interface:
35
+ """Gets the Interface with Input and Outputs
36
+
37
+ Returns:
38
+ Interface: gradio interface
39
+ """
40
+
41
+ interface = Interface(
42
  get_predictions,
43
+ inputs=get_input_fields(),
44
+ outputs=get_output_fields(),
 
 
 
 
 
 
 
 
45
  title="Aggression and Misogyny Predictor",
46
+ theme=Monochrome(),
47
+ live=False,
48
  )
49
 
50
+ return interface
51
+
52
+
53
+ if __name__ == "__main__":
54
+ interface = get_interface()
55
+
56
  # Launch the interface
57
+ interface.launch(share=False, debug=True)