Skip to content

armgit / rembg

Public Imported from GitHub
0

Rembg is a tool to remove images background

fix windows installer

Daniel Gatis3800351a4492
diff --git a/.github/workflows/windows_installer.yml b/.github/workflows/windows_installer.yml
index 9e58c78..9b821d7 100644
--- a/.github/workflows/windows_installer.yml
+++ b/.github/workflows/windows_installer.yml
@@ -13,16 +13,29 @@ jobs:
- uses: actions/checkout@v4
- shell: pwsh
run: ./_build-exe.ps1
- - name: Compile .ISS to .EXE Installer
+ - name: Compile CPU Installer
uses: Minionguyjpro/[email protected]
with:
- path: _setup.iss
+ path: _setup-cpu.iss
options: /O+
- - name: Upload binaries to release
+ - name: Compile GPU Installer
+ uses: Minionguyjpro/[email protected]
+ with:
+ path: _setup-gpu.iss
+ options: /O+
+ - name: Upload CPU installer to release
+ uses: svenstaro/upload-release-action@v2
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: dist/rembg-cli-cpu-installer.exe
+ asset_name: rembg-cli-cpu-installer.exe
+ tag: ${{ github.ref }}
+ overwrite: true
+ - name: Upload GPU installer to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- file: dist/rembg-cli-installer.exe
- asset_name: rembg-cli-installer.exe
+ file: dist/rembg-cli-gpu-installer.exe
+ asset_name: rembg-cli-gpu-installer.exe
tag: ${{ github.ref }}
overwrite: true
diff --git a/_build-exe.ps1 b/_build-exe.ps1
index 0b30210..bb1c41e 100755
--- a/_build-exe.ps1
+++ b/_build-exe.ps1
@@ -3,14 +3,21 @@ if (-not (Get-Command poetry -ErrorAction SilentlyContinue)) {
pip install poetry
}
-# Install project dependencies with cli extras
-poetry install --extras "cli"
+# Install pyinstaller
+pip install pyinstaller
-# Install pyinstaller in the poetry environment
-poetry run pip install pyinstaller
+# Build CPU version
+Write-Host "Building CPU version..." -ForegroundColor Cyan
+poetry install --extras "cli cpu"
+poetry run pyinstaller rembg.spec
+Rename-Item -Path "dist/rembg" -NewName "rembg-cpu"
-# Create PyInstaller spec file with specified data collections
-# poetry run pyi-makespec --collect-data=gradio_client --collect-data=gradio rembg.py
+# Build GPU version
+Write-Host "Building GPU version..." -ForegroundColor Cyan
+poetry install --extras "cli gpu"
+poetry run pyinstaller rembg.spec --noconfirm
+Rename-Item -Path "dist/rembg" -NewName "rembg-gpu"
-# Run PyInstaller with the generated spec file
-poetry run pyinstaller rembg.spec
+Write-Host "Build complete!" -ForegroundColor Green
+Write-Host "CPU version: dist/rembg-cpu"
+Write-Host "GPU version: dist/rembg-gpu"
diff --git a/_setup.iss b/_setup-cpu.iss
similarity index 69%
rename from _setup.iss
rename to _setup-cpu.iss
index 0d85c2e..7785931 100644
--- a/_setup.iss
+++ b/_setup-cpu.iss
@@ -1,4 +1,4 @@
-#define MyAppName "Rembg"
+#define MyAppName "Rembg CPU"
#define MyAppVersion "STABLE"
#define MyAppPublisher "danielgatis"
#define MyAppURL "https://github.com/danielgatis/rembg"
@@ -13,10 +13,10 @@ AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
-DefaultDirName={autopf}\{#MyAppName}
-DefaultGroupName={#MyAppName}
+DefaultDirName={autopf}\Rembg
+DefaultGroupName=Rembg
DisableProgramGroupPage=yes
-OutputBaseFilename=rembg-cli-installer
+OutputBaseFilename=rembg-cli-cpu-installer
Compression=lzma
SolidCompression=yes
WizardStyle=modern
@@ -27,14 +27,14 @@ ChangesEnvironment=yes
Name: "english"; MessagesFile: "compiler:Default.isl"
[Files]
-Source: "{#SourcePath}dist\rembg\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
-Source: "{#SourcePath}dist\rembg\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
+Source: "{#SourcePath}dist\rembg-cpu\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
+Source: "{#SourcePath}dist\rembg-cpu\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
[Tasks]
Name: modifypath; Description: "Add to PATH variable"
[Icons]
-Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
+Name: "{group}\Rembg"; Filename: "{app}\{#MyAppExeName}"
[Code]
const
diff --git a/_setup-gpu.iss b/_setup-gpu.iss
new file mode 100644
index 0000000..fa627fd
--- /dev/null
+++ b/_setup-gpu.iss
@@ -0,0 +1,49 @@
+#define MyAppName "Rembg GPU"
+#define MyAppVersion "STABLE"
+#define MyAppPublisher "danielgatis"
+#define MyAppURL "https://github.com/danielgatis/rembg"
+#define MyAppExeName "rembg.exe"
+#define MyAppId "49AB7484-212F-4B31-A49F-533A480F3FD4"
+
+[Setup]
+AppId={#MyAppId}
+AppName={#MyAppName}
+AppVersion={#MyAppVersion}
+AppPublisher={#MyAppPublisher}
+AppPublisherURL={#MyAppURL}
+AppSupportURL={#MyAppURL}
+AppUpdatesURL={#MyAppURL}
+DefaultDirName={autopf}\Rembg
+DefaultGroupName=Rembg
+DisableProgramGroupPage=yes
+OutputBaseFilename=rembg-cli-gpu-installer
+Compression=lzma
+SolidCompression=yes
+WizardStyle=modern
+OutputDir=dist
+ChangesEnvironment=yes
+
+[Languages]
+Name: "english"; MessagesFile: "compiler:Default.isl"
+
+[Files]
+Source: "{#SourcePath}dist\rembg-gpu\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
+Source: "{#SourcePath}dist\rembg-gpu\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
+
+[Tasks]
+Name: modifypath; Description: "Add to PATH variable"
+
+[Icons]
+Name: "{group}\Rembg"; Filename: "{app}\{#MyAppExeName}"
+
+[Code]
+const
+ ModPathName = 'modifypath';
+ ModPathType = 'user';
+
+function ModPathDir(): TArrayOfString;
+begin
+ setArrayLength(Result, 1)
+ Result[0] := ExpandConstant('{app}');
+end;
+#include "_modpath.iss"
diff --git a/rembg.spec b/rembg.spec
index 8f441f4..7cce928 100644
--- a/rembg.spec
+++ b/rembg.spec
@@ -1,15 +1,27 @@
# -*- mode: python ; coding: utf-8 -*-
-from PyInstaller.utils.hooks import collect_data_files
+from PyInstaller.utils.hooks import collect_data_files, collect_dynamic_libs
datas = []
datas += collect_data_files('gradio_client')
datas += collect_data_files('gradio')
-datas += collect_data_files('onnxruntime')
+datas += collect_data_files('safehttpx')
+datas += collect_data_files('groovy')
+
+binaries = []
+
+# Collect onnxruntime (works for both CPU and GPU versions)
+# The pip packages are named differently (onnxruntime vs onnxruntime-gpu)
+# but both install the Python module as 'onnxruntime'
+try:
+ datas += collect_data_files('onnxruntime')
+ binaries += collect_dynamic_libs('onnxruntime')
+except Exception:
+ pass
a = Analysis(
['rembg.py'],
pathex=[],
- binaries=[],
+ binaries=binaries,
datas=datas,
hiddenimports=[],
hookspath=[],