diff --git a/.gitignore b/.gitignore index 85b40c3..ddecaff 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,7 @@ .idea .DS_Store hivision_modnet.onnx -output/*.jpg \ No newline at end of file +output/*.jpg +# build outputs +dist +build diff --git a/app.py b/app.py index 0396cd2..aa24d8e 100644 --- a/app.py +++ b/app.py @@ -1,3 +1,4 @@ +import os import gradio as gr import onnxruntime from src.face_judgement_align import IDphotos_create @@ -226,7 +227,8 @@ def idphoto_inference( if __name__ == "__main__": # 预加载 ONNX 模型 - HY_HUMAN_MATTING_WEIGHTS_PATH = "./hivision_modnet.onnx" + root_dir = os.path.dirname(os.path.abspath(__file__)) + HY_HUMAN_MATTING_WEIGHTS_PATH = os.path.join(root_dir, "hivision_modnet.onnx") sess = onnxruntime.InferenceSession(HY_HUMAN_MATTING_WEIGHTS_PATH) size_mode = ["尺寸列表", "只换底", "自定义尺寸"] @@ -319,7 +321,7 @@ if __name__ == "__main__": components=[img_input], samples=[ [path.as_posix()] - for path in sorted(pathlib.Path("images").rglob("*.jpg")) + for path in sorted(pathlib.Path(os.path.join(root_dir, "images")).rglob("*.jpg")) ], ) diff --git a/app.spec b/app.spec new file mode 100644 index 0000000..0673070 --- /dev/null +++ b/app.spec @@ -0,0 +1,44 @@ +# -*- mode: python ; coding: utf-8 -*- +from PyInstaller.utils.hooks import collect_data_files + +datas = [('hivisionai', 'hivisionai'), ('hivision_modnet.onnx', '.')] +datas += collect_data_files('gradio_client') +datas += collect_data_files('gradio') + + +a = Analysis( + ['app.py'], + pathex=[], + binaries=[], + datas=datas, + hiddenimports=[], + hookspath=[], + hooksconfig={}, + runtime_hooks=[], + excludes=[], + noarchive=False, + optimize=0, +) +pyz = PYZ(a.pure) + +exe = EXE( + pyz, + a.scripts, + a.binaries, + a.datas, + [], + name='HivisionIDPhotos', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=True, + disable_windowed_traceback=False, + argv_emulation=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None, + icon=['assets\hivisionai.ico'], +) diff --git a/assets/hivisionai.ico b/assets/hivisionai.ico new file mode 100644 index 0000000..3a27d0e Binary files /dev/null and b/assets/hivisionai.ico differ