staghado commited on
Commit
85c77a6
Β·
verified Β·
1 Parent(s): 0c74f80

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -24,11 +24,11 @@ def image_to_base64(image):
24
  return base64.b64encode(buffered.getvalue()).decode("utf-8")
25
 
26
 
27
- def render_pdf_page(page, max_resolution=1280, scale=2.77):
28
  width, height = page.get_size()
29
  pixel_width = width * scale
30
  pixel_height = height * scale
31
- resize_factor = min(max_resolution / pixel_width, max_resolution / pixel_height)
32
  target_scale = scale * resize_factor
33
  return page.render(scale=target_scale, rev_byteorder=True).to_pil()
34
 
@@ -176,8 +176,7 @@ with gr.Blocks(title="πŸ“– Image/PDF OCR", theme=gr.themes.Soft()) as demo:
176
  # πŸ“– Image/PDF to Text Extraction
177
  **πŸ’‘ How to use:**
178
  1. Upload an image OR a PDF (max 5 pages)
179
- 2. Adjust temperature if needed
180
- 3. Click "Extract Text" to process
181
 
182
  The model will extract and format text from your document.
183
  """
 
24
  return base64.b64encode(buffered.getvalue()).decode("utf-8")
25
 
26
 
27
+ def render_pdf_page(page, max_resolution=1540, scale=2.77):
28
  width, height = page.get_size()
29
  pixel_width = width * scale
30
  pixel_height = height * scale
31
+ resize_factor = min(1, max_resolution / pixel_width, max_resolution / pixel_height)
32
  target_scale = scale * resize_factor
33
  return page.render(scale=target_scale, rev_byteorder=True).to_pil()
34
 
 
176
  # πŸ“– Image/PDF to Text Extraction
177
  **πŸ’‘ How to use:**
178
  1. Upload an image OR a PDF (max 5 pages)
179
+ 2. Click "Extract Text" to process
 
180
 
181
  The model will extract and format text from your document.
182
  """