-
Notifications
You must be signed in to change notification settings - Fork 855
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
模型预加载 #517
Labels
enhancement
New feature or request
Comments
把模型提出来先加载,再传入函数 |
可以通过以下代码预加载模型 def init_model():
from magic_pdf.model.doc_analyze_by_custom_model import ModelSingleton
try:
model_manager = ModelSingleton()
txt_model = model_manager.get_model(False, False)
logger.info(f"txt_model init final")
ocr_model = model_manager.get_model(True, False)
logger.info(f"ocr_model init final")
return 0
except Exception as e:
logger.exception(e)
return -1
model_init = init_model()
logger.info(f"model_init: {model_init}") |
Closed
收到,谢谢大佬们 |
感谢提供的代码,方便了很多。但是在使用过程中我发现如果程序出错或者提前结束的情况下,预载的模型还是会留在显存中不会自己结束进程,需要自己手动杀掉才能释放内存。请问这种情况有解决方式吗? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
在我连续处理多个pdf时,我希望能只用加载一次模型,也就是说需要向用户提供一个api接口,方便用户在合适的时机将模型加载到显存中。
The text was updated successfully, but these errors were encountered: