electblake commited on
Commit
86abf9a
·
1 Parent(s): 63f2d65

Update Gradio GPU decorator and template controls

Browse files
Files changed (1) hide show
  1. app/gradio.py +11 -9
app/gradio.py CHANGED
@@ -1,9 +1,10 @@
1
  # ruff: noqa: I001
2
 
 
 
3
  import json
4
  from pathlib import Path
5
 
6
- import spaces
7
  import gradio as gr
8
  import torch
9
  from transformers import AutoModelForImageTextToText, AutoProcessor
@@ -234,7 +235,7 @@ model = (
234
  )
235
 
236
 
237
- @spaces.GPU(duration=120)
238
  def run_nuextract(messages, **chat_template_kwargs):
239
  inputs = processor.apply_chat_template(
240
  messages,
@@ -301,19 +302,20 @@ with gr.Blocks(title="NuMarkApp") as demo:
301
  value="content",
302
  label="Task",
303
  )
 
304
  template_preset = gr.Dropdown(
305
  choices=list(structured_json_templates),
306
  value=default_structured_json_template,
307
  label="JSON template preset",
308
  info="Choose a starting structure, then edit it below.",
309
  )
310
- template = gr.Textbox(
311
- label="Structured JSON template",
312
- value=structured_json_templates[default_structured_json_template],
313
- lines=18,
314
- info="Used for structured extraction. Edit the example to match your document.",
315
- )
316
- enable_thinking = gr.Checkbox(label="Enable thinking")
317
  run = gr.Button("Extract", variant="primary")
318
  with gr.Column(), gr.Tabs():
319
  with gr.Tab("Content"):
 
1
  # ruff: noqa: I001
2
 
3
+ import spaces
4
+
5
  import json
6
  from pathlib import Path
7
 
 
8
  import gradio as gr
9
  import torch
10
  from transformers import AutoModelForImageTextToText, AutoProcessor
 
235
  )
236
 
237
 
238
+ @spaces.GPU
239
  def run_nuextract(messages, **chat_template_kwargs):
240
  inputs = processor.apply_chat_template(
241
  messages,
 
302
  value="content",
303
  label="Task",
304
  )
305
+ enable_thinking = gr.Checkbox(label="Enable thinking")
306
  template_preset = gr.Dropdown(
307
  choices=list(structured_json_templates),
308
  value=default_structured_json_template,
309
  label="JSON template preset",
310
  info="Choose a starting structure, then edit it below.",
311
  )
312
+ with gr.Accordion("Structured JSON template", open=False):
313
+ template = gr.Textbox(
314
+ label="Structured JSON template",
315
+ value=structured_json_templates[default_structured_json_template],
316
+ lines=18,
317
+ info="Used for structured extraction. Edit the example to match your document.",
318
+ )
319
  run = gr.Button("Extract", variant="primary")
320
  with gr.Column(), gr.Tabs():
321
  with gr.Tab("Content"):