Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
@@ -1,8 +1,14 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
from utils import *
|
|
|
4 |
|
5 |
pipe = pipeline(model="raminass/scotus-v10", top_k=13, padding=True, truncation=True)
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
max_textboxes = 100
|
8 |
|
@@ -23,9 +29,16 @@ def greet(opinion):
|
|
23 |
)
|
24 |
|
25 |
|
|
|
|
|
|
|
|
|
26 |
with gr.Blocks() as demo:
|
27 |
opinion = gr.Textbox(label="Opinion")
|
28 |
op_level = gr.outputs.Label(num_top_classes=13, label="Overall")
|
|
|
|
|
|
|
29 |
greet_btn = gr.Button("Predict")
|
30 |
textboxes = []
|
31 |
for i in range(max_textboxes):
|
@@ -36,6 +49,8 @@ with gr.Blocks() as demo:
|
|
36 |
textboxes.append(t)
|
37 |
textboxes.append(par_level)
|
38 |
|
|
|
|
|
39 |
greet_btn.click(
|
40 |
fn=greet,
|
41 |
inputs=opinion,
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
from utils import *
|
4 |
+
from datasets import load_dataset
|
5 |
|
6 |
pipe = pipeline(model="raminass/scotus-v10", top_k=13, padding=True, truncation=True)
|
7 |
+
all = load_dataset("raminass/full_opinions_1994_2020")
|
8 |
+
df = pd.DataFrame(all["train"])
|
9 |
+
choices = []
|
10 |
+
for index, row in df[df.category == "per_curiam"].iterrows():
|
11 |
+
choices.append((f"""{row["case_name"]}""", row["text"]))
|
12 |
|
13 |
max_textboxes = 100
|
14 |
|
|
|
29 |
)
|
30 |
|
31 |
|
32 |
+
def set_input(drop):
|
33 |
+
return drop
|
34 |
+
|
35 |
+
|
36 |
with gr.Blocks() as demo:
|
37 |
opinion = gr.Textbox(label="Opinion")
|
38 |
op_level = gr.outputs.Label(num_top_classes=13, label="Overall")
|
39 |
+
|
40 |
+
drop = gr.Dropdown(choices=sorted(choices))
|
41 |
+
|
42 |
greet_btn = gr.Button("Predict")
|
43 |
textboxes = []
|
44 |
for i in range(max_textboxes):
|
|
|
49 |
textboxes.append(t)
|
50 |
textboxes.append(par_level)
|
51 |
|
52 |
+
drop.select(set_input, inputs=drop, outputs=[opinion])
|
53 |
+
|
54 |
greet_btn.click(
|
55 |
fn=greet,
|
56 |
inputs=opinion,
|