From 1eb05d91413eaed8d7bdc4619aa621e1e6c4f668 Mon Sep 17 00:00:00 2001 From: hyrulelinks <134026642+hyrulelinks@users.noreply.github.com> Date: Mon, 11 Mar 2024 01:10:08 +0800 Subject: [PATCH 01/19] Update macos-build-script.sh - Change realesrgan-ncnn-vulkan to upscayl-ncnn, the latter is a continued development project of the former - Increase the RealSR model, which provides better super-resolution fidelity for real photos - Remove the 2x and 3x models of Real-ESRGAN's animevideov3 due to their poor upscaling performance and tendency to produce erroneous images - Modify the script content for downloading the Super Resolution executable program and models --- macos-build-script.sh | 124 ++++++++++++++++++++++++++++++++---------- 1 file changed, 95 insertions(+), 29 deletions(-) diff --git a/macos-build-script.sh b/macos-build-script.sh index ef30c2f..92f5be7 100644 --- a/macos-build-script.sh +++ b/macos-build-script.sh @@ -1,6 +1,7 @@ # Clone repo echo "INFO: Clone repo." -git clone https://github.com/TransparentLC/realesrgan-gui.git +mirror_head="https://mirror.ghproxy.com" +git clone $mirror_head/https://github.com/TransparentLC/realesrgan-gui.git cd realesrgan-gui # Create and activate Python virtual environment @@ -31,40 +32,105 @@ else fi fi -# Download required files -echo "INFO: ๐Ÿš€ Downloading realesrgan-ncnn-vulkan executable and models..." -base_url="https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0" -source_file="realesrgan-ncnn-vulkan-20220424-macos.zip" -target_file="realesrgan-ncnn-vulkan" -model_folder="models" +# Download extra files +# Function to download and process release asset +download_asset() { + repo=$1 + asset_keyword=$2 + unzip_target=$3 + output_folder=$4 -if command -v wget &> /dev/null; then - echo "INFO: Using wget..." - wget -q --show-progress "$base_url/$source_file" -O "$source_file" -else - echo "INFO: wget not available, using curl..." - curl -L "$base_url/$source_file" -o "$source_file" -fi + # GitHub API endpoint to retrieve releases + api_url="https://api.github.com/repos/$repo/releases/latest" -unzip -j "$source_file" "$target_file" -d "." -unzip -j "$source_file" "$model_folder/*" -d "$model_folder" -rm -rf "$source_file" + # Make a GET request to the GitHub API to retrieve the latest release + response=$(curl -s "$api_url") -# Thin fat files to single architecture -arch=$(uname -m) + # Check if repo is xinntao/Real-ESRGAN + if [ "$repo" = "xinntao/Real-ESRGAN" ]; then + asset_url="https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesrgan-ncnn-vulkan-20220424-macos.zip" + zip_file=$(basename "$asset_url") + folder_name="models" + else + # Parse the response to get the latest release asset URL + asset_url=$(echo "$response" | grep -o "https://.*$asset_keyword*.zip" | head -n 1) + zip_file=$(basename "$asset_url") + folder_name=$(basename -s .zip "$zip_file") + fi -echo "INFO: System architecture is $arch." -echo "INFO: Extracting architecture specific libraries..." + # Download the latest release asset + if [ -n "$asset_url" ]; then + echo "INFO: ๐Ÿš€ Downloading $zip_file..." + curl -LO "$mirror_head/$asset_url" + echo "INFO: โœ… Download $zip_file complete." -if [ "$arch" = "arm64" ]; then - ditto --arch arm64 "$target_file" "temp_file" -else - ditto --arch x86_64 "$target_file" "temp_file" -fi + # Unzip and process the file + echo "INFO: ๐Ÿš€ Extracting and processing files..." + unzip -j "$zip_file" "$folder_name/$unzip_target" -d "$output_folder" + + # Perform additional actions based on the repo + if [ "$repo" = "upscayl/upscayl-ncnn" ]; then + # Rename and set permissions + if [ -f "upscayl-bin" ]; then + # Rename file + echo "INFO: ๐Ÿš€ Rename upscayl-bin to realesrgan-ncnn-vulkan..." + source_file="upscayl-bin" + target_file="realesrgan-ncnn-vulkan" + target_file_temp="realesrgan-ncnn-vulkan-temp" + mv $source_file $target_file + # Thin file + echo "INFO: ๐Ÿš€ Thin fat files to single architecture..." + arch=$(uname -m) + echo "INFO: ๐Ÿ’ฌ System architecture is $arch." + echo "INFO: ๐Ÿš€ Extracting architecture specific libraries..." + if [ "$arch" = "arm64" ]; then + ditto --arch arm64 "$target_file" "$target_file_temp" + else + ditto --arch x86_64 "$target_file" "$target_file_temp" + fi + rm -rf "$target_file" + mv "$target_file_temp" "$target_file" + # Add execute permission + echo "INFO: ๐Ÿš€ Add execute permission to realesrgan-ncnn-vulkan..." + chmod u+x realesrgan-ncnn-vulkan + fi + elif [ "$repo" = "nihui/realsr-ncnn-vulkan" ]; then + # Rename RealSR models + if [ -f "models/x4.param" ] && [ -f "models/x4.bin" ]; then + echo "INFO: ๐Ÿš€ Rename RealSR models..." + mv models/x4.param models/realsr-x4-realworld.param + mv models/x4.bin models/realsr-x4-realworld.bin + fi + elif [ "$repo" = "xinntao/Real-ESRGAN" ]; then + # Models to remove + models_to_remove=( + "realesr-animevideov3-x2" + "realesr-animevideov3-x3" + ) + # Remove models + for model in "${models_to_remove[@]}"; do + param_file="models/$model.param" + bin_file="models/$model.bin" + if [ -f "$param_file" ] && [ -f "$bin_file" ]; then + echo "INFO: ๐Ÿš€ Removing $model models..." + rm -rf "$param_file" "$bin_file" + fi + done + fi + echo "INFO: โœ… Processing complete." + else + echo "ERROR: โ›”๏ธ No release asset found for $repo." + fi +} + +# Download and process assets for upscayl-ncnn +download_asset "upscayl/upscayl-ncnn" "macos" "upscayl-bin" "." + +# Download and process assets for realsr-ncnn-vulkan +download_asset "nihui/realsr-ncnn-vulkan" "macos" "models-DF2K/*" "models" -rm -rf "$target_file" -mv "temp_file" "$target_file" -chmod u+x "$target_file" +# Download and process assets for realesrgan-ncnn-vulkan +download_asset "xinntao/Real-ESRGAN" "macos" "*" "models" # Install dependencies echo "INFO: ๐Ÿš€ Installing requirements..." From ed58399c4030d602084023a9582a515061ab6c35 Mon Sep 17 00:00:00 2001 From: hyrulelinks <134026642+hyrulelinks@users.noreply.github.com> Date: Mon, 11 Mar 2024 09:20:31 +0800 Subject: [PATCH 02/19] Create build-macos-arm64.yml --- .github/workflows/build-macos-arm64.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/build-macos-arm64.yml diff --git a/.github/workflows/build-macos-arm64.yml b/.github/workflows/build-macos-arm64.yml new file mode 100644 index 0000000..f170e1a --- /dev/null +++ b/.github/workflows/build-macos-arm64.yml @@ -0,0 +1,18 @@ +name: build macos arm64 + +on: workflow_dispatch + +jobs: + release: + name: build macos arm64 + runs-on: macos-13-xlarge + + steps: + - name: run shell scripts + run: sh macos-build-script.sh + + - name: Upload a Build Artifact + uses: actions/upload-artifact@v3.1.0 + with: + name: arm64 + path: dist/Real-ESRGAN\ GUI.app From 7b8e0d72289682e1b95aaed34f0948f69a4cde43 Mon Sep 17 00:00:00 2001 From: hyrulelinks <134026642+hyrulelinks@users.noreply.github.com> Date: Mon, 11 Mar 2024 09:24:01 +0800 Subject: [PATCH 03/19] Delete .github/workflows/build-macos-arm64.yml --- .github/workflows/build-macos-arm64.yml | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 .github/workflows/build-macos-arm64.yml diff --git a/.github/workflows/build-macos-arm64.yml b/.github/workflows/build-macos-arm64.yml deleted file mode 100644 index f170e1a..0000000 --- a/.github/workflows/build-macos-arm64.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: build macos arm64 - -on: workflow_dispatch - -jobs: - release: - name: build macos arm64 - runs-on: macos-13-xlarge - - steps: - - name: run shell scripts - run: sh macos-build-script.sh - - - name: Upload a Build Artifact - uses: actions/upload-artifact@v3.1.0 - with: - name: arm64 - path: dist/Real-ESRGAN\ GUI.app From b4203e535c5f59a2adcff3f599e580d3529668d4 Mon Sep 17 00:00:00 2001 From: hyrulelinks <134026642+hyrulelinks@users.noreply.github.com> Date: Mon, 11 Mar 2024 09:38:02 +0800 Subject: [PATCH 04/19] Create build-macos-arm64.yml --- .github/workflows/build-macos-arm64.yml | 48 +++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/build-macos-arm64.yml diff --git a/.github/workflows/build-macos-arm64.yml b/.github/workflows/build-macos-arm64.yml new file mode 100644 index 0000000..ed0e4fd --- /dev/null +++ b/.github/workflows/build-macos-arm64.yml @@ -0,0 +1,48 @@ +name: build-macos-arm64 + +on: workflow_dispatch + +jobs: + build: + runs-on: macos-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.12 + + - name: Install dependencies + run: | + pip install pyinstaller + + - name: Install osx-arm64-builder + run: | + git clone https://github.com/tpoechtrager/osxcross.git + cd osxcross + UNATTENDED=1 ./build.sh + mv target /opt/osxcross + echo 'export PATH="/opt/osxcross/bin:$PATH"' >> $GITHUB_ENV + + - name: Build arm64 app + run: | + export CROSS_TRIPLE=x86_64-apple-darwin + export BUILD_TRIPLE=aarch64-apple-darwin + export SDK_VERSION=11.3 + export MACOSX_DEPLOYMENT_TARGET=10.14 + export PKG_CONFIG_PATH=/opt/osxcross/lib/pkgconfig + export CFLAGS="-arch $BUILD_TRIPLE -target $BUILD_TRIPLE -isysroot /opt/osxcross/target/SDK/MacOSX$SDK_VERSION.sdk -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET $CFLAGS" + export LDFLAGS="-arch $BUILD_TRIPLE -target $BUILD_TRIPLE -isysroot /opt/osxcross/target/SDK/MacOSX$SDK_VERSION.sdk -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET $LDFLAGS" + export CC=/opt/osxcross/bin/$CROSS_TRIPLE-clang + export CXX=/opt/osxcross/bin/$CROSS_TRIPLE-clang++ + export MACOSX_DEPLOYMENT_TARGET=$SDK_VERSION + sh macos-build-script.sh + + - name: Upload a Build Artifact + uses: actions/upload-artifact@v4 + with: + name: realesrgan-gui-macos-arm64 + path: dist/*.app From 4e77fb752d6423d090fcd353df615c9036d90a5c Mon Sep 17 00:00:00 2001 From: hyrulelinks <134026642+hyrulelinks@users.noreply.github.com> Date: Mon, 11 Mar 2024 09:49:04 +0800 Subject: [PATCH 05/19] Update build-macos-arm64.yml --- .github/workflows/build-macos-arm64.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-macos-arm64.yml b/.github/workflows/build-macos-arm64.yml index ed0e4fd..fba60bd 100644 --- a/.github/workflows/build-macos-arm64.yml +++ b/.github/workflows/build-macos-arm64.yml @@ -18,13 +18,13 @@ jobs: - name: Install dependencies run: | pip install pyinstaller + brew install patch openssl xz libxml2 bzip2 zlib - name: Install osx-arm64-builder run: | git clone https://github.com/tpoechtrager/osxcross.git cd osxcross UNATTENDED=1 ./build.sh - mv target /opt/osxcross echo 'export PATH="/opt/osxcross/bin:$PATH"' >> $GITHUB_ENV - name: Build arm64 app From 8cc77f511e3b0fcdafb174bd3bb716f81d93f146 Mon Sep 17 00:00:00 2001 From: hyrulelinks <134026642+hyrulelinks@users.noreply.github.com> Date: Mon, 11 Mar 2024 09:50:21 +0800 Subject: [PATCH 06/19] Update build-macos-arm64.yml --- .github/workflows/build-macos-arm64.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-macos-arm64.yml b/.github/workflows/build-macos-arm64.yml index fba60bd..824b1a7 100644 --- a/.github/workflows/build-macos-arm64.yml +++ b/.github/workflows/build-macos-arm64.yml @@ -18,7 +18,7 @@ jobs: - name: Install dependencies run: | pip install pyinstaller - brew install patch openssl xz libxml2 bzip2 zlib + brew install openssl xz libxml2 bzip2 zlib - name: Install osx-arm64-builder run: | From abf67445de5cf09d7580c9ea034a43c727e7a32b Mon Sep 17 00:00:00 2001 From: hyrulelinks <134026642+hyrulelinks@users.noreply.github.com> Date: Mon, 11 Mar 2024 09:55:31 +0800 Subject: [PATCH 07/19] Update build-macos-arm64.yml --- .github/workflows/build-macos-arm64.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build-macos-arm64.yml b/.github/workflows/build-macos-arm64.yml index 824b1a7..a2f9741 100644 --- a/.github/workflows/build-macos-arm64.yml +++ b/.github/workflows/build-macos-arm64.yml @@ -19,11 +19,15 @@ jobs: run: | pip install pyinstaller brew install openssl xz libxml2 bzip2 zlib + + - name: Install Xcode Command Line Tools + run: sudo xcode-select --install - name: Install osx-arm64-builder run: | git clone https://github.com/tpoechtrager/osxcross.git cd osxcross + cp -r /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/ ./tarballs/ UNATTENDED=1 ./build.sh echo 'export PATH="/opt/osxcross/bin:$PATH"' >> $GITHUB_ENV From 915ec188d8ba92e5481b92456a7ad8b80ad42a00 Mon Sep 17 00:00:00 2001 From: hyrulelinks <134026642+hyrulelinks@users.noreply.github.com> Date: Mon, 11 Mar 2024 09:57:48 +0800 Subject: [PATCH 08/19] Update build-macos-arm64.yml --- .github/workflows/build-macos-arm64.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/build-macos-arm64.yml b/.github/workflows/build-macos-arm64.yml index a2f9741..a041264 100644 --- a/.github/workflows/build-macos-arm64.yml +++ b/.github/workflows/build-macos-arm64.yml @@ -19,14 +19,12 @@ jobs: run: | pip install pyinstaller brew install openssl xz libxml2 bzip2 zlib - - - name: Install Xcode Command Line Tools - run: sudo xcode-select --install - name: Install osx-arm64-builder run: | git clone https://github.com/tpoechtrager/osxcross.git cd osxcross + find /Applications/Xcode.app/Contents/Developer/Platforms -name "*.sdk" cp -r /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/ ./tarballs/ UNATTENDED=1 ./build.sh echo 'export PATH="/opt/osxcross/bin:$PATH"' >> $GITHUB_ENV From c90410f60d44ab276693c1d33cfa43d20aae1c91 Mon Sep 17 00:00:00 2001 From: hyrulelinks <134026642+hyrulelinks@users.noreply.github.com> Date: Mon, 11 Mar 2024 10:03:07 +0800 Subject: [PATCH 09/19] Update build-macos-arm64.yml --- .github/workflows/build-macos-arm64.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-macos-arm64.yml b/.github/workflows/build-macos-arm64.yml index a041264..dc34050 100644 --- a/.github/workflows/build-macos-arm64.yml +++ b/.github/workflows/build-macos-arm64.yml @@ -25,7 +25,9 @@ jobs: git clone https://github.com/tpoechtrager/osxcross.git cd osxcross find /Applications/Xcode.app/Contents/Developer/Platforms -name "*.sdk" - cp -r /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/ ./tarballs/ + ditto -r /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk tarballs/ + ditto -r /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk tarballs/ + ditto -r /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.sdk tarballs/ UNATTENDED=1 ./build.sh echo 'export PATH="/opt/osxcross/bin:$PATH"' >> $GITHUB_ENV From 201e65954fbda846d266322af6d9783157679ca6 Mon Sep 17 00:00:00 2001 From: hyrulelinks <134026642+hyrulelinks@users.noreply.github.com> Date: Mon, 11 Mar 2024 10:06:01 +0800 Subject: [PATCH 10/19] Update build-macos-arm64.yml --- .github/workflows/build-macos-arm64.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-macos-arm64.yml b/.github/workflows/build-macos-arm64.yml index dc34050..7ececd7 100644 --- a/.github/workflows/build-macos-arm64.yml +++ b/.github/workflows/build-macos-arm64.yml @@ -25,9 +25,9 @@ jobs: git clone https://github.com/tpoechtrager/osxcross.git cd osxcross find /Applications/Xcode.app/Contents/Developer/Platforms -name "*.sdk" - ditto -r /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk tarballs/ - ditto -r /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk tarballs/ - ditto -r /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.sdk tarballs/ + ditto /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk tarballs/ + ditto /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk tarballs/ + ditto /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.sdk tarballs/ UNATTENDED=1 ./build.sh echo 'export PATH="/opt/osxcross/bin:$PATH"' >> $GITHUB_ENV From c9d00476e3566e0c9df9d2a5126307eeb93f056a Mon Sep 17 00:00:00 2001 From: hyrulelinks <134026642+hyrulelinks@users.noreply.github.com> Date: Mon, 11 Mar 2024 10:09:11 +0800 Subject: [PATCH 11/19] Update build-macos-arm64.yml --- .github/workflows/build-macos-arm64.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build-macos-arm64.yml b/.github/workflows/build-macos-arm64.yml index 7ececd7..01e2610 100644 --- a/.github/workflows/build-macos-arm64.yml +++ b/.github/workflows/build-macos-arm64.yml @@ -26,8 +26,6 @@ jobs: cd osxcross find /Applications/Xcode.app/Contents/Developer/Platforms -name "*.sdk" ditto /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk tarballs/ - ditto /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk tarballs/ - ditto /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.sdk tarballs/ UNATTENDED=1 ./build.sh echo 'export PATH="/opt/osxcross/bin:$PATH"' >> $GITHUB_ENV From 6dfa19569bbee6ffda28bcb0b60fd38c4f968a08 Mon Sep 17 00:00:00 2001 From: hyrulelinks <134026642+hyrulelinks@users.noreply.github.com> Date: Mon, 11 Mar 2024 10:13:46 +0800 Subject: [PATCH 12/19] Update build-macos-arm64.yml --- .github/workflows/build-macos-arm64.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-macos-arm64.yml b/.github/workflows/build-macos-arm64.yml index 01e2610..de2d819 100644 --- a/.github/workflows/build-macos-arm64.yml +++ b/.github/workflows/build-macos-arm64.yml @@ -26,14 +26,14 @@ jobs: cd osxcross find /Applications/Xcode.app/Contents/Developer/Platforms -name "*.sdk" ditto /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk tarballs/ - UNATTENDED=1 ./build.sh + UNATTENDED=1 SDK_VERSION=13.1 ./build.sh echo 'export PATH="/opt/osxcross/bin:$PATH"' >> $GITHUB_ENV - name: Build arm64 app run: | export CROSS_TRIPLE=x86_64-apple-darwin export BUILD_TRIPLE=aarch64-apple-darwin - export SDK_VERSION=11.3 + export SDK_VERSION=13.1 export MACOSX_DEPLOYMENT_TARGET=10.14 export PKG_CONFIG_PATH=/opt/osxcross/lib/pkgconfig export CFLAGS="-arch $BUILD_TRIPLE -target $BUILD_TRIPLE -isysroot /opt/osxcross/target/SDK/MacOSX$SDK_VERSION.sdk -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET $CFLAGS" From fbdabebd6cfb5bf94f708aec5d2ce6346bc51316 Mon Sep 17 00:00:00 2001 From: hyrulelinks <134026642+hyrulelinks@users.noreply.github.com> Date: Mon, 11 Mar 2024 10:21:16 +0800 Subject: [PATCH 13/19] Update build-macos-arm64.yml --- .github/workflows/build-macos-arm64.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-macos-arm64.yml b/.github/workflows/build-macos-arm64.yml index de2d819..8adf371 100644 --- a/.github/workflows/build-macos-arm64.yml +++ b/.github/workflows/build-macos-arm64.yml @@ -25,7 +25,7 @@ jobs: git clone https://github.com/tpoechtrager/osxcross.git cd osxcross find /Applications/Xcode.app/Contents/Developer/Platforms -name "*.sdk" - ditto /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk tarballs/ + cp -v /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk tarballs/ UNATTENDED=1 SDK_VERSION=13.1 ./build.sh echo 'export PATH="/opt/osxcross/bin:$PATH"' >> $GITHUB_ENV From d676ce71f213a664e6d21739912142fb29572020 Mon Sep 17 00:00:00 2001 From: hyrulelinks <134026642+hyrulelinks@users.noreply.github.com> Date: Mon, 11 Mar 2024 10:23:55 +0800 Subject: [PATCH 14/19] Update build-macos-arm64.yml --- .github/workflows/build-macos-arm64.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-macos-arm64.yml b/.github/workflows/build-macos-arm64.yml index 8adf371..a505d3b 100644 --- a/.github/workflows/build-macos-arm64.yml +++ b/.github/workflows/build-macos-arm64.yml @@ -25,7 +25,7 @@ jobs: git clone https://github.com/tpoechtrager/osxcross.git cd osxcross find /Applications/Xcode.app/Contents/Developer/Platforms -name "*.sdk" - cp -v /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk tarballs/ + cp -rv /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk tarballs/ UNATTENDED=1 SDK_VERSION=13.1 ./build.sh echo 'export PATH="/opt/osxcross/bin:$PATH"' >> $GITHUB_ENV From 8da0723f9328d400671862a5abdf3c14e6f83310 Mon Sep 17 00:00:00 2001 From: hyrulelinks <134026642+hyrulelinks@users.noreply.github.com> Date: Mon, 11 Mar 2024 10:29:56 +0800 Subject: [PATCH 15/19] Update build-macos-arm64.yml --- .github/workflows/build-macos-arm64.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-macos-arm64.yml b/.github/workflows/build-macos-arm64.yml index a505d3b..d40da1b 100644 --- a/.github/workflows/build-macos-arm64.yml +++ b/.github/workflows/build-macos-arm64.yml @@ -25,7 +25,7 @@ jobs: git clone https://github.com/tpoechtrager/osxcross.git cd osxcross find /Applications/Xcode.app/Contents/Developer/Platforms -name "*.sdk" - cp -rv /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk tarballs/ + cp -r /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk tarballs/ UNATTENDED=1 SDK_VERSION=13.1 ./build.sh echo 'export PATH="/opt/osxcross/bin:$PATH"' >> $GITHUB_ENV From 5ff5623c0a8f8f4a4c3c00e621a7ae5503ac55a8 Mon Sep 17 00:00:00 2001 From: hyrulelinks <134026642+hyrulelinks@users.noreply.github.com> Date: Mon, 11 Mar 2024 10:34:56 +0800 Subject: [PATCH 16/19] Delete .github/workflows/build-macos-arm64.yml --- .github/workflows/build-macos-arm64.yml | 50 ------------------------- 1 file changed, 50 deletions(-) delete mode 100644 .github/workflows/build-macos-arm64.yml diff --git a/.github/workflows/build-macos-arm64.yml b/.github/workflows/build-macos-arm64.yml deleted file mode 100644 index d40da1b..0000000 --- a/.github/workflows/build-macos-arm64.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: build-macos-arm64 - -on: workflow_dispatch - -jobs: - build: - runs-on: macos-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: 3.12 - - - name: Install dependencies - run: | - pip install pyinstaller - brew install openssl xz libxml2 bzip2 zlib - - - name: Install osx-arm64-builder - run: | - git clone https://github.com/tpoechtrager/osxcross.git - cd osxcross - find /Applications/Xcode.app/Contents/Developer/Platforms -name "*.sdk" - cp -r /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk tarballs/ - UNATTENDED=1 SDK_VERSION=13.1 ./build.sh - echo 'export PATH="/opt/osxcross/bin:$PATH"' >> $GITHUB_ENV - - - name: Build arm64 app - run: | - export CROSS_TRIPLE=x86_64-apple-darwin - export BUILD_TRIPLE=aarch64-apple-darwin - export SDK_VERSION=13.1 - export MACOSX_DEPLOYMENT_TARGET=10.14 - export PKG_CONFIG_PATH=/opt/osxcross/lib/pkgconfig - export CFLAGS="-arch $BUILD_TRIPLE -target $BUILD_TRIPLE -isysroot /opt/osxcross/target/SDK/MacOSX$SDK_VERSION.sdk -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET $CFLAGS" - export LDFLAGS="-arch $BUILD_TRIPLE -target $BUILD_TRIPLE -isysroot /opt/osxcross/target/SDK/MacOSX$SDK_VERSION.sdk -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET $LDFLAGS" - export CC=/opt/osxcross/bin/$CROSS_TRIPLE-clang - export CXX=/opt/osxcross/bin/$CROSS_TRIPLE-clang++ - export MACOSX_DEPLOYMENT_TARGET=$SDK_VERSION - sh macos-build-script.sh - - - name: Upload a Build Artifact - uses: actions/upload-artifact@v4 - with: - name: realesrgan-gui-macos-arm64 - path: dist/*.app From 3352e4b3c6cb730304d4a818283e8b205672cde3 Mon Sep 17 00:00:00 2001 From: hyrulelinks <134026642+hyrulelinks@users.noreply.github.com> Date: Sun, 7 Apr 2024 18:13:11 +0800 Subject: [PATCH 17/19] Update macos-build-script.sh --- macos-build-script.sh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/macos-build-script.sh b/macos-build-script.sh index 92f5be7..2f1ba3b 100644 --- a/macos-build-script.sh +++ b/macos-build-script.sh @@ -70,14 +70,8 @@ download_asset() { # Perform additional actions based on the repo if [ "$repo" = "upscayl/upscayl-ncnn" ]; then - # Rename and set permissions + # Set permissions if [ -f "upscayl-bin" ]; then - # Rename file - echo "INFO: ๐Ÿš€ Rename upscayl-bin to realesrgan-ncnn-vulkan..." - source_file="upscayl-bin" - target_file="realesrgan-ncnn-vulkan" - target_file_temp="realesrgan-ncnn-vulkan-temp" - mv $source_file $target_file # Thin file echo "INFO: ๐Ÿš€ Thin fat files to single architecture..." arch=$(uname -m) From 30ba093f54f6d91aaee5df7fa80ef49bece03014 Mon Sep 17 00:00:00 2001 From: hyrulelinks <134026642+hyrulelinks@users.noreply.github.com> Date: Mon, 8 Apr 2024 10:30:19 +0800 Subject: [PATCH 18/19] Update macos-build-script.sh --- macos-build-script.sh | 48 +++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/macos-build-script.sh b/macos-build-script.sh index 2f1ba3b..a8d4cef 100644 --- a/macos-build-script.sh +++ b/macos-build-script.sh @@ -1,11 +1,19 @@ +# Ask user whether to use mirror_head +read -p "Do you want to use mirror_head? (y/n): " use_mirror +if [ "$use_mirror" = "y" ]; then + mirror_head="https://mirror.ghproxy.com/" +else + mirror_head="" +fi + # Clone repo echo "INFO: Clone repo." -mirror_head="https://mirror.ghproxy.com" -git clone $mirror_head/https://github.com/TransparentLC/realesrgan-gui.git +repo_url="https://github.com/TransparentLC/realesrgan-gui.git" +git clone $mirror_head$repo_url cd realesrgan-gui # Create and activate Python virtual environment -echo "INFO: ๐Ÿš€ Checking current Python version..." +echo "INFO: ๐Ÿšง Checking current Python version..." python_version=$(python3 -V 2>&1 | cut -d" " -f2 | cut -d"." -f1-2) if ! which python3 >/dev/null 2>&1; then @@ -16,18 +24,18 @@ else echo "INFO: The 'python3' command found." if [ "$python_version" == "3.12" ]; then echo "INFO: โœ… The current Python version is 3.12" - echo "INFO: ๐Ÿš€ Creating Python 3.12 virtual enviroment..." + echo "INFO: ๐Ÿšง Creating Python 3.12 virtual enviroment..." python3 -m venv venv - echo "INFO: ๐Ÿš€ Activating Python virtual enviroment..." + echo "INFO: ๐Ÿšง Activating Python virtual enviroment..." source venv/bin/activate else echo "ERROR: โ›”๏ธ The current Python version is $python_version but 3.12 is required." - echo "INFO: ๐Ÿš€ Installling Python package 'virtualenv'..." + echo "INFO: ๐Ÿšง Installling Python package 'virtualenv'..." pip3 install virtualenv - echo "INFO: ๐Ÿš€ Creating Python 3.12 virtual enviroment..." + echo "INFO: ๐Ÿšง Creating Python 3.12 virtual enviroment..." virtualenv -p python3.12 venv - echo "INFO: ๐Ÿš€ Activating Python virtual enviroment..." + echo "INFO: ๐Ÿšง Activating Python virtual enviroment..." source venv/bin/activate fi fi @@ -60,23 +68,23 @@ download_asset() { # Download the latest release asset if [ -n "$asset_url" ]; then - echo "INFO: ๐Ÿš€ Downloading $zip_file..." - curl -LO "$mirror_head/$asset_url" + echo "INFO: ๐Ÿšง Downloading $zip_file..." + curl -LO "$mirror_head$asset_url" echo "INFO: โœ… Download $zip_file complete." # Unzip and process the file - echo "INFO: ๐Ÿš€ Extracting and processing files..." + echo "INFO: ๐Ÿšง Extracting and processing files..." unzip -j "$zip_file" "$folder_name/$unzip_target" -d "$output_folder" # Perform additional actions based on the repo if [ "$repo" = "upscayl/upscayl-ncnn" ]; then - # Set permissions + # Thin file and set permissions if [ -f "upscayl-bin" ]; then # Thin file - echo "INFO: ๐Ÿš€ Thin fat files to single architecture..." + echo "INFO: ๐Ÿšง Thin fat files to single architecture..." arch=$(uname -m) echo "INFO: ๐Ÿ’ฌ System architecture is $arch." - echo "INFO: ๐Ÿš€ Extracting architecture specific libraries..." + echo "INFO: ๐Ÿšง Extracting architecture specific libraries..." if [ "$arch" = "arm64" ]; then ditto --arch arm64 "$target_file" "$target_file_temp" else @@ -85,13 +93,13 @@ download_asset() { rm -rf "$target_file" mv "$target_file_temp" "$target_file" # Add execute permission - echo "INFO: ๐Ÿš€ Add execute permission to realesrgan-ncnn-vulkan..." + echo "INFO: ๐Ÿšง Add execute permission to realesrgan-ncnn-vulkan..." chmod u+x realesrgan-ncnn-vulkan fi elif [ "$repo" = "nihui/realsr-ncnn-vulkan" ]; then # Rename RealSR models if [ -f "models/x4.param" ] && [ -f "models/x4.bin" ]; then - echo "INFO: ๐Ÿš€ Rename RealSR models..." + echo "INFO: ๐Ÿšง Rename RealSR models..." mv models/x4.param models/realsr-x4-realworld.param mv models/x4.bin models/realsr-x4-realworld.bin fi @@ -106,7 +114,7 @@ download_asset() { param_file="models/$model.param" bin_file="models/$model.bin" if [ -f "$param_file" ] && [ -f "$bin_file" ]; then - echo "INFO: ๐Ÿš€ Removing $model models..." + echo "INFO: ๐Ÿšง Removing $model models..." rm -rf "$param_file" "$bin_file" fi done @@ -127,13 +135,13 @@ download_asset "nihui/realsr-ncnn-vulkan" "macos" "models-DF2K/*" "models" download_asset "xinntao/Real-ESRGAN" "macos" "*" "models" # Install dependencies -echo "INFO: ๐Ÿš€ Installing requirements..." +echo "INFO: ๐Ÿšง Installing requirements..." pip3 install -r requirements.txt -echo "INFO: ๐Ÿš€ Installing Python package 'pyinstaller'..." +echo "INFO: ๐Ÿšง Installing Python package 'pyinstaller'..." pip install pyinstaller # Build macOS app -echo "INFO: ๐Ÿš€ Packaging macOS app..." +echo "INFO: ๐Ÿšง Packaging macOS app..." sudo pyinstaller realesrgan-gui-macos.spec # Copy built app to Download directory From 0b4dc8726094a6c31262846d0883134369ac1274 Mon Sep 17 00:00:00 2001 From: hyrulelinks <134026642+hyrulelinks@users.noreply.github.com> Date: Mon, 8 Apr 2024 10:31:27 +0800 Subject: [PATCH 19/19] Update realesrgan-gui-macos.spec --- realesrgan-gui-macos.spec | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/realesrgan-gui-macos.spec b/realesrgan-gui-macos.spec index 35715a8..4d1f5d8 100644 --- a/realesrgan-gui-macos.spec +++ b/realesrgan-gui-macos.spec @@ -8,14 +8,20 @@ import subprocess commit_hash = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('utf-8').strip() version = "0.2.5." + commit_hash +# ๅˆคๆ–ญๆ˜ฏๅฆๅญ˜ๅœจ upscayl-bin ๆ–‡ไปถ +if os.path.exists('upscayl-bin'): + # ๅญ˜ๅœจ upscayl-bin๏ผŒๅช้œ€่ฆๆ‰“ๅŒ… upscayl-bin + bin = [('upscayl-bin', '.')] +else: + # ไธๅญ˜ๅœจ upscayl-bin๏ผŒๆ‰“ๅŒ… realesrgan-ncnn-vulkan + bin = [('realesrgan-ncnn-vulkan', '.')] + # PyInstallerๅˆ†ๆž่„šๆœฌ # ๆŒ‡ๅฎšไธปๅ…ฅๅฃๆ–‡ไปถ a = Analysis( ['main.py'], # ้œ€่ฆๆ‰“ๅŒ…็š„ไบŒ่ฟ›ๅˆถ - binaries=[ - ('realesrgan-ncnn-vulkan', '.'), - ], + binaries=bin, # ้œ€่ฆๆ‰“ๅŒ…็š„ๆ•ฐๆฎๆ–‡ไปถ datas=[ ('models', 'models'),