12 self = p.buildPythonApplication rec {
13 pname = "backgroundremover";
17 src = fetchFromGitHub {
19 repo = "backgroundremover";
21 hash = "sha256-LjVT4j0OzfbVSQgU0z/gzRTLm7N0RQRrfxtTugWwOxs=";
24 models = runCommand "background-remover-models" { } ''
26 cat ${src}/models/u2a{a,b,c,d} > $out/u2net.pth
27 cat ${src}/models/u2ha{a,b,c,d} > $out/u2net_human_seg.pth
28 cp ${src}/models/u2netp.pth $out
32 substituteInPlace backgroundremover/bg.py backgroundremover/u2net/detect.py \
33 --replace-fail 'os.path.expanduser(os.path.join("~", ".u2net", model_name + ".pth"))' "os.path.join(\"$models\", model_name + \".pth\")"
46 propagatedBuildInputs = [
71 pythonImportsCheck = [ "backgroundremover" ];
78 # random no copyright car image from the internet
79 demoImage = fetchurl {
80 url = "https://pics.craiyon.com/2023-07-16/38653769ac3b4e068181cb5ab1e542a1.webp";
81 hash = "sha256-Kvd06eZdibgDbabVVe0+cNTeS1rDnMXIZZpPlHIlfBo=";
84 runCommand "backgroundremover-image-test.png"
86 buildInputs = [ self ];
89 export NUMBA_CACHE_DIR=$(mktemp -d)
90 backgroundremover -i ${demoImage} -o $out
93 updateScript = gitUpdater { rev-prefix = "v"; };
96 doCheck = false; # no tests
99 mainProgram = "backgroundremover";
100 description = "Command line tool to remove background from image and video, made by nadermx to power";
101 homepage = "https://BackgroundRemoverAI.com";
102 downloadPage = "https://github.com/nadermx/backgroundremover/releases";
103 license = licenses.mit;
104 maintainers = [ maintainers.lucasew ];