multimodalart HF Staff commited on
Commit
3f7c1da
·
verified ·
1 Parent(s): bde7cc6

Two-column layout (inputs left, outputs right) for each task tab

Browse files
Files changed (1) hide show
  1. app.py +71 -59
app.py CHANGED
@@ -185,23 +185,26 @@ with gr.Blocks(title="GLiNER2.5 Multi — Information Extraction") as demo:
185
  with gr.Tabs():
186
  with gr.Tab("🏷️ Entity Extraction"):
187
  gr.Markdown("Extract named entities with custom labels.")
188
- ner_text = gr.Textbox(
189
- label="Input Text",
190
- placeholder="Enter text to analyze…",
191
- lines=5,
192
- value="Apple CEO Tim Cook announced iPhone 15 in Cupertino yesterday. The event was held at Apple Park.",
193
- )
194
- ner_labels = gr.Textbox(
195
- label="Entity Labels (comma-separated)",
196
- value="company, person, product, location",
197
- placeholder="person, organization, location…",
198
- )
199
- ner_btn = gr.Button("Extract Entities", variant="primary")
200
- ner_output = gr.HighlightedText(
201
- label="Extracted Entities",
202
- combine_adjacent=True,
203
- show_legend=True,
204
- )
 
 
 
205
 
206
  gr.Examples(
207
  examples=[
@@ -218,19 +221,22 @@ with gr.Blocks(title="GLiNER2.5 Multi — Information Extraction") as demo:
218
 
219
  with gr.Tab("📋 Text Classification"):
220
  gr.Markdown("Classify text into custom categories (zero-shot).")
221
- cls_text = gr.Textbox(
222
- label="Input Text",
223
- placeholder="Enter text to classify…",
224
- lines=3,
225
- value="This laptop has amazing performance but terrible battery life!",
226
- )
227
- cls_schema = gr.Textbox(
228
- label="Classification Schema (one task per line: task: label1, label2, …)",
229
- value="sentiment: positive, negative, neutral",
230
- lines=3,
231
- )
232
- cls_btn = gr.Button("Classify Text", variant="primary")
233
- cls_output = gr.Code(label="Result (JSON)", language="json", lines=8)
 
 
 
234
 
235
  gr.Examples(
236
  examples=[
@@ -247,22 +253,25 @@ with gr.Blocks(title="GLiNER2.5 Multi — Information Extraction") as demo:
247
 
248
  with gr.Tab("🔗 Relation Extraction"):
249
  gr.Markdown("Detect relationships between entities in text.")
250
- rel_text = gr.Textbox(
251
- label="Input Text",
252
- placeholder="Enter text to analyze…",
253
- lines=4,
254
- value="Alice works for Acme Corp in Paris. Bob joined Acme last year and lives in London.",
255
- )
256
- rel_labels = gr.Textbox(
257
- label="Relation Labels (comma-separated)",
258
- value="works_for, located_in",
259
- placeholder="works_for, located_in, founded_by…",
260
- )
261
- with gr.Accordion("Options", open=False):
262
- rel_conf = gr.Checkbox(label="Include confidence scores", value=True)
263
- rel_spans = gr.Checkbox(label="Include character spans", value=True)
264
- rel_btn = gr.Button("Extract Relations", variant="primary")
265
- rel_output = gr.Code(label="Result (JSON)", language="json", lines=15)
 
 
 
266
 
267
  gr.Examples(
268
  examples=[
@@ -279,19 +288,22 @@ with gr.Blocks(title="GLiNER2.5 Multi — Information Extraction") as demo:
279
 
280
  with gr.Tab("📦 Structured Data Extraction"):
281
  gr.Markdown("Parse text into structured JSON records with typed fields.")
282
- json_text = gr.Textbox(
283
- label="Input Text",
284
- placeholder="Enter text to extract structured data from…",
285
- lines=4,
286
- value="iPhone 15 Pro Max with 256GB storage, A17 Pro chip, priced at $1199. Available in titanium and black colors.",
287
- )
288
- json_schema = gr.Textbox(
289
- label="Schema (one field per line: field::type::description)",
290
- value="name::str::Full product name and model\nstorage::str::Storage capacity\nprocessor::str::Chip or processor\nprice::str::Product price with currency\ncolors::list::Available color options",
291
- lines=5,
292
- )
293
- json_btn = gr.Button("Extract Structured Data", variant="primary")
294
- json_output = gr.Code(label="Result (JSON)", language="json", lines=12)
 
 
 
295
 
296
  gr.Examples(
297
  examples=[
 
185
  with gr.Tabs():
186
  with gr.Tab("🏷️ Entity Extraction"):
187
  gr.Markdown("Extract named entities with custom labels.")
188
+ with gr.Row():
189
+ with gr.Column():
190
+ ner_text = gr.Textbox(
191
+ label="Input Text",
192
+ placeholder="Enter text to analyze…",
193
+ lines=5,
194
+ value="Apple CEO Tim Cook announced iPhone 15 in Cupertino yesterday. The event was held at Apple Park.",
195
+ )
196
+ ner_labels = gr.Textbox(
197
+ label="Entity Labels (comma-separated)",
198
+ value="company, person, product, location",
199
+ placeholder="person, organization, location…",
200
+ )
201
+ ner_btn = gr.Button("Extract Entities", variant="primary")
202
+ with gr.Column():
203
+ ner_output = gr.HighlightedText(
204
+ label="Extracted Entities",
205
+ combine_adjacent=True,
206
+ show_legend=True,
207
+ )
208
 
209
  gr.Examples(
210
  examples=[
 
221
 
222
  with gr.Tab("📋 Text Classification"):
223
  gr.Markdown("Classify text into custom categories (zero-shot).")
224
+ with gr.Row():
225
+ with gr.Column():
226
+ cls_text = gr.Textbox(
227
+ label="Input Text",
228
+ placeholder="Enter text to classify…",
229
+ lines=3,
230
+ value="This laptop has amazing performance but terrible battery life!",
231
+ )
232
+ cls_schema = gr.Textbox(
233
+ label="Classification Schema (one task per line: task: label1, label2, …)",
234
+ value="sentiment: positive, negative, neutral",
235
+ lines=3,
236
+ )
237
+ cls_btn = gr.Button("Classify Text", variant="primary")
238
+ with gr.Column():
239
+ cls_output = gr.Code(label="Result (JSON)", language="json", lines=8)
240
 
241
  gr.Examples(
242
  examples=[
 
253
 
254
  with gr.Tab("🔗 Relation Extraction"):
255
  gr.Markdown("Detect relationships between entities in text.")
256
+ with gr.Row():
257
+ with gr.Column():
258
+ rel_text = gr.Textbox(
259
+ label="Input Text",
260
+ placeholder="Enter text to analyze…",
261
+ lines=4,
262
+ value="Alice works for Acme Corp in Paris. Bob joined Acme last year and lives in London.",
263
+ )
264
+ rel_labels = gr.Textbox(
265
+ label="Relation Labels (comma-separated)",
266
+ value="works_for, located_in",
267
+ placeholder="works_for, located_in, founded_by…",
268
+ )
269
+ with gr.Accordion("Options", open=False):
270
+ rel_conf = gr.Checkbox(label="Include confidence scores", value=True)
271
+ rel_spans = gr.Checkbox(label="Include character spans", value=True)
272
+ rel_btn = gr.Button("Extract Relations", variant="primary")
273
+ with gr.Column():
274
+ rel_output = gr.Code(label="Result (JSON)", language="json", lines=15)
275
 
276
  gr.Examples(
277
  examples=[
 
288
 
289
  with gr.Tab("📦 Structured Data Extraction"):
290
  gr.Markdown("Parse text into structured JSON records with typed fields.")
291
+ with gr.Row():
292
+ with gr.Column():
293
+ json_text = gr.Textbox(
294
+ label="Input Text",
295
+ placeholder="Enter text to extract structured data from…",
296
+ lines=4,
297
+ value="iPhone 15 Pro Max with 256GB storage, A17 Pro chip, priced at $1199. Available in titanium and black colors.",
298
+ )
299
+ json_schema = gr.Textbox(
300
+ label="Schema (one field per line: field::type::description)",
301
+ value="name::str::Full product name and model\nstorage::str::Storage capacity\nprocessor::str::Chip or processor\nprice::str::Product price with currency\ncolors::list::Available color options",
302
+ lines=5,
303
+ )
304
+ json_btn = gr.Button("Extract Structured Data", variant="primary")
305
+ with gr.Column():
306
+ json_output = gr.Code(label="Result (JSON)", language="json", lines=12)
307
 
308
  gr.Examples(
309
  examples=[