From debbugs-submit-bounces@debbugs.gnu.org Sat Nov 26 07:12:04 2022 Received: (at 59607) by debbugs.gnu.org; 26 Nov 2022 12:12:04 +0000 Received: from localhost ([127.0.0.1]:38046 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oyu2N-00015s-1o for submit@debbugs.gnu.org; Sat, 26 Nov 2022 07:12:04 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:39926) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oyu2K-00014s-1K for 59607@debbugs.gnu.org; Sat, 26 Nov 2022 07:12:00 -0500 Received: by mail-wm1-f66.google.com with SMTP id 83-20020a1c0256000000b003d03017c6efso7358323wmc.4 for <59607@debbugs.gnu.org>; Sat, 26 Nov 2022 04:12:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:message-id:content-transfer-encoding:to:subject:date :from:from:to:cc:subject:date:message-id:reply-to; bh=S1xNGSAZzmOdxzyxcW8rowRjT/fDpcfR7DeQKFy4zRM=; b=GyO4KAMzldFwRpPgsoZGDlfRlqxHpwLguMhwN8mniBni+7HtqCblUpn6AIgyiHp2Ur WDdGKBuIvW7Nmm3sudaAjtQsgKgSFqdCfWDjG7n0Vz+P65LCNt3wwIN7DRHdh6xC9Yu/ okJsnwiJrZeo0nzXAJUZBCQvJNTUqx0W0W5c2tFVVRgwZC6lxBFMK+FlCiNb0EVrVbEM jb0UGjivXQ2HDwek69rsIWWGGMB1jNM40dzwMp6FcBSCWz2UEb1nJMP0QOOKD0h0JZmR rc+sh6TLgB3641D+IX18uDxMkVbJQ7FD8df1NICUyMNI4mfJAwtzCG6BOFy9FRUyifvb y+Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:content-transfer-encoding:to:subject:date :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=S1xNGSAZzmOdxzyxcW8rowRjT/fDpcfR7DeQKFy4zRM=; b=jcpmG6A5VcIRyfsYeqDGW4ybw24wk5QRRNdMIJy7bsDDmFt1NCQWR2rp8dlPZ73ZnM 1ESky1YqTXOjHHcq+9UT5QzvGehW3aSdFgBWrf4iPLEGmYejZxSUXpCGsU5LI0iaBC81 Jr14pTk16NgQR4BIPHMlaCMdbK+kiKnT/5cVG9x/c+4EiefYXlqDk08MO37SttycRR5N xngggNkgm+E3Qzi5M82x6/9qqYxfw/POFf2Fo+k6E4CcUbYerjuNqlvcQ2btx8do28ke tDOMRNrGxLB/i0zOmQcpWTM73/X9TfRsAUMn0kzUFOwxoLat/Cd8dkX0xXVyWEPp6M4Y lBwg== X-Gm-Message-State: ANoB5plCuMInvSQMYit96SGRro/vkHeanfczP/+GHzSNvP9Xi1f+4Y2z nMZpA4S7d8/ujMfsKbtqbJSxHhltgA8= X-Google-Smtp-Source: AA0mqf4Sc52uA8BJQj96S24Vtwo9wWIvZDJKctone1zElAsOck6NFqAOL1xU9i8YBDZryaDYtdk4dA== X-Received: by 2002:a1c:2743:0:b0:3c6:e471:7400 with SMTP id n64-20020a1c2743000000b003c6e4717400mr17865844wmn.98.1669464714144; Sat, 26 Nov 2022 04:11:54 -0800 (PST) Received: from lumine.fritz.box (85-127-52-93.dsl.dynamic.surfer.at. [85.127.52.93]) by smtp.gmail.com with ESMTPSA id az26-20020a05600c601a00b003d01b84e9b2sm8695059wmb.27.2022.11.26.04.11.53 for <59607@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Nov 2022 04:11:53 -0800 (PST) From: Liliana Marie Prikler Date: Sun, 20 Nov 2022 02:16:54 +0100 Subject: [PATCH 2/8] gnu: Add real-esrgan-ncnn. to: 59607@debbugs.gnu.org Content-Transfer-Encoding: 7bit Message-ID: <3823ee69ed8ec08192f0c2ebc26fe8b3d399b381.camel@gmail.com> MIME-Version: 1.0 X-Spam-Score: 2.1 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * gnu/packages/machine-learning.scm (real-esrgan-ncnn): New variable. --- gnu/packages/machine-learning.scm | 44 ++++ ...real-resgan-ncnn-simplify-model-path.patch | 195 ++++++++++++++++++ 2 files cha [...] Content analysis details: (2.1 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 2.1 DATE_IN_PAST_96_XX Date: is 96 hours or more before Received: date 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (liliana.prikler[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.128.66 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.128.66 listed in wl.mailspike.net] X-Debbugs-Envelope-To: 59607 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.1 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * gnu/packages/machine-learning.scm (real-esrgan-ncnn): New variable. --- gnu/packages/machine-learning.scm | 44 ++++ ...real-resgan-ncnn-simplify-model-path.patch | 195 ++++++++++++++++++ 2 files cha [...] Content analysis details: (1.1 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.128.66 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.128.66 listed in wl.mailspike.net] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 2.1 DATE_IN_PAST_96_XX Date: is 96 hours or more before Received: date 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (liliana.prikler[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager * gnu/packages/machine-learning.scm (real-esrgan-ncnn): New variable. --- gnu/packages/machine-learning.scm | 44 ++++ ...real-resgan-ncnn-simplify-model-path.patch | 195 ++++++++++++++++++ 2 files changed, 239 insertions(+) create mode 100644 gnu/packages/patches/real-resgan-ncnn-simplify-model-path.patch diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm index e984e3004b..0566f4bd69 100644 --- a/gnu/packages/machine-learning.scm +++ b/gnu/packages/machine-learning.scm @@ -781,6 +781,50 @@ (define-public ncnn C++. It supports parallel computing as well as GPU acceleration via Vulkan.") (license license:bsd-3))) +(define-public real-esrgan-ncnn + (package + (name "real-esrgan-ncnn") + (version "0.2.0") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/xinntao/Real-ESRGAN-ncnn-vulkan") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (patches + (search-patches + "real-resgan-ncnn-simplify-model-path.patch")) + (sha256 + (base32 "1hlrq8b4848vgj2shcxz68d98p9wd5mf619v5d04pwg40s85zqqp")))) + (build-system cmake-build-system) + (arguments + (list #:tests? #f ; No tests + #:configure-flags + #~(list "-DUSE_SYSTEM_NCNN=TRUE" + "-DUSE_SYSTEM_WEBP=TRUE" + (string-append "-DGLSLANG_TARGET_DIR=" + #$(this-package-input "glslang") + "/lib/cmake")) + #:phases #~(modify-phases %standard-phases + (add-after 'unpack 'chdir + (lambda _ + (chdir "src"))) + (replace 'install + (lambda* (#:key outputs #:allow-other-keys) + (let ((bin (string-append (assoc-ref outputs "out") + "/bin"))) + (mkdir-p bin) + (install-file "realesrgan-ncnn-vulkan" bin))))))) + (inputs (list glslang libwebp ncnn vulkan-headers vulkan-loader)) + (home-page "https://github.com/xinntao/Real-ESRGAN") + (synopsis "Restore low-resolution images") + (description "Real-ESRGAN is a @acronym{GAN, Generative Adversarial Network} +aiming to restore low-resolution images. The techniques used are described in +the paper 'Real-ESRGAN: Training Real-World Blind Super-Resolution with Pure +Synthetic Data' by Xintao Wang, Liangbin Xie, Chao Dong, and Ying Shan. +This package provides an implementation built on top of ncnn.") + (license license:expat))) + (define-public onnx (package (name "onnx") diff --git a/gnu/packages/patches/real-resgan-ncnn-simplify-model-path.patch b/gnu/packages/patches/real-resgan-ncnn-simplify-model-path.patch new file mode 100644 index 0000000000..9a02269718 --- /dev/null +++ b/gnu/packages/patches/real-resgan-ncnn-simplify-model-path.patch @@ -0,0 +1,195 @@ +diff --git a/src/main.cpp b/src/main.cpp +index ebe0e62..ddfb742 100644 +--- a/src/main.cpp ++++ b/src/main.cpp +@@ -109,8 +109,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, 3, 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 the pre-trained models. default=models\n"); +- fprintf(stderr, " -n model-name model name (default=realesr-animevideov3, can be realesr-animevideov3 | realesrgan-x4plus | realesrgan-x4plus-anime | realesrnet-x4plus)\n"); ++ fprintf(stderr, " -m model-path model and parameter file name (sans .bin and .param extension)\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"); + fprintf(stderr, " -x enable tta mode\n"); +@@ -438,8 +437,7 @@ int main(int argc, char** argv) + path_t outputpath; + int scale = 4; + std::vector tilesize; +- path_t model = PATHSTR("models"); +- path_t modelname = PATHSTR("realesr-animevideov3"); ++ path_t model = PATHSTR(""); + std::vector gpuid; + int jobs_load = 1; + std::vector jobs_proc; +@@ -451,7 +449,7 @@ int main(int argc, char** argv) + #if _WIN32 + setlocale(LC_ALL, ""); + wchar_t opt; +- while ((opt = getopt(argc, argv, L"i:o:s:t:m:n:g:j:f:vxh")) != (wchar_t)-1) ++ while ((opt = getopt(argc, argv, L"i:o:t:m:g:j:f:vxh")) != (wchar_t)-1) + { + switch (opt) + { +@@ -461,18 +459,12 @@ int main(int argc, char** argv) + case L'o': + outputpath = optarg; + break; +- case L's': +- scale = _wtoi(optarg); +- break; + case L't': + tilesize = parse_optarg_int_array(optarg); + break; + case L'm': + model = optarg; + break; +- case L'n': +- modelname = optarg; +- break; + case L'g': + gpuid = parse_optarg_int_array(optarg); + break; +@@ -497,7 +489,7 @@ int main(int argc, char** argv) + } + #else // _WIN32 + int opt; +- while ((opt = getopt(argc, argv, "i:o:s:t:m:n:g:j:f:vxh")) != -1) ++ while ((opt = getopt(argc, argv, "i:o:t:m:g:j:f:vxh")) != -1) + { + switch (opt) + { +@@ -507,18 +499,12 @@ int main(int argc, char** argv) + case 'o': + outputpath = optarg; + break; +- case 's': +- scale = atoi(optarg); +- break; + case 't': + tilesize = parse_optarg_int_array(optarg); + break; + case 'm': + model = optarg; + break; +- case 'n': +- modelname = optarg; +- break; + case 'g': + gpuid = parse_optarg_int_array(optarg); + break; +@@ -549,6 +535,12 @@ int main(int argc, char** argv) + return -1; + } + ++ if (model.empty()) ++ { ++ fprintf(stderr, "no model given\n"); ++ return -1; ++ } ++ + if (tilesize.size() != (gpuid.empty() ? 1 : gpuid.size()) && !tilesize.empty()) + { + fprintf(stderr, "invalid tilesize argument\n"); +@@ -671,61 +663,17 @@ int main(int argc, char** argv) + } + } + +- int prepadding = 0; +- +- if (model.find(PATHSTR("models")) != path_t::npos +- || model.find(PATHSTR("models2")) != path_t::npos) +- { +- prepadding = 10; +- } +- else +- { +- fprintf(stderr, "unknown model dir type\n"); +- return -1; +- } ++ int prepadding = 10; + +- // if (modelname.find(PATHSTR("realesrgan-x4plus")) != path_t::npos +- // || modelname.find(PATHSTR("realesrnet-x4plus")) != path_t::npos +- // || modelname.find(PATHSTR("esrgan-x4")) != path_t::npos) +- // {} +- // else +- // { +- // fprintf(stderr, "unknown model name\n"); +- // return -1; +- // } + + #if _WIN32 +- wchar_t parampath[256]; +- wchar_t modelpath[256]; +- +- if (modelname == PATHSTR("realesr-animevideov3")) +- { +- swprintf(parampath, 256, L"%s/%s-x%s.param", model.c_str(), modelname.c_str(), std::to_string(scale)); +- swprintf(modelpath, 256, L"%s/%s-x%s.bin", model.c_str(), modelname.c_str(), std::to_string(scale)); +- } +- else{ +- swprintf(parampath, 256, L"%s/%s.param", model.c_str(), modelname.c_str()); +- swprintf(modelpath, 256, L"%s/%s.bin", model.c_str(), modelname.c_str()); +- } +- ++ path_t parampath = model + L".param"; ++ path_t modelpath = model + L".bin"; + #else +- char parampath[256]; +- char modelpath[256]; +- +- if (modelname == PATHSTR("realesr-animevideov3")) +- { +- sprintf(parampath, "%s/%s-x%s.param", model.c_str(), modelname.c_str(), std::to_string(scale).c_str()); +- sprintf(modelpath, "%s/%s-x%s.bin", model.c_str(), modelname.c_str(), std::to_string(scale).c_str()); +- } +- else{ +- sprintf(parampath, "%s/%s.param", model.c_str(), modelname.c_str()); +- sprintf(modelpath, "%s/%s.bin", model.c_str(), modelname.c_str()); +- } ++ path_t parampath = model + ".param"; ++ path_t modelpath = model + ".bin"; + #endif + +- path_t paramfullpath = sanitize_filepath(parampath); +- path_t modelfullpath = sanitize_filepath(modelpath); +- + #if _WIN32 + CoInitializeEx(NULL, COINIT_MULTITHREADED); + #endif +@@ -781,17 +729,14 @@ int main(int argc, char** argv) + uint32_t heap_budget = ncnn::get_gpu_device(gpuid[i])->get_heap_budget(); + + // more fine-grained tilesize policy here +- if (model.find(PATHSTR("models")) != path_t::npos) +- { +- if (heap_budget > 1900) +- tilesize[i] = 200; +- else if (heap_budget > 550) +- tilesize[i] = 100; +- else if (heap_budget > 190) +- tilesize[i] = 64; +- else +- tilesize[i] = 32; +- } ++ if (heap_budget > 1900) ++ tilesize[i] = 200; ++ else if (heap_budget > 550) ++ tilesize[i] = 100; ++ else if (heap_budget > 190) ++ tilesize[i] = 64; ++ else ++ tilesize[i] = 32; + } + + { +@@ -801,7 +746,7 @@ int main(int argc, char** argv) + { + realesrgan[i] = new RealESRGAN(gpuid[i], tta_mode); + +- realesrgan[i]->load(paramfullpath, modelfullpath); ++ realesrgan[i]->load(parampath, modelpath); + + realesrgan[i]->scale = scale; + realesrgan[i]->tilesize = tilesize[i]; -- 2.38.1