feat(model): support MonkeyOCR - #5475
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds support for the MonkeyOCR model, registering it as a built-in OCR engine and adding the necessary third-party model wrapper and image loading utilities. The review feedback highlights several critical issues: a potential runtime crash when forcing FlashAttention-2 on CUDA without checking if the package is installed, inconsistent image preprocessing in single-image inference that could lead to OOM errors, a potential AttributeError if model_spec is None, and a device-matching bug that prevents CUDA cache clearing when specific device indices (e.g., 'cuda:0') are used.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces support for the MonkeyOCR model, adding its specification, registering it as a built-in OCR engine, and implementing its wrapper and custom inference logic. Feedback on the implementation highlights several key improvements: resolving potential runtime crashes on CPU by falling back to torch.float32 instead of torch.float16, adding qwen_vl_utils to the required libraries, safely handling None values for model_path, clearing the CUDA cache prior to single-processing fallbacks to prevent OOM errors, and using the configured max_new_tokens instead of a hardcoded value during single-item inference.
qinxuye
left a comment
There was a problem hiding this comment.
Please also correct the PR title from monkeycor to MonkeyOCR. git diff --check currently reports trailing whitespace throughout the newly vendored custom_model.py; please clean that up as part of the revision.
Support MonkeyOCR.