Skip to content

Commit aa42016

Browse files
authored
Add pyinstaller packaging (#18)
* upgrade: Update code to resolve pyinstaller packaging issues according to labelimg * upgrade: Write related tutorials and update resources based on labelimg packaging script * format: Modify code format according to specifications * format: Format and modify code according to black style requirements * format: Format and modify code according to black style requirements
1 parent bfa0d59 commit aa42016

File tree

5 files changed

+10778
-10738
lines changed

5 files changed

+10778
-10738
lines changed

PPOCRLabel.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,9 @@
6262
QSizePolicy,
6363
)
6464

65-
__dir__ = os.path.dirname(os.path.abspath(__file__))
66-
67-
sys.path.append(__dir__)
68-
sys.path.append(os.path.abspath(os.path.join(__dir__, "../..")))
69-
sys.path.append(os.path.abspath(os.path.join(__dir__, "../PaddleOCR")))
70-
sys.path.append("..")
7165

7266
from paddleocr import PaddleOCR, PPStructure
67+
from libs.resources import *
7368
from libs.constants import *
7469
from libs.utils import *
7570
from libs.labelColor import label_colormap
@@ -3421,7 +3416,7 @@ def get_main_app(argv=[]):
34213416
app.setWindowIcon(newIcon("app"))
34223417
# Tzutalin 201705+: Accept extra arguments to change predefined class file
34233418
arg_parser = argparse.ArgumentParser()
3424-
arg_parser.add_argument("--lang", type=str, default="en", nargs="?")
3419+
arg_parser.add_argument("--lang", type=str, default="ch", nargs="?")
34253420
arg_parser.add_argument("--gpu", type=str2bool, default=True, nargs="?")
34263421
arg_parser.add_argument("--kie", type=str2bool, default=False, nargs="?")
34273422
arg_parser.add_argument(
@@ -3450,12 +3445,4 @@ def main():
34503445

34513446

34523447
if __name__ == "__main__":
3453-
resource_file = "./libs/resources.py"
3454-
if not os.path.exists(resource_file):
3455-
output = os.system("pyrcc5 -o libs/resources.py resources.qrc")
3456-
assert output == 0, (
3457-
"operate the cmd have some problems ,please check whether there is a in the lib "
3458-
"directory resources.py "
3459-
)
3460-
34613448
sys.exit(main())

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,21 @@ cd ./PPOCRLabel
106106
pip3 install -e .
107107
```
108108

109+
#### 1.2.4 Pyinstaller build
110+
```bash
111+
cd ./PPOCRLabel
112+
# install pyinstaller
113+
pip install pyinstaller
114+
115+
# Regenerate Resources
116+
pyrcc5 -o libs/resources.py resources.qrc
117+
118+
# Packaging executable programs
119+
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
120+
121+
# Run the executable program in dist, windows as an example
122+
PPOCRLabel.exe --lang ch
123+
```
109124

110125
## 2. Usage
111126

README_ch.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,21 @@ cd ./PPOCRLabel
103103
pip install -e .
104104
```
105105

106+
#### 1.2.4 Pyinstaller打包并运行
107+
```bash
108+
cd ./PPOCRLabel
109+
# 安装pyinstaller
110+
pip install pyinstaller
111+
112+
# 重新生成资源
113+
pyrcc5 -o libs/resources.py resources.qrc
114+
115+
# 打包可执行程序
116+
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
117+
118+
# 运行dist中的可执行程序,以windows为例
119+
PPOCRLabel.exe --lang ch
120+
```
106121

107122
## 2. 使用
108123

0 commit comments

Comments
 (0)