LennardZuendorf commited on
Commit
f55975e
1 Parent(s): fe41904

pushing UI updates

Browse files
Files changed (2) hide show
  1. app.py +26 -4
  2. requirements.txt +2 -1
app.py CHANGED
@@ -1,9 +1,31 @@
1
  import gradio as gr
 
2
 
 
3
 
4
- def greet(name):
5
- return "Hello " + name + "!!"
6
 
 
 
 
7
 
8
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
9
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
 
4
+ classifier_pipe = pipeline("text-classification", model="LennardZuendorf/legalis-BERT", top_k=None)
5
 
 
 
6
 
7
+ def predict_fun(text):
8
+ predictions = classifier_pipe(text)
9
+ return {p["label"]: p["score"] for p in predictions[0]}
10
 
11
+
12
+ with gr.Blocks(title='Legalis') as interface:
13
+ with gr.Row():
14
+ gr.Markdown(
15
+ """
16
+ # Legalis BERT Demo
17
+ Start typing below to see the output.
18
+ """)
19
+ with gr.Row():
20
+ with gr.Column():
21
+ input_text = gr.Textbox(label="Case Facts")
22
+ with gr.Row():
23
+ predict = gr.Button("Predict")
24
+ with gr.Column():
25
+ label = gr.Label(label="Predicted Winner")
26
+ with gr.Row():
27
+ interpretation = gr.components.Interpretation(input_text, visible=False)
28
+
29
+ predict.click(predict_fun, input_text, label)
30
+
31
+ interface.launch()
requirements.txt CHANGED
@@ -1 +1,2 @@
1
- gradio
 
 
1
+ gradio
2
+ transformers