mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-12 03:58:22 +08:00
Opt: Avoid importing OCR models on client when UseOcrServer is enable
This commit is contained in:
@@ -99,17 +99,20 @@ def release_resources(next_task=''):
|
||||
# Release all OCR models
|
||||
# Usually to have 2 models loaded and each model takes about 20MB
|
||||
# This will release 20-40MB
|
||||
from module.ocr.ocr import OCR_MODEL
|
||||
if 'Opsi' in next_task or 'commission' in next_task:
|
||||
# OCR models will be used soon, don't release
|
||||
models = []
|
||||
elif next_task:
|
||||
# Release OCR models except 'azur_lane'
|
||||
models = ['cnocr', 'jp', 'tw']
|
||||
else:
|
||||
models = ['azur_lane', 'cnocr', 'jp', 'tw']
|
||||
for model in models:
|
||||
del_cached_property(OCR_MODEL, model)
|
||||
from module.webui.setting import State
|
||||
if not State.deploy_config.UseOcrServer:
|
||||
# Release only when using per-instance OCR
|
||||
from module.ocr.ocr import OCR_MODEL
|
||||
if 'Opsi' in next_task or 'commission' in next_task:
|
||||
# OCR models will be used soon, don't release
|
||||
models = []
|
||||
elif next_task:
|
||||
# Release OCR models except 'azur_lane'
|
||||
models = ['cnocr', 'jp', 'tw']
|
||||
else:
|
||||
models = ['azur_lane', 'cnocr', 'jp', 'tw']
|
||||
for model in models:
|
||||
del_cached_property(OCR_MODEL, model)
|
||||
|
||||
# Release assets cache
|
||||
# module.ui has about 80 assets and takes about 3MB
|
||||
|
||||
Reference in New Issue
Block a user