更新到HyperLPR3版本
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import requests
|
||||
from tqdm import tqdm
|
||||
import zipfile
|
||||
import os
|
||||
from .settings import _DEFAULT_FOLDER_, _MODEL_VERSION_, _ONLINE_URL_
|
||||
|
||||
|
||||
def down_model_zip(url, save_path, is_unzip=False):
|
||||
resp = requests.get(url, stream=True)
|
||||
total = int(resp.headers.get('content-length', 0))
|
||||
name = os.path.join(save_path, os.path.basename(url))
|
||||
with open(name, 'wb') as file, tqdm(
|
||||
desc="pull",
|
||||
total=total,
|
||||
unit='iB',
|
||||
unit_scale=True,
|
||||
unit_divisor=1024,
|
||||
) as bar:
|
||||
for data in resp.iter_content(chunk_size=1024):
|
||||
size = file.write(data)
|
||||
bar.update(size)
|
||||
|
||||
if is_unzip:
|
||||
f = zipfile.ZipFile(name, "r")
|
||||
for file in f.namelist():
|
||||
f.extract(file, save_path)
|
||||
os.remove(name)
|
||||
|
||||
|
||||
def initialization(re_download=False):
|
||||
os.makedirs(_DEFAULT_FOLDER_, exist_ok=True)
|
||||
models_dir = os.path.join(_DEFAULT_FOLDER_, _MODEL_VERSION_)
|
||||
# print(models_dir)
|
||||
if not os.path.exists(models_dir) or re_download:
|
||||
target_url = os.path.join(_ONLINE_URL_, _MODEL_VERSION_) + '.zip'
|
||||
down_model_zip(target_url, _DEFAULT_FOLDER_, True)
|
||||
@@ -0,0 +1,19 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
_MODEL_VERSION_ = "20230228"
|
||||
|
||||
if 'win32' in sys.platform:
|
||||
_DEFAULT_FOLDER_ = os.path.join(os.environ['HOMEPATH'], ".hyperlpr3")
|
||||
else:
|
||||
_DEFAULT_FOLDER_ = os.path.join(os.environ['HOME'], ".hyperlpr3")
|
||||
|
||||
_ONLINE_URL_ = "https://tunm.oss-cn-hangzhou.aliyuncs.com/hyperlpr3/"
|
||||
|
||||
onnx_runtime_config = dict(
|
||||
det_model_path_320x=os.path.join(_MODEL_VERSION_, "onnx", "y5fu_320x_sim.onnx"),
|
||||
det_model_path_640x=os.path.join(_MODEL_VERSION_, "onnx", "y5fu_640x_sim.onnx"),
|
||||
rec_model_path=os.path.join(_MODEL_VERSION_, "onnx", "rpv3_mdict_160_r3.onnx"),
|
||||
cls_model_path=os.path.join(_MODEL_VERSION_, "onnx", "litemodel_cls_96x_r1.onnx"),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user