LLDDWW commited on
Commit
0e757ea
ยท
1 Parent(s): 6d9d526

feat: surface raw ocr text

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -329,6 +329,7 @@ def run_pipeline(image: Optional[Image.Image]):
329
  None,
330
  "์ด๋ฏธ์ง€๋ฅผ ๋จผ์ € ์—…๋กœ๋“œํ•ด ์ฃผ์„ธ์š”.",
331
  "๐Ÿ“ท ์•ฝ ๋ด‰ํˆฌ ์‚ฌ์ง„์„ ์˜ฌ๋ฆฌ๋ฉด ์ธ์‹์ด ์‹œ์ž‘๋ผ์š”.",
 
332
  )
333
 
334
  output = ocr_and_parse(image)
@@ -337,7 +338,7 @@ def run_pipeline(image: Optional[Image.Image]):
337
  json_text = json.dumps(output, ensure_ascii=False, indent=2)
338
  explanations = build_explanations(output)
339
  warnings_md = format_warnings(output.get("warnings", []))
340
- return json_text, card, csv_row, explanations, warnings_md
341
 
342
 
343
  CUSTOM_CSS = """
@@ -383,6 +384,7 @@ with gr.Blocks(theme=gr.themes.Soft(), css=CUSTOM_CSS) as demo:
383
  with gr.Column(scale=6, elem_classes=["glass-panel"]):
384
  gr.Markdown("### 2. ๊ฒฐ๊ณผ๋ฅผ ํ™•์ธํ•˜์„ธ์š”")
385
  explain_md = gr.Markdown("์—ฌ๊ธฐ์— ์•ฝ ์„ค๋ช…์ด ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค.", elem_classes=["output-card"])
 
386
  card_out = gr.Image(type="pil", label="์ผ์ • ์นด๋“œ(๋ฏธ๋ฆฌ๋ณด๊ธฐ)")
387
  csv_box = gr.Textbox(label="CSV(์•ฝ๋ช…,1ํšŒ์šฉ๋Ÿ‰,1์ผํšŸ์ˆ˜,์‹œ๊ฐ„๋Œ€)", lines=2, elem_classes=["csv-box"])
388
  with gr.Accordion("์„ธ๋ถ€ JSON ๊ฒฐ๊ณผ", open=False, elem_classes=["accordion"]):
@@ -391,7 +393,7 @@ with gr.Blocks(theme=gr.themes.Soft(), css=CUSTOM_CSS) as demo:
391
  btn.click(
392
  run_pipeline,
393
  inputs=img_in,
394
- outputs=[json_out, card_out, csv_box, explain_md, warn_md],
395
  )
396
 
397
  gr.Markdown(
 
329
  None,
330
  "์ด๋ฏธ์ง€๋ฅผ ๋จผ์ € ์—…๋กœ๋“œํ•ด ์ฃผ์„ธ์š”.",
331
  "๐Ÿ“ท ์•ฝ ๋ด‰ํˆฌ ์‚ฌ์ง„์„ ์˜ฌ๋ฆฌ๋ฉด ์ธ์‹์ด ์‹œ์ž‘๋ผ์š”.",
332
+ "",
333
  )
334
 
335
  output = ocr_and_parse(image)
 
338
  json_text = json.dumps(output, ensure_ascii=False, indent=2)
339
  explanations = build_explanations(output)
340
  warnings_md = format_warnings(output.get("warnings", []))
341
+ return json_text, card, csv_row, explanations, warnings_md, output.get("raw_text", "")
342
 
343
 
344
  CUSTOM_CSS = """
 
384
  with gr.Column(scale=6, elem_classes=["glass-panel"]):
385
  gr.Markdown("### 2. ๊ฒฐ๊ณผ๋ฅผ ํ™•์ธํ•˜์„ธ์š”")
386
  explain_md = gr.Markdown("์—ฌ๊ธฐ์— ์•ฝ ์„ค๋ช…์ด ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค.", elem_classes=["output-card"])
387
+ raw_box = gr.Textbox(label="OCR ์›๋ฌธ ํ…์ŠคํŠธ", lines=5, interactive=False)
388
  card_out = gr.Image(type="pil", label="์ผ์ • ์นด๋“œ(๋ฏธ๋ฆฌ๋ณด๊ธฐ)")
389
  csv_box = gr.Textbox(label="CSV(์•ฝ๋ช…,1ํšŒ์šฉ๋Ÿ‰,1์ผํšŸ์ˆ˜,์‹œ๊ฐ„๋Œ€)", lines=2, elem_classes=["csv-box"])
390
  with gr.Accordion("์„ธ๋ถ€ JSON ๊ฒฐ๊ณผ", open=False, elem_classes=["accordion"]):
 
393
  btn.click(
394
  run_pipeline,
395
  inputs=img_in,
396
+ outputs=[json_out, card_out, csv_box, explain_md, warn_md, raw_box],
397
  )
398
 
399
  gr.Markdown(