SWHL commited on
Commit
06a29a7
Β·
verified Β·
1 Parent(s): 8ed29d8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -15
app.py CHANGED
@@ -8,18 +8,6 @@ from gradio_pdf import PDF
8
 
9
  from rapidocr_pdf import RapidOCRPDF
10
 
11
- custom_css = """
12
- body {font-family: body {font-family: 'Helvetica Neue', Helvetica;}
13
- .gr-button {background-color: #4CAF50; color: white; border: none; padding: 10px 20px; border-radius: 5px;}
14
- .gr-button:hover {background-color: #45a049;}
15
- .gr-textbox {margin-bottom: 15px;}
16
- .example-button {background-color: #1E90FF; color: white; border: none; padding: 8px 15px; border-radius: 5px; margin: 5px;}
17
- .example-button:hover {background-color: #FF4500;}
18
- .tall-radio .gr-radio-item {padding: 15px 0; min-height: 50px; display: flex; align-items: center;}
19
- .tall-radio label {font-size: 16px;}
20
- .output-image, .input-image, .image-preview {height: 300px !important}
21
- """
22
-
23
  pdf_extracter = RapidOCRPDF()
24
 
25
 
@@ -27,9 +15,7 @@ def get_pdf_result(pdf_path: str, page_num: int = 0):
27
  return pdf_extracter(pdf_path, page_num_list=[page_num])
28
 
29
 
30
- with gr.Blocks(
31
- title="RapidOCR πŸ“„ PDF", css="custom_css", theme=gr.themes.Soft()
32
- ) as demo:
33
  gr.Markdown(
34
  "<h1 style='text-align: center;'><a href='https://github.com/RapidAI/RapidOCRPDF' style='text-decoration: none;'>RapidOCR πŸ“„ PDF</a></h1>"
35
  )
@@ -59,6 +45,18 @@ with gr.Blocks(
59
  )
60
  btn.click(get_pdf_result, inputs=[pdf_path, page_num], outputs=[results])
61
 
 
 
 
 
 
 
 
 
 
 
 
 
62
 
63
  if __name__ == "__main__":
64
  demo.launch()
 
8
 
9
  from rapidocr_pdf import RapidOCRPDF
10
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  pdf_extracter = RapidOCRPDF()
12
 
13
 
 
15
  return pdf_extracter(pdf_path, page_num_list=[page_num])
16
 
17
 
18
+ with gr.Blocks(title="RapidOCR πŸ“„ PDF", theme=gr.themes.Soft()) as demo:
 
 
19
  gr.Markdown(
20
  "<h1 style='text-align: center;'><a href='https://github.com/RapidAI/RapidOCRPDF' style='text-decoration: none;'>RapidOCR πŸ“„ PDF</a></h1>"
21
  )
 
45
  )
46
  btn.click(get_pdf_result, inputs=[pdf_path, page_num], outputs=[results])
47
 
48
+ examples = gr.Examples(
49
+ examples=[
50
+ ["./files/direct_and_image.pdf", 0],
51
+ ["./files/direct_extract.pdf", 0],
52
+ ],
53
+ examples_per_page=5,
54
+ inputs=[pdf_path, page_num],
55
+ fn=get_pdf_result,
56
+ outputs=[results],
57
+ cache_examples=False,
58
+ )
59
+
60
 
61
  if __name__ == "__main__":
62
  demo.launch()