Skip to content
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

add:增加pyinstaller打包 #18

Merged
merged 6 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions PPOCRLabel.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,9 @@
QSizePolicy,
)

__dir__ = os.path.dirname(os.path.abspath(__file__))

sys.path.append(__dir__)
sys.path.append(os.path.abspath(os.path.join(__dir__, "../..")))
sys.path.append(os.path.abspath(os.path.join(__dir__, "../PaddleOCR")))
sys.path.append("..")

from paddleocr import PaddleOCR, PPStructure
from libs.resources import *
from libs.constants import *
from libs.utils import *
from libs.labelColor import label_colormap
Expand Down Expand Up @@ -3421,7 +3416,7 @@ def get_main_app(argv=[]):
app.setWindowIcon(newIcon("app"))
# Tzutalin 201705+: Accept extra arguments to change predefined class file
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument("--lang", type=str, default="en", nargs="?")
GreatV marked this conversation as resolved.
Show resolved Hide resolved
arg_parser.add_argument("--lang", type=str, default="ch", nargs="?")
arg_parser.add_argument("--gpu", type=str2bool, default=True, nargs="?")
arg_parser.add_argument("--kie", type=str2bool, default=False, nargs="?")
arg_parser.add_argument(
Expand Down Expand Up @@ -3450,12 +3445,4 @@ def main():


if __name__ == "__main__":
resource_file = "./libs/resources.py"
GreatV marked this conversation as resolved.
Show resolved Hide resolved
if not os.path.exists(resource_file):
output = os.system("pyrcc5 -o libs/resources.py resources.qrc")
assert output == 0, (
"operate the cmd have some problems ,please check whether there is a in the lib "
"directory resources.py "
)

sys.exit(main())
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,21 @@ cd ./PPOCRLabel
pip3 install -e .
```

#### 1.2.4 Pyinstaller build
```bash
cd ./PPOCRLabel
# install pyinstaller
pip install pyinstaller

# Regenerate Resources
pyrcc5 -o libs/resources.py resources.qrc

# Packaging executable programs
pyinstaller -c PPOCRLabel.py --collect-all paddleocr --collect-all pyclipper --collect-all imghdr --collect-all skimage --collect-all imgaug --collect-all scipy.io --collect-all lmdb --collect-all paddle --hidden-import=pyqt5 -p ./libs -p ./ -p ./data -p ./resources -F

# Run the executable program in dist, windows as an example
PPOCRLabel.exe --lang ch
```

## 2. Usage

Expand Down
15 changes: 15 additions & 0 deletions README_ch.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,21 @@ cd ./PPOCRLabel
pip install -e .
```

#### 1.2.4 Pyinstaller打包并运行
```bash
cd ./PPOCRLabel
# 安装pyinstaller
pip install pyinstaller

# 重新生成资源
pyrcc5 -o libs/resources.py resources.qrc

# 打包可执行程序
pyinstaller -c PPOCRLabel.py --collect-all paddleocr --collect-all pyclipper --collect-all imghdr --collect-all skimage --collect-all imgaug --collect-all scipy.io --collect-all lmdb --collect-all paddle --hidden-import=pyqt5 -p ./libs -p ./ -p ./data -p ./resources -F

# 运行dist中的可执行程序,以windows为例
PPOCRLabel.exe --lang ch
```

## 2. 使用

Expand Down
Loading
Loading