Add automatic online download

master
tunm 2 years ago
parent 58ad4ef736
commit 554a25edaa

@ -2,6 +2,7 @@
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/HyperLPR.iml" filepath="$PROJECT_DIR$/.idea/HyperLPR.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/ZephyrLPR.iml" filepath="$PROJECT_DIR$/.idea/ZephyrLPR.iml" />
</modules>
</component>

@ -7,23 +7,17 @@
</component>
<component name="CMakeSettings">
<configurations>
<configuration PROFILE_NAME="Debug" ENABLED="true" CONFIG_NAME="Debug" />
<configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" ENABLED="true" />
</configurations>
</component>
<component name="ChangeListManager">
<list default="true" id="4be586f9-7a61-4585-994f-eaa32375497d" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/CMakeLists.txt" beforeDir="false" afterPath="$PROJECT_DIR$/CMakeLists.txt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Prj-Android/app/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/Prj-Android/app/build.gradle" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Prj-Android/app/release/app-release.apk" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Prj-Android/app/release/output-metadata.json" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Prj-Android/app/src/main/java/com/hyperai/hyperlpr_sdk_demo/MainActivity.java" beforeDir="false" afterPath="$PROJECT_DIR$/Prj-Android/app/src/main/java/com/hyperai/hyperlpr_sdk_demo/MainActivity.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Prj-Android/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/Prj-Android/build.gradle" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/modules.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Prj-Python/hyperlpr3/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/Prj-Python/hyperlpr3/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Prj-Python/hyperlpr3/config/configuration.py" beforeDir="false" afterPath="$PROJECT_DIR$/Prj-Python/hyperlpr3/config/configuration.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Prj-Python/hyperlpr3/config/settings.py" beforeDir="false" afterPath="$PROJECT_DIR$/Prj-Python/hyperlpr3/config/settings.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Prj-Python/hyperlpr3/inference/multitask_detect.py" beforeDir="false" afterPath="$PROJECT_DIR$/Prj-Python/hyperlpr3/inference/multitask_detect.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Prj-Python/hyperlpr3/inference/pipeline.py" beforeDir="false" afterPath="$PROJECT_DIR$/Prj-Python/hyperlpr3/inference/pipeline.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Prj-Python/hyperlpr3/inference/recognition.py" beforeDir="false" afterPath="$PROJECT_DIR$/Prj-Python/hyperlpr3/inference/recognition.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cpp/src/context_module/hyper_lpr_context.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/cpp/src/context_module/hyper_lpr_context.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resource/models/r2_mobile/rpv3_mdict_160_r3.mnn" beforeDir="false" afterPath="$PROJECT_DIR$/resource/models/r2_mobile/rpv3_mdict_160_r3.mnn" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Prj-Python/setup.py" beforeDir="false" afterPath="$PROJECT_DIR$/Prj-Python/setup.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -70,17 +64,17 @@
<property name="cf.first.check.clang-format" value="false" />
<property name="cidr.known.project.marker" value="true" />
<property name="cmake.loaded.for.project" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/resource/models/r2_mobile" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/resource/models" />
<property name="nodejs_package_manager_path" value="npm" />
<property name="settings.editor.selected.configurable" value="com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable" />
</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/resource/models" />
<recent name="$PROJECT_DIR$/resource/models/r2_mobile" />
<recent name="$PROJECT_DIR$/command" />
<recent name="$PROJECT_DIR$/cpp/samples" />
<recent name="$PROJECT_DIR$/tools/rknn_export_repo" />
<recent name="$PROJECT_DIR$/resource/images" />
</key>
<key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/Prj-Python" />
@ -91,11 +85,6 @@
</key>
</component>
<component name="RunManager">
<configuration default="true" type="CLionExternalRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" PASS_PARENT_ENVS_2="true">
<method v="2">
<option name="CLION.EXTERNAL.BUILD" enabled="true" />
</method>
</configuration>
<configuration default="true" type="CMakeRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" PASS_PARENT_ENVS_2="true">
<method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
@ -106,6 +95,11 @@
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>
</configuration>
<configuration default="true" type="GradleAppRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" PASS_PARENT_ENVS_2="true">
<method v="2">
<option name="com.jetbrains.cidr.cpp.gradle.execution.GradleNativeBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>
</configuration>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
@ -131,6 +125,7 @@
<workItem from="1677218101830" duration="1207000" />
<workItem from="1677220611638" duration="33000" />
<workItem from="1677457111481" duration="10241000" />
<workItem from="1677496149958" duration="3480000" />
</task>
<servers />
</component>

@ -2,8 +2,6 @@ from .hyperlpr3 import LicensePlateCatcher
from .common.typedef import *
from .config.configuration import initialization
initialization()
__version__ = "0.1.2"
initialization()

@ -2,7 +2,22 @@ import requests
from tqdm import tqdm
import zipfile
import os
from .settings import _DEFAULT_FOLDER_, _MODEL_VERSION_, _ONLINE_URL_
from .settings import _DEFAULT_FOLDER_, _MODEL_VERSION_, _ONLINE_URL_, _REMOTE_URL_, onnx_model_maps, onnx_runtime_config
def down_model_file(url, save_path):
resp = requests.get(url, stream=True)
total = int(resp.headers.get('content-length', 0))
with open(save_path, '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)
def down_model_zip(url, save_path, is_unzip=False):
@ -10,7 +25,7 @@ def down_model_zip(url, save_path, is_unzip=False):
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",
desc="Pull",
total=total,
unit='iB',
unit_scale=True,
@ -28,9 +43,16 @@ def down_model_zip(url, save_path, is_unzip=False):
def initialization(re_download=False):
os.makedirs(_DEFAULT_FOLDER_, exist_ok=True)
models_dir = os.path.join(_DEFAULT_FOLDER_, _MODEL_VERSION_)
models_dir = os.path.join(_DEFAULT_FOLDER_, _MODEL_VERSION_, "onnx")
os.makedirs(models_dir, exist_ok=True)
for model_key in onnx_model_maps:
save_path = onnx_runtime_config[model_key]
basename = os.path.basename(save_path)
remote_url = os.path.join(_REMOTE_URL_, basename + "?raw=true")
down_path = os.path.join(models_dir, basename)
if not os.path.exists(down_path) or re_download:
down_model_file(remote_url, down_path)
# 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)
# 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)

@ -1,7 +1,7 @@
import os
import sys
_MODEL_VERSION_ = "20230228"
_MODEL_VERSION_ = "20230229"
if 'win32' in sys.platform:
_DEFAULT_FOLDER_ = os.path.join(os.environ['HOMEPATH'], ".hyperlpr3")
@ -17,3 +17,6 @@ onnx_runtime_config = dict(
cls_model_path=os.path.join(_MODEL_VERSION_, "onnx", "litemodel_cls_96x_r1.onnx"),
)
onnx_model_maps = ["det_model_path_320x", "det_model_path_640x", "rec_model_path", "cls_model_path"]
_REMOTE_URL_ = "https://github.com/szad670401/HyperLPR/blob/master/resource/models/onnx/"

@ -1,7 +1,8 @@
# !/usr/bin/env python
from setuptools import find_packages, setup
from hyperlpr3 import __version__ as lpr3_ver
__version__ = "0.1.1"
__version__ = lpr3_ver
if __name__ == "__main__":
setup(

Loading…
Cancel
Save