patharanor commited on
Commit
27124d8
·
1 Parent(s): 66ebefb

fix: app sequence

Browse files
Files changed (1) hide show
  1. app.py +25 -23
app.py CHANGED
@@ -16,33 +16,35 @@ def inference(img) -> pd.DataFrame:
16
  def ask(img, question) -> str:
17
  return layoutlm.answer_the_question(img, question, is_debug=True)
18
 
19
- with gr.Blocks() as demo:
20
-
21
- with gr.Column():
22
- inp_img = gr.Image(type='pil')
23
-
24
- with gr.Row():
25
- inp_img = gr.Image(type='pil')
26
- out = gr.Dataframe(
27
- headers=['Data', 'Value'],
28
- datatype=['str', 'str'],
29
- row_count=8,
30
- col_count=(2, 'fixed'),
31
- interactive=False
32
- )
33
-
34
- txt_custom_question = gr.Textbox(label='Your question')
35
- btn_ask = gr.Button('Ask me')
36
- txt_out_answer = gr.Textbox(label='Answer', interactive=False)
37
-
38
- # event
39
- inp_img.change(inference, inp_img, out)
40
- btn_ask.click(ask, [inp_img, txt_custom_question], txt_out_answer)
41
-
42
  if __name__ == '__main__':
 
43
  try:
44
  layoutlm = LayoutLM()
45
  layoutlm.set_model(layoutlm.default_model)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  demo.launch(auth=auth)
47
  except Exception as e:
48
  print(str(e))
 
16
  def ask(img, question) -> str:
17
  return layoutlm.answer_the_question(img, question, is_debug=True)
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  if __name__ == '__main__':
20
+
21
  try:
22
  layoutlm = LayoutLM()
23
  layoutlm.set_model(layoutlm.default_model)
24
+
25
+ with gr.Blocks() as demo:
26
+
27
+ with gr.Column():
28
+ inp_img = gr.Image(type='pil')
29
+
30
+ with gr.Row():
31
+ inp_img = gr.Image(type='pil')
32
+ out = gr.Dataframe(
33
+ headers=['Data', 'Value'],
34
+ datatype=['str', 'str'],
35
+ row_count=8,
36
+ col_count=(2, 'fixed'),
37
+ interactive=False
38
+ )
39
+
40
+ txt_custom_question = gr.Textbox(label='Your question')
41
+ btn_ask = gr.Button('Ask me')
42
+ txt_out_answer = gr.Textbox(label='Answer', interactive=False)
43
+
44
+ # event
45
+ inp_img.change(inference, inp_img, out)
46
+ btn_ask.click(ask, [inp_img, txt_custom_question], txt_out_answer)
47
+
48
  demo.launch(auth=auth)
49
  except Exception as e:
50
  print(str(e))