DocUA commited on
Commit
c194733
·
1 Parent(s): f7c3947

feat: Remove temperature parameter and slider, forcing greedy search (temperature=0.0) for OCR processing.

Browse files
Files changed (1) hide show
  1. app.py +5 -11
app.py CHANGED
@@ -53,7 +53,7 @@ def process_pdf(pdf_path, num_pages=1, scale=2.0):
53
  return images, total_pages
54
 
55
 
56
- def process_input(file_input, backend_name, scale, temperature, max_tokens, num_pages):
57
  """Process uploaded file with OCR."""
58
  if file_input is None:
59
  yield "Idle", "Please upload an image or PDF first.", "", "", None
@@ -106,7 +106,8 @@ def process_input(file_input, backend_name, scale, temperature, max_tokens, num_
106
  for i, img in enumerate(images_to_process):
107
  try:
108
  print(f"Processing page {i+1}/{len(images_to_process)}...")
109
- text = backend.process_image(img, temperature=temperature, max_tokens=max_tokens)
 
110
  all_texts.append(text.strip())
111
 
112
  # Update progress
@@ -185,14 +186,7 @@ with gr.Blocks(title="📖 LightOnOCR-1B Demo", theme=gr.themes.Soft()) as demo:
185
  info="Number of pages to process (max 10)"
186
  )
187
 
188
- temperature = gr.Slider(
189
- minimum=0.0,
190
- maximum=1.0,
191
- value=0.1,
192
- step=0.05,
193
- label="Temperature",
194
- info="0 = deterministic"
195
- )
196
 
197
  page_info = gr.Textbox(
198
  label="Processing Info",
@@ -226,7 +220,7 @@ with gr.Blocks(title="📖 LightOnOCR-1B Demo", theme=gr.themes.Soft()) as demo:
226
  # Event handlers
227
  submit_btn.click(
228
  fn=process_input,
229
- inputs=[file_input, backend_selector, scale_slider, temperature, max_tokens_slider, num_pages],
230
  outputs=[status_display, output_text, raw_output, page_info, rendered_image]
231
  )
232
 
 
53
  return images, total_pages
54
 
55
 
56
+ def process_input(file_input, backend_name, scale, max_tokens, num_pages):
57
  """Process uploaded file with OCR."""
58
  if file_input is None:
59
  yield "Idle", "Please upload an image or PDF first.", "", "", None
 
106
  for i, img in enumerate(images_to_process):
107
  try:
108
  print(f"Processing page {i+1}/{len(images_to_process)}...")
109
+ # Force greedy search (temp=0.0)
110
+ text = backend.process_image(img, temperature=0.0, max_tokens=max_tokens)
111
  all_texts.append(text.strip())
112
 
113
  # Update progress
 
186
  info="Number of pages to process (max 10)"
187
  )
188
 
189
+ # Temperature slider removed for stability (Greedy search forced)
 
 
 
 
 
 
 
190
 
191
  page_info = gr.Textbox(
192
  label="Processing Info",
 
220
  # Event handlers
221
  submit_btn.click(
222
  fn=process_input,
223
+ inputs=[file_input, backend_selector, scale_slider, max_tokens_slider, num_pages],
224
  outputs=[status_display, output_text, raw_output, page_info, rendered_image]
225
  )
226