Skip to content

Commit

Permalink
stable-diffusion-webui
Browse files Browse the repository at this point in the history
  • Loading branch information
arcnmx committed Mar 6, 2023
1 parent 7da23cb commit 8256007
Show file tree
Hide file tree
Showing 9 changed files with 527 additions and 1 deletion.
19 changes: 18 additions & 1 deletion flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
url = "github:koboldai/koboldai-client/1.19.2";
flake = false;
};
webui-src = {
url = "github:AUTOMATIC1111/stable-diffusion-webui";
flake = false;
};
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
Expand All @@ -38,6 +42,7 @@
./modules/aipython3
./projects/invokeai
./projects/koboldai
./projects/webui
./website
];
};
Expand Down
5 changes: 5 additions & 0 deletions modules/aipython3/overlays.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pkgs: {
rmCallPackage = path: args: rm (callPackage path args);
in {
safetensors = callPackage ../../packages/safetensors { };
tensorflow-io-bin = callPackage ../../packages/tensorflow-io-bin { };
compel = callPackage ../../packages/compel { };
apispec-webframeworks = callPackage ../../packages/apispec-webframeworks { };
pydeprecate = callPackage ../../packages/pydeprecate { };
Expand Down Expand Up @@ -61,6 +62,10 @@ pkgs: {
jsonmerge = callPackage ../../packages/jsonmerge { };
clean-fid = callPackage ../../packages/clean-fid { };
getpass-asterisk = callPackage ../../packages/getpass-asterisk { };
stable-diffusion = callPackage ../../packages/stable-diffusion { };
deepdanbooru = callPackage ../../packages/deepdanbooru { };

tensorflow-io = final.tensorflow-io-bin;
};

torchRocm = final: prev: rec {
Expand Down
24 changes: 24 additions & 0 deletions packages/deepdanbooru/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{ buildPythonPackage
, fetchFromGitHub
, click
, numpy
, scikit-image
, requests
, six
, tensorflow
, tensorflow-io
}: buildPythonPackage rec {
pname = "deepdanbooru";
version = "2022-10-25";
src = fetchFromGitHub {
owner = "KichangKim";
repo = "DeepDanbooru";
rev = "c48689a85dde0e4a852c1691a7d746abe242e283";
sha256 = "sha256-IPbh7pEJhn1j1SkCLo0l8955pCFKFn+vPFPtfgW4Zog=";
};
propagatedBuildInputs = [
click numpy scikit-image requests six
tensorflow-io tensorflow-io.tensorflow or tensorflow
];
doCheck = false;
}
69 changes: 69 additions & 0 deletions packages/stable-diffusion/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
buildPythonPackage
, pythonRelaxDepsHook
, fetchFromGitHub

, torch
, torchvision
, numpy

, albumentations
, opencv4
, pudb
, imageio
, imageio-ffmpeg
, pytorch-lightning
, protobuf3_20
, omegaconf
, test-tube
, streamlit
, einops
, taming-transformers-rom1504
, torch-fidelity
, torchmetrics
, transformers
, kornia
, k-diffusion
}:
buildPythonPackage rec {
pname = "stable-diffusion";
version = "2022-08-22";

src = fetchFromGitHub {
owner = "CompVis";
repo = pname;
rev = "69ae4b35e0a0f6ee1af8bb9a5d0016ccb27e36dc";
sha256 = "sha256-3YkSUATD/73nJFm4os3ZyNU8koabGB/6iR0XbTUQmVY=";
};

nativeBuildInputs = [ pythonRelaxDepsHook ];
pythonRelaxDeps = [
"transformers"
];

propagatedBuildInputs = [
torch
torchvision
numpy

albumentations
opencv4
pudb
imageio
imageio-ffmpeg
pytorch-lightning
protobuf3_20
omegaconf
test-tube
streamlit
einops
taming-transformers-rom1504
torch-fidelity
torchmetrics
transformers
kornia
k-diffusion
];

doCheck = false;
}
92 changes: 92 additions & 0 deletions packages/tensorflow-io-bin/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{ stdenv
, lib
, fetchurl
, buildPythonPackage
, wheel
, zlib
, python
, keras
, tensorflow
, tensorlow-io-gcs-filesystem ? null
, enableGcsFilesystem ? tensorlow-io-gcs-filesystem != null
}:

let
version = "0.28.0";
pname = "tensorflow-io";
cudaSupport = lib.hasSuffix "-gpu" tensorflow.pname;

packages = {
/*linux_py_37 = {
url = "https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-2.9.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl";
sha256 = lib.fakeHash;
};
linux_py_38 = {
url = "https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-2.9.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl";
sha256 = lib.fakeHash;
};*/
linux_py_39 = {
url = "https://files.pythonhosted.org/packages/91/c8/1ebae5d5583cbe3606d4021e400789ceb0ec9f05169fe6f5a26aa499b867/tensorflow_io-0.28.0-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl";
sha256 = "0000000000000000000000000000000000000000000000000009";
};
linux_py_310 = {
url = "https://files.pythonhosted.org/packages/d8/39/963bccfbb8f36722a52f2de211ec82f912fb1ddb7a821ccace3739492fe4/tensorflow_io-0.28.0-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl";
sha256 = "sha256-Pgu34meOi3JvJREGg0jzUswT5+MJFFwcVfNHmiJ2yTc=";
};
linux_py_311 = {
url = "https://files.pythonhosted.org/packages/10/e1/0d47af2822777c0ce71539edcb065aca17355b9c276ce95355eedb234c87/tensorflow_io-0.28.0-cp311-cp311-manylinux_2_12_x86_64.manylinux2010_x86_64.whl";
sha256 = lib.fakeHash;
};
};
in buildPythonPackage {
pname = "tensorflow-io";
inherit version;
format = "wheel";

src = let
pyVerNoDot = lib.strings.stringAsChars (x: if x == "." then "" else x) python.pythonVersion;
platform = if stdenv.isDarwin then "mac" else "linux";
key = "${platform}_py_${pyVerNoDot}";
in fetchurl packages.${key};

propagatedBuildInputs = [
tensorflow
keras
] ++ lib.optional (enableGcsFilesystem) tensorlow-io-gcs-filesystem;

nativeBuildInputs = [ wheel ];

inherit enableGcsFilesystem;
preConfigure = ''
unset SOURCE_DATE_EPOCH
# Make sure that dist and the wheel file are writable.
chmod u+rwx -R ./dist
pushd dist
orig_name="$(echo ./*.whl)"
wheel unpack --dest unpacked ./*.whl
rm ./*.whl
pushd unpacked/tensorflow_io*
if [[ -z ''${enableGcsFilesystem-} ]]; then
sed -i *.dist-info/METADATA \
-e "/Requires-Dist: tensorflow-io-gcs-filesystem/d"
fi
popd
wheel pack ./unpacked/tensorflow_io*
mv *.whl $orig_name # avoid changes to the _os_arch.whl suffix
popd
'';

pythonImportsCheck = [
"tensorflow_io"
];

passthru = {
inherit tensorflow;
};
}
18 changes: 18 additions & 0 deletions projects/webui/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{ inputs, lib, ... }:

{
perSystem = { config, pkgs, ... }: let
inherit (config.dependencySets) aipython3-amd aipython3-nvidia;

src = inputs.webui-src;
in {
packages = {
webui-amd = aipython3-amd.callPackage ./package.nix {
inherit src;
};
webui-nvidia = aipython3-nvidia.callPackage ./package.nix {
inherit src;
};
};
};
}
Loading

0 comments on commit 8256007

Please sign in to comment.