electblake commited on
Commit
4d86074
·
verified ·
1 Parent(s): d9eb7f6

Move agent skill download below output

Browse files
Files changed (1) hide show
  1. app.py +22 -67
app.py CHANGED
@@ -1,5 +1,5 @@
1
- from pathlib import Path
2
  import shutil
 
3
 
4
  import gradio as gr
5
 
@@ -208,6 +208,7 @@ structured_json_templates = {
208
 
209
  default_structured_json_template = "Invoice with line items"
210
 
 
211
  def download_agentskill():
212
  return shutil.make_archive(
213
  "extract-image-data",
@@ -222,15 +223,6 @@ with gr.Blocks(title="Image Data Extractor") as demo:
222
  "Extract structured JSON from an image and optional text using "
223
  "[numind/NuExtract3](https://huggingface.co/numind/NuExtract3)."
224
  )
225
- gr.Markdown(
226
- "## Install the agent skill\n"
227
- "Download the ZIP, extract it, and place the `extract-image-data` folder "
228
- "in your project's `.agents/skills/` directory. Agents should read its "
229
- "`SKILL.md` and use it whenever a task requires structured extraction "
230
- "from an image."
231
- )
232
- download_agentskill_button = gr.Button("Download agent skill")
233
- download_agentskill_file = gr.File(label="Agent skill ZIP")
234
  with gr.Row():
235
  with gr.Column():
236
  image = gr.Image(label="Document image", type="pil", height=430)
@@ -263,69 +255,32 @@ with gr.Blocks(title="Image Data Extractor") as demo:
263
  open=True,
264
  show_indices=True,
265
  )
 
 
 
 
 
 
 
 
 
266
 
267
  gr.Examples(
268
  examples=[
269
  [
270
- "Basic receipt",
271
- str(
272
- Path(__file__).parent
273
- / "data"
274
- / "samples"
275
- / "receipt-ocr-original.webp"
276
- ),
277
- "",
278
- False,
279
- ],
280
- [
281
- "Invoice with line items",
282
- str(
283
- Path(__file__).parent
284
- / "data"
285
- / "samples"
286
- / "invoice-with-items.png"
287
- ),
288
- "",
289
- False,
290
- ],
291
- [
292
- "Advanced bank statement",
293
- str(
294
- Path(__file__).parent
295
- / "data"
296
- / "samples"
297
- / "BankStatementChequing.png"
298
- ),
299
  "",
300
  False,
301
- ],
302
- [
303
- "Basic bank statement",
304
- str(
305
- Path(__file__).parent
306
- / "data"
307
- / "samples"
308
- / "bank statement blog image.webp"
309
- ),
310
- "",
311
- False,
312
- ],
313
- *[
314
- [
315
- default_structured_json_template,
316
- str(path),
317
- "",
318
- False,
319
- ]
320
- for path in sorted(
321
- path
322
- for path in (Path(__file__).parent / "data" / "samples").glob(
323
- "*.png"
324
- )
325
- if path.name
326
- not in {"BankStatementChequing.png", "invoice-with-items.png"}
327
- )
328
- ],
329
  ],
330
  inputs=[template_preset, image, text, enable_thinking],
331
  )
 
 
1
  import shutil
2
+ from pathlib import Path
3
 
4
  import gradio as gr
5
 
 
208
 
209
  default_structured_json_template = "Invoice with line items"
210
 
211
+
212
  def download_agentskill():
213
  return shutil.make_archive(
214
  "extract-image-data",
 
223
  "Extract structured JSON from an image and optional text using "
224
  "[numind/NuExtract3](https://huggingface.co/numind/NuExtract3)."
225
  )
 
 
 
 
 
 
 
 
 
226
  with gr.Row():
227
  with gr.Column():
228
  image = gr.Image(label="Document image", type="pil", height=430)
 
255
  open=True,
256
  show_indices=True,
257
  )
258
+ gr.Markdown(
259
+ "## Install the agent skill\n"
260
+ "Download the ZIP, extract it, and place the `extract-image-data` folder "
261
+ "in your project's `.agents/skills/` directory. Agents should read its "
262
+ "`SKILL.md` and use it whenever a task requires structured extraction "
263
+ "from an image."
264
+ )
265
+ download_agentskill_button = gr.Button("Download agent skill")
266
+ download_agentskill_file = gr.File(label="Agent skill ZIP")
267
 
268
  gr.Examples(
269
  examples=[
270
  [
271
+ preset,
272
+ str(Path(__file__).parent / "data" / "samples" / filename),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
273
  "",
274
  False,
275
+ ]
276
+ for preset, filename in [
277
+ ("Basic receipt", "receipt-ocr-original.webp"),
278
+ ("Invoice with line items", "invoice-with-items.png"),
279
+ ("Advanced bank statement", "BankStatementChequing.png"),
280
+ ("Basic bank statement", "bank statement blog image.webp"),
281
+ ("Advanced global record", "tags.png"),
282
+ ("Advanced global record", "task-list.png"),
283
+ ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
284
  ],
285
  inputs=[template_preset, image, text, enable_thinking],
286
  )