Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge mac_test with main #7

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,42 @@
### v1.04
[💾](https://github.com/Nenotriple/gimp_upscale/releases/tag/v1.04)


<details>
<summary>Release Notes</summary>

### New:
- Add MAcOS support.


</details>


---


### v1.03
[💾](https://github.com/Nenotriple/gimp_upscale/releases/tag/v1.03)


<details>
<summary>Release Notes</summary>

### New:
- Add Linux support.
- Add progress bar message during upscale process.

### Other Changes:
- Disable terminal popup on Windows.
- Increase output scale limits and granularity.


</details>


---


### v1.02
[💾](https://github.com/Nenotriple/gimp_upscale/releases/tag/v1.02)

Expand Down
48 changes: 25 additions & 23 deletions gimp_upscale.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""
########################################
# gimp_upscale #
# Version : v1.03 #
# Version : v1.04 #
# Author : github.com/Nenotriple #
########################################

Expand All @@ -20,8 +20,6 @@
# --------------------------------------
# Imports
# --------------------------------------


# Standard Library
import os
import tempfile
Expand All @@ -36,8 +34,6 @@
# --------------------------------------
# Global Variables
# --------------------------------------


# Operation System
PLATFORM = platform.system()

Expand All @@ -50,15 +46,6 @@
MODEL_DIR = os.path.join(SCRIPT_DIR, "resrgan/models")


# Path to RESRGAN executable
if PLATFORM == "Windows":
RESRGAN_PATH = os.path.join(SCRIPT_DIR, "resrgan/realesrgan-ncnn-vulkan.exe")
else: # Linux
RESRGAN_PATH = os.path.join(SCRIPT_DIR, "resrgan/realesrgan-ncnn-vulkan")
# Make sure the executable has the correct permissions
subprocess.call(['chmod', 'u+x', RESRGAN_PATH])


# Predefined model list
HARDCODED_MODELS = [
"realesr-animevideov3-x4",
Expand All @@ -84,10 +71,32 @@


# --------------------------------------
# Update the list of available models
# Get RESRGAN Executable Path
# --------------------------------------
def get_resrgan_executable_path(PLATFORM, SCRIPT_DIR):
EXECUTABLES = {
"Windows": "realesrgan-ncnn-vulkan.exe",
"Darwin": "realesrgan-ncnn-vulkan_mac",
"Linux": "realesrgan-ncnn-vulkan_linux"
}
# Check if platform is supported
if PLATFORM not in EXECUTABLES:
raise Exception("Unsupported platform")
# Set platform dependant RESRGAN executable path
RESRGAN_PATH = os.path.join(SCRIPT_DIR, "resrgan", EXECUTABLES[PLATFORM])
# Make executable for Unix-like systems
if PLATFORM in ("Darwin", "Linux"):
subprocess.call(['chmod', 'u+x', RESRGAN_PATH])
return RESRGAN_PATH


# Get platform-specific RESRGAN executable path
RESRGAN_PATH = get_resrgan_executable_path(PLATFORM, SCRIPT_DIR)


# --------------------------------------
# Update the list of available models
# --------------------------------------
def _find_additional_models():
'''Function to find additional upscale models in the "resrgan/models" folder'''
# List all files in the models directory
Expand All @@ -109,8 +118,6 @@ def _find_additional_models():
# --------------------------------------
# Functions
# --------------------------------------


def _get_layer_or_selection(image, drawable, upscale_selection):
'''Retrieves the active layer or creates a new one from the selection.'''
if upscale_selection and pdb.gimp_selection_is_empty(image):
Expand Down Expand Up @@ -196,8 +203,6 @@ def _cleanup_temp_files(image, selected_layer, temp_input_file, temp_output_file
# --------------------------------------
# Primary Function
# --------------------------------------


def execute_upscale_process(image, drawable, model_index, upscale_selection, keep_copy_layer, output_factor):
'''Main function that orchestrates the upscaling process using realesrgan-ncnn-vulkan.'''
pdb.gimp_image_undo_group_start(image)
Expand All @@ -222,11 +227,9 @@ def execute_upscale_process(image, drawable, model_index, upscale_selection, kee
# --------------------------------------
# GIMP Plug-in Registration
# --------------------------------------


register(
proc_name = "python-fu-upscale-with-ncnn",
blurb = "Upscale using AI-powered ESRGAN models\t\n---\t\ngithub.com/Nenotriple/gimp_upscale\t",
blurb = "v1.04 -- Upscale using Real-ESRGAN\t\n---\t\ngithub.com/Nenotriple/gimp_upscale\t",
help = "This plugin provides AI-powered image upscaling using ESRGAN/NCNN models; github.com/Nenotriple/gimp_upscale",
author = "github.com/Nenotriple",
copyright = "github/Nenotriple; MIT-LICENSE; 2024;",
Expand All @@ -248,4 +251,3 @@ def execute_upscale_process(image, drawable, model_index, upscale_selection, kee


main()

File renamed without changes.
Binary file added resrgan/realesrgan-ncnn-vulkan_mac
Binary file not shown.