upscayl-ncnn: init at 20240601-103425
This commit is contained in:
parent
73db838c15
commit
6da00ff003
27
pkgs/by-name/up/upscayl-ncnn/cmakelists.patch
Normal file
27
pkgs/by-name/up/upscayl-ncnn/cmakelists.patch
Normal file
@ -0,0 +1,27 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 7e4da27..85cf911 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -106,20 +106,13 @@ if(USE_SYSTEM_NCNN)
|
||||
message(STATUS "Using glslang install located at ${GLSLANG_TARGET_DIR}")
|
||||
|
||||
find_package(Threads)
|
||||
+ find_package(glslang REQUIRED)
|
||||
+ find_package(SPIRV-Tools-opt REQUIRED)
|
||||
|
||||
- include("${GLSLANG_TARGET_DIR}/OSDependentTargets.cmake")
|
||||
- include("${GLSLANG_TARGET_DIR}/OGLCompilerTargets.cmake")
|
||||
if(EXISTS "${GLSLANG_TARGET_DIR}/HLSLTargets.cmake")
|
||||
# hlsl support can be optional
|
||||
include("${GLSLANG_TARGET_DIR}/HLSLTargets.cmake")
|
||||
endif()
|
||||
- include("${GLSLANG_TARGET_DIR}/glslangTargets.cmake")
|
||||
- include("${GLSLANG_TARGET_DIR}/SPIRVTargets.cmake")
|
||||
-
|
||||
- if (NOT TARGET glslang OR NOT TARGET SPIRV)
|
||||
- message(WARNING "glslang or SPIRV target not found! USE_SYSTEM_NCNN will be turned off.")
|
||||
- set(USE_SYSTEM_NCNN OFF)
|
||||
- endif()
|
||||
endif()
|
||||
endif()
|
||||
|
22
pkgs/by-name/up/upscayl-ncnn/models_path.patch
Normal file
22
pkgs/by-name/up/upscayl-ncnn/models_path.patch
Normal file
@ -0,0 +1,22 @@
|
||||
diff --git a/main.cpp b/main.cpp
|
||||
index 9d44c3d..40d2b27 100644
|
||||
--- a/main.cpp
|
||||
+++ b/main.cpp
|
||||
@@ -207,7 +207,7 @@ static void print_usage()
|
||||
fprintf(stderr, " -w width resize output to a width (default=W:default), use '-r help' for more details\n");
|
||||
fprintf(stderr, " -c compress compression of the output image, default 0 and varies to 100\n");
|
||||
fprintf(stderr, " -t tile-size tile size (>=32/0=auto, default=0) can be 0,0,0 for multi-gpu\n");
|
||||
- fprintf(stderr, " -m model-path folder path to the pre-trained models. default=models\n");
|
||||
+ fprintf(stderr, " -m model-path folder path to the pre-trained models. default=REPLACE_MODELS\n");
|
||||
fprintf(stderr, " -n model-name model name (default=realesrgan-x4plus, can be realesr-animevideov3 | realesrgan-x4plus-anime | realesrnet-x4plus or any other model)\n");
|
||||
fprintf(stderr, " -g gpu-id gpu device to use (default=auto) can be 0,1,2 for multi-gpu\n");
|
||||
fprintf(stderr, " -j load:proc:save thread count for load/proc/save (default=1:2:2) can be 1:2,2,2:2 for multi-gpu\n");
|
||||
@@ -688,7 +688,7 @@ int main(int argc, char **argv)
|
||||
bool resizeProvided = false;
|
||||
bool hasCustomWidth = false;
|
||||
std::vector<int> tilesize;
|
||||
- path_t model = PATHSTR("models");
|
||||
+ path_t model = PATHSTR("REPLACE_MODELS");
|
||||
path_t modelname = PATHSTR("realesrgan-x4plus");
|
||||
std::vector<int> gpuid;
|
||||
int jobs_load = 1;
|
92
pkgs/by-name/up/upscayl-ncnn/package.nix
Normal file
92
pkgs/by-name/up/upscayl-ncnn/package.nix
Normal file
@ -0,0 +1,92 @@
|
||||
{
|
||||
cmake,
|
||||
fetchFromGitHub,
|
||||
fetchzip,
|
||||
glslang,
|
||||
installShellFiles,
|
||||
lib,
|
||||
libwebp,
|
||||
ncnn,
|
||||
stdenv,
|
||||
vulkan-headers,
|
||||
vulkan-loader,
|
||||
}:
|
||||
|
||||
# upscayl-ncnn is a fork of /pkgs/by-name/re/realesrgan-ncnn-vulkan, so the nix package is basically the same.
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "upscayl-ncnn";
|
||||
version = "20240601-103425";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "upscayl";
|
||||
repo = "upscayl-ncnn";
|
||||
rev = "refs/tags/${finalAttrs.version}";
|
||||
hash = "sha256-rGnjL+sU5x3VXHnvuYXVdxGmHdj9eBkIZK3CwL89lN0=";
|
||||
};
|
||||
|
||||
models = fetchzip {
|
||||
# Choose the newst release from https://github.com/xinntao/Real-ESRGAN/releases to update
|
||||
url = "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesrgan-ncnn-vulkan-20220424-ubuntu.zip";
|
||||
hash = "sha256-1YiPzv1eGnHrazJFRvl37+C1F2xnoEbN0UQYkxLT+JQ=";
|
||||
stripRoot = false;
|
||||
};
|
||||
|
||||
patches = [
|
||||
./cmakelists.patch
|
||||
./models_path.patch
|
||||
];
|
||||
|
||||
sourceRoot = "${finalAttrs.src.name}/src";
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace main.cpp --replace REPLACE_MODELS $out/share/models
|
||||
'';
|
||||
|
||||
nativeBuildInputs = [
|
||||
cmake
|
||||
glslang
|
||||
installShellFiles
|
||||
];
|
||||
|
||||
cmakeFlags = [
|
||||
(lib.cmakeBool "USE_SYSTEM_NCNN" true)
|
||||
(lib.cmakeBool "USE_SYSTEM_WEBP" true)
|
||||
(lib.cmakeFeature "GLSLANG_TARGET_DIR" "${glslang}/lib/cmake")
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
vulkan-loader
|
||||
libwebp
|
||||
ncnn
|
||||
vulkan-headers
|
||||
glslang
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/share
|
||||
|
||||
installBin upscayl-bin
|
||||
ln -s ${finalAttrs.models}/models $out/share
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
env.NIX_LDFLAGS = lib.optionalString stdenv.hostPlatform.isLinux "-rpath ${
|
||||
lib.makeLibraryPath [ vulkan-loader ]
|
||||
}";
|
||||
|
||||
meta = {
|
||||
changelog = "https://github.com/upscayl/upscayl-ncnn/releases/tag/${finalAttrs.version}";
|
||||
description = "Upscayl backend powered by the NCNN framework and Real-ESRGAN architecture";
|
||||
homepage = "https://github.com/upscayl/upscayl-ncnn";
|
||||
license = lib.licenses.agpl3Only;
|
||||
mainProgram = "upscayl-bin";
|
||||
maintainers = with lib.maintainers; [
|
||||
grimmauld
|
||||
getchoo
|
||||
];
|
||||
platforms = lib.platforms.all;
|
||||
};
|
||||
})
|
Loading…
Reference in New Issue
Block a user