Skip to content

Commit

Permalink
Add pyinstaller packaging (#18)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Gmgge authored Jun 18, 2024
1 parent bfa0d59 commit aa42016
Show file tree
Hide file tree
Showing 5 changed files with 10,778 additions and 10,738 deletions.
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="?")
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"
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

0 comments on commit aa42016

Please sign in to comment.