Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -105,22 +105,49 @@ with gr.Blocks(title="GLiNER-base") as demo:
|
|
105 |
value=examples[0][1],
|
106 |
label="Labels",
|
107 |
placeholder="Enter your labels here (comma separated)",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
scale=1,
|
109 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
output = gr.HighlightedText(label="Predicted Entities")
|
111 |
submit_btn = gr.Button("Submit")
|
112 |
examples = gr.Examples(
|
113 |
examples,
|
114 |
fn=ner,
|
115 |
-
inputs=[input_text, labels],
|
116 |
outputs=output,
|
117 |
cache_examples=True,
|
118 |
)
|
119 |
|
120 |
# Submitting
|
121 |
-
input_text.submit(
|
122 |
-
|
123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
|
125 |
demo.queue()
|
126 |
demo.launch(debug=True)
|
|
|
105 |
value=examples[0][1],
|
106 |
label="Labels",
|
107 |
placeholder="Enter your labels here (comma separated)",
|
108 |
+
scale=2,
|
109 |
+
)
|
110 |
+
threshold = gr.Slider(
|
111 |
+
0,
|
112 |
+
1,
|
113 |
+
value=0.3,
|
114 |
+
step=0.01,
|
115 |
+
label="Threshold",
|
116 |
+
info="Lower the threshold to increase how many entities get predicted.",
|
117 |
scale=1,
|
118 |
)
|
119 |
+
nested_ner = gr.Checkbox(
|
120 |
+
value=examples[0][2],
|
121 |
+
label="Nested NER",
|
122 |
+
info="Allow for nested NER?",
|
123 |
+
scale=0,
|
124 |
+
)
|
125 |
output = gr.HighlightedText(label="Predicted Entities")
|
126 |
submit_btn = gr.Button("Submit")
|
127 |
examples = gr.Examples(
|
128 |
examples,
|
129 |
fn=ner,
|
130 |
+
inputs=[input_text, labels, threshold, nested_ner],
|
131 |
outputs=output,
|
132 |
cache_examples=True,
|
133 |
)
|
134 |
|
135 |
# Submitting
|
136 |
+
input_text.submit(
|
137 |
+
fn=ner, inputs=[input_text, labels, threshold, nested_ner], outputs=output
|
138 |
+
)
|
139 |
+
labels.submit(
|
140 |
+
fn=ner, inputs=[input_text, labels, threshold, nested_ner], outputs=output
|
141 |
+
)
|
142 |
+
threshold.release(
|
143 |
+
fn=ner, inputs=[input_text, labels, threshold, nested_ner], outputs=output
|
144 |
+
)
|
145 |
+
submit_btn.click(
|
146 |
+
fn=ner, inputs=[input_text, labels, threshold, nested_ner], outputs=output
|
147 |
+
)
|
148 |
+
nested_ner.change(
|
149 |
+
fn=ner, inputs=[input_text, labels, threshold, nested_ner], outputs=output
|
150 |
+
)
|
151 |
|
152 |
demo.queue()
|
153 |
demo.launch(debug=True)
|