From 307c993e8c48c9c2d4ba3dee1b23b73385eb78c5 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Thu, 26 Oct 2023 11:49:25 +0200 Subject: [PATCH 1/2] python311Packages.pytorch-msssim: init at 1.0.0 --- .../python-modules/pytorch-msssim/default.nix | 41 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 43 insertions(+) create mode 100644 pkgs/development/python-modules/pytorch-msssim/default.nix diff --git a/pkgs/development/python-modules/pytorch-msssim/default.nix b/pkgs/development/python-modules/pytorch-msssim/default.nix new file mode 100644 index 000000000000..371ae7514aeb --- /dev/null +++ b/pkgs/development/python-modules/pytorch-msssim/default.nix @@ -0,0 +1,41 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub +, setuptools +, wheel +, torch +}: + +buildPythonPackage rec { + pname = "pytorch-msssim"; + version = "1.0.0"; + pyproject = true; + + src = fetchFromGitHub { + owner = "VainF"; + repo = "pytorch-msssim"; + rev = "refs/tags/v${version}"; + hash = "sha256-bghglwQhgByC7BqbDvImSvt6edKF55NLYEPjqmmSFH8="; + }; + + nativeBuildInputs = [ + setuptools + wheel + ]; + + propagatedBuildInputs = [ + torch + ]; + + pythonImportsCheck = [ "pytorch_msssim" ]; + + # This test doesn't have (automatic) tests + doCheck = false; + + meta = with lib; { + description = "Fast and differentiable MS-SSIM and SSIM for pytorch"; + homepage = "https://github.com/VainF/pytorch-msssim"; + license = licenses.mit; + maintainers = with maintainers; [ GaetanLepage ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index f9ed05e39462..904524f97c5b 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -11642,6 +11642,8 @@ self: super: with self; { pytorch-metric-learning = callPackage ../development/python-modules/pytorch-metric-learning { }; + pytorch-msssim = callPackage ../development/python-modules/pytorch-msssim { }; + pytorch-pfn-extras = callPackage ../development/python-modules/pytorch-pfn-extras { }; pytraccar = callPackage ../development/python-modules/pytraccar { }; From 65575bb2c0b501ccd15edaf89118b2edd1875a03 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Thu, 26 Oct 2023 11:50:00 +0200 Subject: [PATCH 2/2] python311Packages.compressai: init at 1.2.4 --- .../python-modules/compressai/default.nix | 89 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 91 insertions(+) create mode 100644 pkgs/development/python-modules/compressai/default.nix diff --git a/pkgs/development/python-modules/compressai/default.nix b/pkgs/development/python-modules/compressai/default.nix new file mode 100644 index 000000000000..47487a6f633f --- /dev/null +++ b/pkgs/development/python-modules/compressai/default.nix @@ -0,0 +1,89 @@ +{ lib +, buildPythonPackage +, pythonOlder +, fetchFromGitHub +, pybind11 +, setuptools +, wheel +, numpy +, matplotlib +, pytorch-msssim +, scipy +, torch +, torchvision +, ipywidgets +, jupyter +, plotly +, pytestCheckHook +}: + +buildPythonPackage rec { + pname = "compressai"; + version = "1.2.4"; + pyproject = true; + + disabled = pythonOlder "3.6"; + + src = fetchFromGitHub { + owner = "InterDigitalInc"; + repo = "CompressAI"; + rev = "refs/tags/v${version}"; + hash = "sha256-nT2vd7t67agIWobJalORbRuns0UJGRGGbTX2/8vbTiY="; + fetchSubmodules = true; + }; + + nativeBuildInputs = [ + pybind11 + setuptools + wheel + ]; + + propagatedBuildInputs = [ + numpy + matplotlib + pytorch-msssim + scipy + torch + torchvision + ]; + + passthru.optional-dependencies = { + tutorials = [ + ipywidgets + jupyter + ]; + }; + + pythonImportsCheck = [ + "compressai" + "compressai._CXX" + ]; + + preCheck = '' + # We have to delete the source because otherwise it is used intead the installed package. + rm -rf compressai + + export HOME=$(mktemp -d) + ''; + + nativeCheckInputs = [ + plotly + pytestCheckHook + ]; + + disabledTests = [ + # Those tests require internet access to download some weights + "test_image_codec" + "test_update" + "test_eval_model_pretrained" + "test_cheng2020_anchor" + "test_pretrained" + ]; + + meta = with lib; { + description = "A PyTorch library and evaluation platform for end-to-end compression research"; + homepage = "https://github.com/InterDigitalInc/CompressAI"; + license = licenses.bsd3Clear; + maintainers = with maintainers; [ GaetanLepage ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 904524f97c5b..ba3285fb0fc1 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -2242,6 +2242,8 @@ self: super: with self; { compreffor = callPackage ../development/python-modules/compreffor { }; + compressai = callPackage ../development/python-modules/compressai { }; + concurrent-log-handler = callPackage ../development/python-modules/concurrent-log-handler { }; conda = callPackage ../development/python-modules/conda { };