prithivMLmods commited on
Commit
edcc548
·
verified ·
1 Parent(s): 091188a

update app

Browse files
Files changed (1) hide show
  1. deepseek_ocr_2_unlimited_ocr.py +0 -24
deepseek_ocr_2_unlimited_ocr.py CHANGED
@@ -88,10 +88,6 @@ print("Determining device...")
88
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
89
  print(f"✅ Using device: {device}")
90
 
91
- # ---------------------------------------------------------------------------
92
- # Model registry — each entry is lazy-loaded on first use and then cached,
93
- # so switching the dropdown doesn't reload a model already resident on GPU.
94
- # ---------------------------------------------------------------------------
95
  DEFAULT_MODEL = "DeepSeek-OCR-2"
96
 
97
  MODEL_REGISTRY = {
@@ -166,26 +162,6 @@ TASK_PROMPTS = {
166
  "Custom": {"prompt": "", "has_grounding": False}
167
  }
168
 
169
- # ---------------------------------------------------------------------------
170
- # Grounding parsing — DeepSeek-OCR-2 and Unlimited-OCR emit boxes in two
171
- # different conventions even though both inherit DeepSeek-OCR's DeepEncoder
172
- # and 0-999 normalized coordinate grid:
173
- #
174
- # DeepSeek-OCR-2: <|ref|>label<|/ref|><|det|>[[x1,y1,x2,y2], ...]<|/det|>
175
- # (tag pair sits on its own metadata line; recognized
176
- # text for that region follows on subsequent lines)
177
- #
178
- # Unlimited-OCR: <|det|>label [x1, y1, x2, y2]<|/det|>RECOGNIZED TEXT
179
- # (single tag, label + one box inline; the OCR'd text for
180
- # that region follows immediately on the SAME line, so it
181
- # must not be deleted when the tag is stripped)
182
- #
183
- # Both patterns are parsed and normalized to (full_match, label, boxes)
184
- # tuples, where boxes is always a list of [x1, y1, x2, y2] ints. Downstream
185
- # code (draw_bounding_boxes, clean_output) consumes this normalized shape
186
- # regardless of which model produced it.
187
- # ---------------------------------------------------------------------------
188
-
189
  REF_DET_PATTERN = re.compile(r'<\|ref\|>(.*?)<\|/ref\|><\|det\|>(.*?)<\|/det\|>', re.DOTALL)
190
  DET_ONLY_PATTERN = re.compile(
191
  r'<\|det\|>([^\[<]+?)\s*\[\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\]<\|/det\|>',
 
88
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
89
  print(f"✅ Using device: {device}")
90
 
 
 
 
 
91
  DEFAULT_MODEL = "DeepSeek-OCR-2"
92
 
93
  MODEL_REGISTRY = {
 
162
  "Custom": {"prompt": "", "has_grounding": False}
163
  }
164
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
  REF_DET_PATTERN = re.compile(r'<\|ref\|>(.*?)<\|/ref\|><\|det\|>(.*?)<\|/det\|>', re.DOTALL)
166
  DET_ONLY_PATTERN = re.compile(
167
  r'<\|det\|>([^\[<]+?)\s*\[\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\]<\|/det\|>',