prithivMLmods commited on
Commit
f64ce2a
·
verified ·
1 Parent(s): 36958a8

update app

Browse files
Files changed (1) hide show
  1. app.py +15 -1
app.py CHANGED
@@ -18,6 +18,7 @@ import cv2
18
  from transformers import (
19
  Qwen2_5_VLForConditionalGeneration,
20
  Qwen3VLForConditionalGeneration,
 
21
  AutoModelForImageTextToText,
22
  AutoModelForCausalLM,
23
  AutoProcessor,
@@ -177,6 +178,16 @@ model_x = Qwen2_5_VLForConditionalGeneration.from_pretrained(
177
  torch_dtype=torch.float16
178
  ).to(device).eval()
179
 
 
 
 
 
 
 
 
 
 
 
180
  # Load Dots.OCR from the local, patched directory
181
  MODEL_PATH_D = "strangervisionhf/dots.ocr-base-fix"
182
  processor_d = AutoProcessor.from_pretrained(MODEL_PATH_D, trust_remote_code=True)
@@ -217,6 +228,9 @@ def generate_image(model_name: str, text: str, image: Image.Image,
217
  elif model_name == "Dots.OCR":
218
  processor = processor_d
219
  model = model_d
 
 
 
220
  else:
221
  yield "Invalid model selected.", "Invalid model selected."
222
  return
@@ -293,7 +307,7 @@ with gr.Blocks(css=css, theme=steel_blue_theme) as demo:
293
  markdown_output = gr.Markdown(label="(Result.Md)")
294
 
295
  model_choice = gr.Radio(
296
- choices=["Nanonets-OCR2-3B", "Chandra-OCR", "Dots.OCR", "olmOCR-2-7B-1025"],
297
  label="Select Model",
298
  value="Nanonets-OCR2-3B"
299
  )
 
18
  from transformers import (
19
  Qwen2_5_VLForConditionalGeneration,
20
  Qwen3VLForConditionalGeneration,
21
+ LightOnOCRForConditionalGeneration,
22
  AutoModelForImageTextToText,
23
  AutoModelForCausalLM,
24
  AutoProcessor,
 
178
  torch_dtype=torch.float16
179
  ).to(device).eval()
180
 
181
+ # Load LightOnOCR
182
+ MODEL_ID_L = "lightonai/LightOnOCR-1B-1025"
183
+ processor_l = AutoProcessor.from_pretrained(MODEL_ID_L, trust_remote_code=True)
184
+ model_l = LightOnOCRForConditionalGeneration.from_pretrained(
185
+ MODEL_ID_L,
186
+ attn_implementation="flash_attention_2",
187
+ trust_remote_code=True,
188
+ torch_dtype=torch.float16
189
+ ).to(device).eval()
190
+
191
  # Load Dots.OCR from the local, patched directory
192
  MODEL_PATH_D = "strangervisionhf/dots.ocr-base-fix"
193
  processor_d = AutoProcessor.from_pretrained(MODEL_PATH_D, trust_remote_code=True)
 
228
  elif model_name == "Dots.OCR":
229
  processor = processor_d
230
  model = model_d
231
+ elif model_name == "LightOnOCR-1B":
232
+ processor = processor_l
233
+ model = model_l
234
  else:
235
  yield "Invalid model selected.", "Invalid model selected."
236
  return
 
307
  markdown_output = gr.Markdown(label="(Result.Md)")
308
 
309
  model_choice = gr.Radio(
310
+ choices=["Nanonets-OCR2-3B", "Chandra-OCR", "Dots.OCR", "LightOnOCR-1B", "olmOCR-2-7B-1025"],
311
  label="Select Model",
312
  value="Nanonets-OCR2-3B"
313
  )