seawolf2357 commited on
Commit
6b7accd
ยท
verified ยท
1 Parent(s): e29c175

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -10
app.py CHANGED
@@ -40,29 +40,32 @@ def get_latex_from_image_all_formats(image):
40
  result = response.json()
41
  # formats_results ๋ณ€์ˆ˜๋Š” ์‚ฌ์šฉํ•˜์ง€ ์•Š์œผ๋ฏ€๋กœ ์ œ๊ฑฐํ•˜์—ฌ ์ฝ”๋“œ๋ฅผ ๋‹จ์ˆœํ™”
42
  return result
 
43
 
44
  def build_gradio_app(css=css):
45
- with gr.Blocks() as demo:
46
- with gr.Row():
47
- image_input = gr.Image(type="pil", label="์ด๋ฏธ์ง€ ์—…๋กœ๋“œ")
48
- submit_button = gr.Button("๋ณ€ํ™˜ํ•˜๊ธฐ")
 
 
49
 
50
- # ๋‹จ์ผ ์ถœ๋ ฅ์„ ์œ„ํ•ด outputs ๋ถ€๋ถ„์„ ๋‹จ์ˆœํ™”
51
  outputs = gr.Textbox(label="๊ฒฐ๊ณผ")
52
- latex_iframe = gr.HTML(value='<iframe src="https://www.mathjax.org/#demo" style="width: 100%; height: 700px; border: 2px solid #007bff; border-radius: 8px;"></iframe>', elem_id="latex_iframe")
53
-
54
- # ์˜ˆ์ œ ์ด๋ฏธ์ง€๋ฅผ ์ž…๋ ฅ์œผ๋กœ ํ•˜๋Š” Examples ์ปดํฌ๋„ŒํŠธ ์ถ”๊ฐ€
55
- examples = gr.Examples(examples=[["ko.png"], ["en.png"]], inputs=image_input, fn=process_and_output, outputs=outputs)
56
 
57
  def process_and_output(image):
58
  latex_result = get_latex_from_image_all_formats(image)
59
  text_result = latex_result.get("text", "No result")
60
  return text_result
 
 
 
61
 
62
  submit_button.click(fn=process_and_output, inputs=image_input, outputs=outputs)
 
 
63
 
64
  return demo
65
 
66
  if __name__ == "__main__":
67
  app = build_gradio_app()
68
- app.launch()
 
40
  result = response.json()
41
  # formats_results ๋ณ€์ˆ˜๋Š” ์‚ฌ์šฉํ•˜์ง€ ์•Š์œผ๋ฏ€๋กœ ์ œ๊ฑฐํ•˜์—ฌ ์ฝ”๋“œ๋ฅผ ๋‹จ์ˆœํ™”
42
  return result
43
+
44
 
45
  def build_gradio_app(css=css):
46
+ with gr.Blocks(css=css) as demo:
47
+ gr.Markdown("# ArXivGPT LaTeX Tool")
48
+ gr.Markdown("This comprehensive solution encompasses an automated workflow...")
49
+
50
+ image_input = gr.Image(type="pil", label="์ด๋ฏธ์ง€ ์—…๋กœ๋“œ")
51
+ submit_button = gr.Button("๋ณ€ํ™˜ํ•˜๊ธฐ")
52
 
 
53
  outputs = gr.Textbox(label="๊ฒฐ๊ณผ")
 
 
 
 
54
 
55
  def process_and_output(image):
56
  latex_result = get_latex_from_image_all_formats(image)
57
  text_result = latex_result.get("text", "No result")
58
  return text_result
59
+
60
+ # Examples ์ •์˜๋ฅผ process_and_output ํ•จ์ˆ˜ ์ •์˜ ํ›„๋กœ ์˜ฎ๊น๋‹ˆ๋‹ค.
61
+ examples = gr.Examples(examples=[["ko.png"], ["en.png"], ["hand.jpg"]], inputs=image_input, outputs=outputs, fn=process_and_output)
62
 
63
  submit_button.click(fn=process_and_output, inputs=image_input, outputs=outputs)
64
+
65
+ demo.add(examples) # gr.Blocks์— examples ์ปดํฌ๋„ŒํŠธ๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.
66
 
67
  return demo
68
 
69
  if __name__ == "__main__":
70
  app = build_gradio_app()
71
+ app.launch()