MCPcopy Create free account
hub / github.com/Topdu/OpenOCR / __call__

Method __call__

openocr.py:193–243  ·  view source on GitHub ↗

Execute the task with appropriate parameters. For 'det' task: Args: image_path: Path to image or directory return_mask: Whether to return detection mask For 'rec' task: Args: image_path: Path to image

(self, *args, **kwargs)

Source from the content-addressed store, hash-verified

191 self.model = OpenDocONNX(**kwargs)
192
193 def __call__(self, *args, **kwargs):
194 """
195 Execute the task with appropriate parameters.
196
197 For 'det' task:
198 Args:
199 image_path: Path to image or directory
200 return_mask: Whether to return detection mask
201
202 For 'rec' task:
203 Args:
204 image_path: Path to image or directory
205 batch_num: Batch size for recognition
206
207 For 'ocr' task:
208 Args:
209 image_path: Path to image or directory
210 is_visualize: Whether to visualize results
211 rec_batch_num: Batch size for recognition
212 crop_infer: Whether to use crop inference
213 return_mask: Whether to return detection mask
214
215 For 'unirec' task:
216 Args:
217 image_path: Path to image or PDF file
218 max_length: Maximum generation length
219
220 For 'doc' task:
221 Args:
222 image_path: Path to image or PDF file
223 layout_threshold: Layout detection threshold
224 max_length: Maximum generation length
225 merge_layout_blocks: Whether to merge layout blocks
226
227 Returns:
228 Task-specific results
229 """
230 if self.model is None:
231 raise RuntimeError('Model not initialized')
232
233 # Dispatch to appropriate task
234 if self.task == 'det':
235 return self._call_det(*args, **kwargs)
236 elif self.task == 'rec':
237 return self._call_rec(*args, **kwargs)
238 elif self.task == 'ocr':
239 return self._call_ocr(*args, **kwargs)
240 elif self.task == 'unirec':
241 return self._call_unirec(*args, **kwargs)
242 elif self.task == 'doc':
243 return self._call_doc(*args, **kwargs)
244
245 def _call_det(self, image_path=None, **kwargs):
246 """Call detection task"""

Callers

nothing calls this directly

Calls 5

_call_detMethod · 0.95
_call_recMethod · 0.95
_call_ocrMethod · 0.95
_call_unirecMethod · 0.95
_call_docMethod · 0.95

Tested by

no test coverage detected