Would there be any way to make this work with TensorRT?
- User
Would there be any way to make this work with TensorRT?
Assistant
Based on the repository code, mokuro primarily relies on two main components for its OCR pipeline:
- comic-text-detector for text detection
- manga-ocr for OCR
Looking at
manga_page_ocr.py, the system uses PyTorch and currently supports CPU and CUDA execution through theforce_cpuparameter. While there's no direct TensorRT integration in the current codebase, it would theoretically be possible to optimize mokuro with TensorRT through these steps:-
Convert the text detector model to TensorRT format. The TextDetector class in
manga_page_ocr.pywould need to be modified to support TensorRT inference. -
Convert the manga-ocr model (which uses the "kha-white/manga-ocr-base" by default) to TensorRT format.
-
Modify the inference pipeline in
MangaPageOcrclass to use TensorRT runtime instead of pure PyTorch.
However, this would require significant modifications to the codebase and careful validation since:
- You'd need to ensure TensorRT supports all the operations used in both models
- The pre/post-processing steps would need to be adapted to work with TensorRT tensors
- The performance benefits would need to be weighed against potential loss in accuracy
- Both models would need to be compatible with TensorRT conversion
If you're interested in pursuing this optimization, I'd recommend:
- First profiling the current implementation to identify the main bottlenecks
- Testing TensorRT conversion on each model separately
- Creating a proof of concept with a modified version of
MangaPageOcrthat supports both PyTorch and TensorRT backends
Would you like me to elaborate on any of these aspects?
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.