Skip to content

Commit fdfd747

Browse files
committed
test splash screen builds for pymatting compilation
1 parent 0863b7b commit fdfd747

File tree

6 files changed

+130
-46
lines changed

6 files changed

+130
-46
lines changed

.github/workflows/build.yaml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,15 @@ jobs:
5050
if: runner.os != 'macOS'
5151
shell: bash
5252
run: |
53-
pyinstaller --clean --onedir --windowed --name "Interactive-BG-Remover" \
54-
--exclude-module torch \
55-
backgroundremoval.py
53+
pyinstaller --clean build_win_linux.spec
5654
mkdir -p dist/Interactive-BG-Remover/Models
5755
mv Models/place_models_here.txt dist/Interactive-BG-Remover/Models/
5856
5957
- name: Build executable (macOS)
6058
if: runner.os == 'macOS'
6159
run: |
62-
# mac has issues with --onedir. cpu only build so may as well use onefile
63-
pyinstaller --clean --onefile --windowed --name "Interactive-BG-Remover" \
64-
--exclude-module torch \
65-
backgroundremoval.py
60+
# mac has issues with --onedir. this is a cpu only build so we can use onefile as it produces smaller binaries than CUDA etc.
61+
pyinstaller --clean build_mac.spec
6662
mkdir -p dist/mac-bundle/Models
6763
mv dist/Interactive-BG-Remover dist/mac-bundle/
6864
cp Models/place_models_here.txt dist/mac-bundle/Models/

backgroundremoval.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
#!/usr/bin/env python3
2+
3+
try:
4+
import pyi_splash # noqa
5+
pyi_splash.update_text("Loading Packages")
6+
except: pass
7+
28
import sys
39
import os
410
import math
@@ -22,9 +28,13 @@
2228
from PIL import Image, ImageOps, ImageDraw, ImageEnhance, ImageGrab, ImageFilter, ImageChops
2329
import onnxruntime as ort
2430

31+
try: pyi_splash.update_text("Loading pymatting (Compiles on first run, approx 1-2 minutes)")
32+
except: pass
2533

2634
from pymatting import estimate_alpha_cf, estimate_foreground_ml
2735

36+
try: pyi_splash.update_text("Loading App Scripts")
37+
except: pass
2838

2939
import src.download_manager as download_manager
3040
from src.ui_widgets import CollapsibleFrame, SynchronisedGraphicsView
@@ -103,12 +113,15 @@ def get_available_ep_options():
103113
AVAILABLE_EPS = get_available_ep_options()
104114

105115

106-
107116
# --- Main Application ---
108117

109118
class BackgroundRemoverGUI(QMainWindow):
110119
def __init__(self, image_paths):
111120
super().__init__()
121+
122+
try: pyi_splash.update_text("App Initialisation")
123+
except: pass
124+
112125
self.image_paths = image_paths if image_paths else []
113126
self.current_image_index = 0
114127
self.setWindowTitle("Interactive Image Background Remover")
@@ -137,7 +150,8 @@ def __init__(self, image_paths):
137150
self.loaded_sam_models = {}
138151
self.loaded_matting_models = {}
139152
self.model_output_mask = None
140-
153+
try: pyi_splash.update_text("Loading UI")
154+
except: pass
141155
self.init_ui()
142156
self.setup_keybindings()
143157

@@ -169,6 +183,11 @@ def __init__(self, image_paths):
169183
self.set_theme(saved_theme)
170184

171185

186+
try: pyi_splash.close()
187+
except: pass
188+
189+
190+
172191
def init_ui(self):
173192
self.setAcceptDrops(True)
174193
main = QWidget(); self.setCentralWidget(main)

build_mac.spec

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# -*- mode: python ; coding: utf-8 -*-
2+
3+
4+
a = Analysis(
5+
['backgroundremoval.py'],
6+
pathex=[],
7+
binaries=[],
8+
datas=[],
9+
hiddenimports=[],
10+
hookspath=[],
11+
hooksconfig={},
12+
runtime_hooks=[],
13+
excludes=['torch'],
14+
noarchive=False,
15+
optimize=0,
16+
)
17+
pyz = PYZ(a.pure)
18+
splash = Splash(
19+
'src/assets/splash.png',
20+
binaries=a.binaries,
21+
datas=a.datas,
22+
text_pos=(10, 30),
23+
text_size=12,
24+
text_color='white',
25+
minify_script=True,
26+
always_on_top=False,
27+
)
28+
29+
exe = EXE(
30+
pyz,
31+
a.scripts,
32+
a.binaries,
33+
a.datas,
34+
splash,
35+
splash.binaries,
36+
[],
37+
name='Interactive-BG-Remover',
38+
debug=False,
39+
bootloader_ignore_signals=False,
40+
strip=False,
41+
upx=True,
42+
upx_exclude=[],
43+
runtime_tmpdir=None,
44+
console=False,
45+
disable_windowed_traceback=False,
46+
argv_emulation=False,
47+
target_arch=None,
48+
codesign_identity=None,
49+
entitlements_file=None,
50+
)

build_win_linux.spec

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# -*- mode: python ; coding: utf-8 -*-
2+
3+
4+
a = Analysis(
5+
['backgroundremoval.py'],
6+
pathex=[],
7+
binaries=[],
8+
datas=[],
9+
hiddenimports=[],
10+
hookspath=[],
11+
hooksconfig={},
12+
runtime_hooks=[],
13+
excludes=['torch'],
14+
noarchive=False,
15+
optimize=0,
16+
)
17+
pyz = PYZ(a.pure)
18+
splash = Splash(
19+
'src/assets/splash.png',
20+
binaries=a.binaries,
21+
datas=a.datas,
22+
text_pos=(10, 30),
23+
text_size=12,
24+
text_color='white',
25+
minify_script=True,
26+
always_on_top=False,
27+
)
28+
29+
exe = EXE(
30+
pyz,
31+
a.scripts,
32+
splash,
33+
[],
34+
exclude_binaries=True,
35+
name='Interactive-BG-Remover-onedir',
36+
debug=False,
37+
bootloader_ignore_signals=False,
38+
strip=False,
39+
upx=True,
40+
console=False,
41+
disable_windowed_traceback=False,
42+
argv_emulation=False,
43+
target_arch=None,
44+
codesign_identity=None,
45+
entitlements_file=None,
46+
)
47+
coll = COLLECT(
48+
exe,
49+
a.binaries,
50+
a.datas,
51+
splash.binaries,
52+
strip=False,
53+
upx=True,
54+
upx_exclude=[],
55+
name='Interactive-BG-Remover',
56+
)

dist/Models/place_models_here.txt

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/assets/splash.png

73.9 KB
Loading

0 commit comments

Comments
 (0)