obs-studio-plugins.obs-backgroundremoval: 0.4.0 -> unstable-2022-05-02

There is no release with OBS 28 support yet.
This commit is contained in:
Raphael Robatsch
2022-11-11 07:04:11 +01:00
committed by Franz Pletz
parent 9e7a3b07e4
commit a9dacbba42
4 changed files with 49 additions and 11 deletions
@@ -8,7 +8,7 @@
{
looking-glass-obs = callPackage ./looking-glass-obs.nix { };
obs-backgroundremoval = callPackage ./obs-backgroundremoval.nix { };
obs-backgroundremoval = callPackage ./obs-backgroundremoval { };
obs-gstreamer = callPackage ./obs-gstreamer.nix { };
@@ -1,7 +1,6 @@
{ lib
, stdenv
, fetchFromGitHub
, fetchpatch
, cmake
, obs-studio
, onnxruntime
@@ -10,15 +9,23 @@
stdenv.mkDerivation rec {
pname = "obs-backgroundremoval";
version = "0.4.0";
version = "unstable-2022-05-02";
src = fetchFromGitHub {
owner = "royshil";
repo = "obs-backgroundremoval";
rev = "v${version}";
sha256 = "sha256-TI1FlhE0+JL50gAZCSsI+g8savX8GRQkH3jYli/66hQ=";
rev = "cc9d4a5711f9388ed110230f9f793bb071577a23";
hash = "sha256-xkVZ4cB642p4DvZAPwI2EVhkfVl5lJhgOQobjNMqpec=";
};
patches = [
# Fix c++ include directives
./includes.patch
# Use CPU backend instead of CUDA/DirectML
./use-cpu-backend.patch
];
nativeBuildInputs = [ cmake ];
buildInputs = [ obs-studio onnxruntime opencv ];
@@ -29,10 +36,9 @@ stdenv.mkDerivation rec {
"-DOnnxruntime_INCLUDE_DIRS=${onnxruntime.dev}/include/onnxruntime/core/session"
];
patches = [ ./obs-backgroundremoval-includes.patch ];
prePatch = ''
sed -i 's/version_from_git()/set(VERSION "${version}")/' CMakeLists.txt
sed -i 's/version_from_git()/set(VERSION "0.4.0")/' CMakeLists.txt
'';
meta = with lib; {
@@ -1,5 +1,5 @@
diff --git a/src/Model.h b/src/Model.h
index 5c21eae..74b8078 100644
index 6a73745..6bb8a7d 100644
--- a/src/Model.h
+++ b/src/Model.h
@@ -1,13 +1,8 @@
@@ -13,11 +13,11 @@ index 5c21eae..74b8078 100644
-#include <onnxruntime_cxx_api.h>
-#include <cpu_provider_factory.h>
-#endif
#ifdef _WIN32
#ifdef WITH_CUDA
#include <cuda_provider_factory.h>
diff --git a/src/background-filter.cpp b/src/background-filter.cpp
index 9fa5794..5d66aee 100644
index 0853818..32c6483 100644
--- a/src/background-filter.cpp
+++ b/src/background-filter.cpp
@@ -1,13 +1,8 @@
@@ -31,6 +31,6 @@ index 9fa5794..5d66aee 100644
-#include <onnxruntime_cxx_api.h>
-#include <cpu_provider_factory.h>
-#endif
#ifdef _WIN32
#ifdef WITH_CUDA
#include <cuda_provider_factory.h>
#endif
@@ -0,0 +1,32 @@
From d04e167f9081a3ec8c49f0967b5b0cec79e40e4d Mon Sep 17 00:00:00 2001
From: Raphael Robatsch <raphael-git@tapesoftware.net>
Date: Fri, 14 Oct 2022 16:55:36 +0200
Subject: [PATCH] unix: use CPU backend instead of DirectML
---
src/background-filter.cpp | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/background-filter.cpp b/src/background-filter.cpp
index 32c6483..55e838f 100644
--- a/src/background-filter.cpp
+++ b/src/background-filter.cpp
@@ -205,10 +205,14 @@ static void createOrtSession(struct background_removal_filter *tf) {
if (tf->useGPU == USEGPU_CUDA) {
Ort::ThrowOnError(OrtSessionOptionsAppendExecutionProvider_CUDA(sessionOptions, 0));
}
-#else
+#elseif _WIN32
if (tf->useGPU == USEGPU_DML) {
Ort::ThrowOnError(OrtSessionOptionsAppendExecutionProvider_DML(sessionOptions, 0));
}
+#else
+ if (tf->useGPU == USEGPU_CPU) {
+ Ort::ThrowOnError(OrtSessionOptionsAppendExecutionProvider_CPU(sessionOptions, 0));
+ }
#endif
tf->session.reset(new Ort::Session(*tf->env, tf->modelFilepath, sessionOptions));
} catch (const std::exception& e) {
--
2.37.3