linjieccc commited on
Commit
27c87a7
1 Parent(s): d7eb61c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -2
app.py CHANGED
@@ -151,6 +151,18 @@ prompt_files = {
151
  "เบอร์โทรร้านอะไรคะ?": "receipt.png",
152
  }
153
 
 
 
 
 
 
 
 
 
 
 
 
 
154
 
155
  def load_document(path):
156
  if path.startswith("http://") or path.startswith("https://"):
@@ -267,9 +279,10 @@ def process_prompt(prompt, document, lang="ch"):
267
  )
268
 
269
 
270
- def load_example_document(img, prompt, lang="ch"):
271
  if img is not None:
272
  document = prompt_files[prompt]
 
273
  preview, answer, answer_text = process_prompt(prompt, document, lang)
274
  return document, prompt, preview, gr.update(visible=True), answer, answer_text
275
  else:
@@ -493,7 +506,7 @@ with gr.Blocks(css=CSS) as demo:
493
 
494
  example_image.change(
495
  fn=load_example_document,
496
- inputs=[example_image, example_prompt, ocr_lang],
497
  outputs=[document, prompt, image, img_clear_button, output, output_text],
498
  )
499
 
 
151
  "เบอร์โทรร้านอะไรคะ?": "receipt.png",
152
  }
153
 
154
+ lang_map = {
155
+ "invoice.jpg": "ch",
156
+ "resume.png": "ch",
157
+ "custom_declaration_form.png": "ch",
158
+ "medical_bill_1.png": "ch",
159
+ "budget_form.png": "en",
160
+ "website_design_guide.jpeg": "en",
161
+ "poster.png": "en",
162
+ "medical_bill_2.jpg": "ch",
163
+ "receipt.png": "en"
164
+ }
165
+
166
 
167
  def load_document(path):
168
  if path.startswith("http://") or path.startswith("https://"):
 
279
  )
280
 
281
 
282
+ def load_example_document(img, prompt):
283
  if img is not None:
284
  document = prompt_files[prompt]
285
+ lang = lang_map[document]
286
  preview, answer, answer_text = process_prompt(prompt, document, lang)
287
  return document, prompt, preview, gr.update(visible=True), answer, answer_text
288
  else:
 
506
 
507
  example_image.change(
508
  fn=load_example_document,
509
+ inputs=[example_image, example_prompt],
510
  outputs=[document, prompt, image, img_clear_button, output, output_text],
511
  )
512