mirror of
https://github.com/SebastianWendel/nixpkgs.git
synced 2024-09-21 04:49:01 +02:00
Merge pull request #152474 from TilCreator/package-Real-ESRGAN-ncnn-vulkan
This commit is contained in:
commit
c1e6dce5ff
|
@ -12037,7 +12037,7 @@
|
|||
name = "Tiago Castro";
|
||||
};
|
||||
tilcreator = {
|
||||
name = "Tilman Jackel";
|
||||
name = "TilCreator";
|
||||
email = "contact.nixos@tc-j.de";
|
||||
matrix = "@tilcreator:matrix.org";
|
||||
github = "TilCreator";
|
||||
|
|
|
@ -31,6 +31,11 @@ stdenv.mkDerivation rec {
|
|||
ln -s "${spirv-headers.src}" External/spirv-tools/external/spirv-headers
|
||||
'';
|
||||
|
||||
# This is a dirty fix for lib/cmake/SPIRVTargets.cmake:51 which includes this directory
|
||||
postInstall = ''
|
||||
mkdir $out/include/External
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
inherit (src.meta) homepage;
|
||||
description = "Khronos reference front-end for GLSL and ESSL";
|
||||
|
|
13
pkgs/development/libraries/ncnn/cmakelists.patch
Normal file
13
pkgs/development/libraries/ncnn/cmakelists.patch
Normal file
|
@ -0,0 +1,13 @@
|
|||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 98611276..989350bb 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -260,6 +260,8 @@ if(NCNN_VULKAN)
|
||||
include("${GLSLANG_TARGET_DIR}/HLSLTargets.cmake")
|
||||
endif()
|
||||
include("${GLSLANG_TARGET_DIR}/glslangTargets.cmake")
|
||||
+ include("${GLSLANG_TARGET_DIR}/SPIRV-Tools/SPIRV-ToolsTarget.cmake")
|
||||
+ include("${GLSLANG_TARGET_DIR}/SPIRV-Tools-opt/SPIRV-Tools-optTargets.cmake")
|
||||
include("${GLSLANG_TARGET_DIR}/SPIRVTargets.cmake")
|
||||
|
||||
if (NOT TARGET glslang OR NOT TARGET SPIRV)
|
50
pkgs/development/libraries/ncnn/default.nix
Normal file
50
pkgs/development/libraries/ncnn/default.nix
Normal file
|
@ -0,0 +1,50 @@
|
|||
{ lib
|
||||
, stdenv
|
||||
, fetchFromGitHub
|
||||
, cmake
|
||||
, vulkan-headers
|
||||
, vulkan-loader
|
||||
, glslang
|
||||
, opencv
|
||||
, protobuf
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "ncnn";
|
||||
version = "20211208";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "Tencent";
|
||||
repo = pname;
|
||||
rev = version;
|
||||
sha256 = "1c9axrnafksnks7v5fmi6nzs0qim9n6j5kh5d0vfl3b4r22irhqr";
|
||||
};
|
||||
|
||||
patches = [
|
||||
./cmakelists.patch
|
||||
./gpu-include.patch
|
||||
];
|
||||
|
||||
cmakeFlags = [
|
||||
"-DNCNN_CMAKE_VERBOSE=1" # Only for debugging the build
|
||||
"-DNCNN_SHARED_LIB=1"
|
||||
"-DNCNN_ENABLE_LTO=1"
|
||||
"-DNCNN_VULKAN=1"
|
||||
"-DNCNN_BUILD_EXAMPLES=0"
|
||||
"-DNCNN_BUILD_TOOLS=0"
|
||||
"-DNCNN_SYSTEM_GLSLANG=1"
|
||||
"-DNCNN_PYTHON=0" # Should be an attribute
|
||||
|
||||
"-DGLSLANG_TARGET_DIR=${glslang}/lib/cmake"
|
||||
];
|
||||
|
||||
nativeBuildInputs = [ cmake ];
|
||||
buildInputs = [ vulkan-headers vulkan-loader glslang opencv protobuf ];
|
||||
|
||||
meta = with lib; {
|
||||
description = "ncnn is a high-performance neural network inference framework optimized for the mobile platform";
|
||||
homepage = "https://github.com/Tencent/ncnn";
|
||||
license = licenses.bsd3;
|
||||
maintainers = with maintainers; [ tilcreator ];
|
||||
};
|
||||
}
|
13
pkgs/development/libraries/ncnn/gpu-include.patch
Normal file
13
pkgs/development/libraries/ncnn/gpu-include.patch
Normal file
|
@ -0,0 +1,13 @@
|
|||
diff --git a/src/gpu.cpp b/src/gpu.cpp
|
||||
index 51cd7f95..bf7ed828 100644
|
||||
--- a/src/gpu.cpp
|
||||
+++ b/src/gpu.cpp
|
||||
@@ -21,7 +21,7 @@
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#include "glslang/SPIRV/GlslangToSpv.h"
|
||||
-#include "glslang/glslang/Public/ShaderLang.h"
|
||||
+#include "glslang/Public/ShaderLang.h"
|
||||
|
||||
#include "command.h"
|
||||
#include "layer.h"
|
13
pkgs/tools/graphics/realesrgan-ncnn-vulkan/cmakelists.patch
Normal file
13
pkgs/tools/graphics/realesrgan-ncnn-vulkan/cmakelists.patch
Normal file
|
@ -0,0 +1,13 @@
|
|||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index a234caa..cd9d2c5 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -114,6 +114,8 @@ if(USE_SYSTEM_NCNN)
|
||||
include("${GLSLANG_TARGET_DIR}/HLSLTargets.cmake")
|
||||
endif()
|
||||
include("${GLSLANG_TARGET_DIR}/glslangTargets.cmake")
|
||||
+ include("${GLSLANG_TARGET_DIR}/SPIRV-Tools/SPIRV-ToolsTarget.cmake")
|
||||
+ include("${GLSLANG_TARGET_DIR}/SPIRV-Tools-opt/SPIRV-Tools-optTargets.cmake")
|
||||
include("${GLSLANG_TARGET_DIR}/SPIRVTargets.cmake")
|
||||
|
||||
if (NOT TARGET glslang OR NOT TARGET SPIRV)
|
65
pkgs/tools/graphics/realesrgan-ncnn-vulkan/default.nix
Normal file
65
pkgs/tools/graphics/realesrgan-ncnn-vulkan/default.nix
Normal file
|
@ -0,0 +1,65 @@
|
|||
{ lib
|
||||
, stdenv
|
||||
, fetchzip
|
||||
, fetchFromGitHub
|
||||
, cmake
|
||||
, spirv-headers
|
||||
, vulkan-headers
|
||||
, vulkan-loader
|
||||
, glslang
|
||||
, libgcc
|
||||
, libwebp
|
||||
, ncnn
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "Real-ESRGAN-ncnn-vulkan";
|
||||
version = "0.1.3.2";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "xinntao";
|
||||
repo = pname;
|
||||
rev = "v${version}";
|
||||
sha256 = "sha256-eLAIlOl1sUxijeVPFG+NscZGxDdtrQqVkMuxhegESHk=";
|
||||
};
|
||||
sourceRoot = "source/src";
|
||||
|
||||
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.3.0/realesrgan-ncnn-vulkan-20211212-ubuntu.zip";
|
||||
stripRoot = false;
|
||||
sha256 = "sha256-17k6fewVEXxx7hi+vPXjHAOq4IIUHLh7WC80CwTeFKI=";
|
||||
};
|
||||
|
||||
patches = [
|
||||
./cmakelists.patch
|
||||
./models_path.patch
|
||||
];
|
||||
|
||||
cmakeFlags = [
|
||||
"-DUSE_SYSTEM_NCNN=1"
|
||||
"-DUSE_SYSTEM_WEBP=1"
|
||||
|
||||
"-DGLSLANG_TARGET_DIR=${glslang}/lib/cmake"
|
||||
];
|
||||
|
||||
nativeBuildInputs = [ cmake ];
|
||||
buildInputs = [ vulkan-headers vulkan-loader glslang libgcc libwebp ncnn ];
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace main.cpp --replace REPLACE_MODELS $out/share/models
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin $out/share
|
||||
cp realesrgan-ncnn-vulkan $out/bin/
|
||||
cp -r ${models}/models $out/share
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "NCNN implementation of Real-ESRGAN. Real-ESRGAN aims at developing Practical Algorithms for General Image Restoration.";
|
||||
homepage = "https://github.com/xinntao/Real-ESRGAN-ncnn-vulkan";
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [ tilcreator ];
|
||||
};
|
||||
}
|
22
pkgs/tools/graphics/realesrgan-ncnn-vulkan/models_path.patch
Normal file
22
pkgs/tools/graphics/realesrgan-ncnn-vulkan/models_path.patch
Normal file
|
@ -0,0 +1,22 @@
|
|||
diff --git a/main.cpp b/main.cpp
|
||||
index eb6f6c8..b230bed 100644
|
||||
--- a/main.cpp
|
||||
+++ b/main.cpp
|
||||
@@ -110,7 +110,7 @@ static void print_usage()
|
||||
fprintf(stderr, " -o output-path output image path (jpg/png/webp) or directory\n");
|
||||
fprintf(stderr, " -s scale upscale ratio (can be 2, 4. default=4)\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 pre-trained models(default=models)\n");
|
||||
+ fprintf(stderr, " -m model-path folder path to pre-trained models(default=REPLACE_MODELS)\n");
|
||||
fprintf(stderr, " -n model-name model name (default=realesrgan-x4plus, can be realesrgan-x4plus | realesrgan-x4plus-anime | realesrnet-x4plus | RealESRGANv2-animevideo-xsx2 | RealESRGANv2-animevideo-xsx4 | RealESRGANv2-anime-xsx2 | RealESRGANv2-anime-xsx4)\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");
|
||||
@@ -438,7 +438,7 @@ int main(int argc, char** argv)
|
||||
path_t outputpath;
|
||||
int scale = 4;
|
||||
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;
|
|
@ -9166,6 +9166,8 @@ with pkgs;
|
|||
|
||||
real_time_config_quick_scan = callPackage ../applications/audio/real_time_config_quick_scan { };
|
||||
|
||||
realesrgan-ncnn-vulkan = callPackage ../tools/graphics/realesrgan-ncnn-vulkan { };
|
||||
|
||||
react-native-debugger = callPackage ../development/tools/react-native-debugger { };
|
||||
|
||||
read-edid = callPackage ../os-specific/linux/read-edid { };
|
||||
|
@ -19015,6 +19017,8 @@ with pkgs;
|
|||
|
||||
nanovna-saver = libsForQt5.callPackage ../applications/science/electronics/nanovna-saver { };
|
||||
|
||||
ncnn = callPackage ../development/libraries/ncnn { };
|
||||
|
||||
ndpi = callPackage ../development/libraries/ndpi { };
|
||||
|
||||
nemo-qml-plugin-dbus = libsForQt5.callPackage ../development/libraries/nemo-qml-plugin-dbus { };
|
||||
|
|
Loading…
Reference in a new issue