Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
25f9388
first_evolutionary_draft
teytaud Sep 20, 2022
d9cdb96
fix
teytaud Sep 20, 2022
dd1299f
fix
teytaud Sep 20, 2022
e8d06f2
fix
teytaud Sep 20, 2022
29672db
fix
teytaud Sep 20, 2022
895ad55
fix
teytaud Sep 20, 2022
a977845
fix
teytaud Sep 20, 2022
d376f3f
fix
teytaud Sep 20, 2022
6d2723e
fix
teytaud Sep 20, 2022
564aa36
fix
teytaud Sep 21, 2022
728fb93
fix
teytaud Sep 21, 2022
51d4c05
fix
teytaud Sep 22, 2022
b4d74c5
fix
teytaud Sep 22, 2022
4cf4832
fix
teytaud Sep 22, 2022
82253b9
fix
teytaud Sep 22, 2022
ab7daf5
fix
teytaud Sep 22, 2022
ec1a080
fix
teytaud Sep 22, 2022
5702317
fix
teytaud Sep 23, 2022
8480363
voronoi_start
teytaud Sep 23, 2022
d2ecd20
fix
teytaud Sep 23, 2022
674aa8e
fix
teytaud Sep 26, 2022
844c3ae
fix
teytaud Sep 26, 2022
b4faf7b
fix
teytaud Sep 26, 2022
a0fe17b
fix
teytaud Sep 26, 2022
a7b95d7
fix
teytaud Sep 26, 2022
0744f86
fix
teytaud Sep 26, 2022
6d5d1c0
fix
teytaud Sep 26, 2022
3d14589
fix
teytaud Sep 26, 2022
36894fa
fix
teytaud Sep 26, 2022
6750d94
fix
teytaud Sep 26, 2022
9cacbb7
fix
teytaud Sep 26, 2022
f75e32f
fix
teytaud Sep 26, 2022
7049273
fix
teytaud Sep 26, 2022
54af2a5
fix
teytaud Sep 26, 2022
20803ee
fix
teytaud Sep 27, 2022
2bbd905
fix
teytaud Sep 27, 2022
29fc38d
fix
teytaud Sep 27, 2022
5b428cb
fix
teytaud Sep 27, 2022
60827c6
fix
teytaud Sep 27, 2022
9a5719a
fix
teytaud Sep 27, 2022
9d9572a
fix
teytaud Sep 27, 2022
4a1789d
fix
teytaud Sep 27, 2022
0ec465a
fix
teytaud Sep 27, 2022
05f6740
fix
teytaud Sep 27, 2022
411200c
fix
teytaud Sep 27, 2022
baca5b4
fix
teytaud Sep 27, 2022
f19b1b3
fix
teytaud Sep 27, 2022
0356ceb
this_version_ok
teytaud Sep 28, 2022
55a0831
fix
teytaud Sep 28, 2022
c60729d
fix
teytaud Sep 28, 2022
cd71c84
fix
teytaud Sep 28, 2022
b84f706
fix
teytaud Sep 29, 2022
eb77929
fix
teytaud Sep 29, 2022
9981400
fix
teytaud Sep 29, 2022
f2fa901
fix
teytaud Oct 1, 2022
ce78634
fix
teytaud Oct 2, 2022
347e19e
fix
teytaud Oct 2, 2022
bfebf01
fix
teytaud Oct 2, 2022
a30527f
fix
teytaud Oct 2, 2022
4701392
fix
teytaud Oct 2, 2022
e77c5d2
fix
teytaud Oct 2, 2022
aeb88ff
fix
teytaud Oct 4, 2022
0be4b40
fix
teytaud Oct 4, 2022
1ee812c
fix
teytaud Oct 5, 2022
19ab206
fix
teytaud Oct 5, 2022
133b1e3
fix
teytaud Oct 5, 2022
be15417
fix
teytaud Oct 6, 2022
ff1961c
fix
teytaud Oct 6, 2022
9b96c3c
voronoi
teytaud Oct 6, 2022
aaa55ea
fix
teytaud Oct 6, 2022
7125a08
fix
teytaud Oct 6, 2022
f5dea90
fix
teytaud Oct 6, 2022
25300f1
fixdoc
teytaud Oct 6, 2022
00b8331
fix
teytaud Oct 6, 2022
9730d90
fix
teytaud Oct 6, 2022
9dd9a5c
fix
teytaud Oct 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,59 @@
# Genetic Stable Diffusion.

This fork of Stable Diffusion uses genetic stuff and a graphical user interface.
It also works in many languages (tested: French and German, should be ok for many more).
It generates many images.
It should work directly on Mac M1.
It should be easy to adap to a machine with GPU.
Without GPU it will be more complicated.
Ping us at the Nevergrad user group if you need help, I'll do my best.

[**Nevergrad Users**](https://www.facebook.com/groups/nevergradusers/)<br/>
[**Doc**](https://docs.google.com/document/d/12Bz095QNuo_ojxSlGENXKL5Law75IUx5_Nm5L5guKgo/edit?usp=sharing)<br/>



## Get a HuggingFace token! This is a fork of HuggingFace's stablediffusion.

Just click here and copy-paste your token:
[**Hugging face tokens**](https://huggingface.co/login?next=%2Fsettings%2Ftokens)<br/>

## Install StableDiffusion as usual, plus a few more stuff. Basically:

You need homebrew.
On a Mac, you need to do special stuff for the MPS: we recommend
[**This page**](https://towardsdatascience.com/gpu-acceleration-comes-to-pytorch-on-m1-macs-195c399efcc1)<br/>

You need to open a terminal. Then:
```
mkdir stablediffusion
cd stablediffusion
git clone git@github.com:teytaud/genetic-stable-diffusion.git .
brew install wget
conda env create -f environment.yaml
conda activate ldm # you can change that name in the environment.yaml file...
conda install pytorch torchvision -c pytorch
pip install transformers diffusers invisible-watermark
pip install -e .
pip install pygame
pip install joblib
pip install pyttsx3
pip install einops
pip install webbrowser
pip install pyfiglet
pip install nevergrad
pip install langdetect
pip install deep-translator
pip install git+https://github.com/sberbank-ai/Real-ESRGAN.git
wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth -P weights
wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth
```

## Then run << python geneticsd.py >>.
You should be asked for a prompt (just <<enter>> if you like the proposed hardcoded prompt), and then a window should be opened.

## Send feedback to [**Nevergrad Users**](https://www.facebook.com/groups/nevergradusers/)<br/>

# Stable Diffusion
*Stable Diffusion was made possible thanks to a collaboration with [Stability AI](https://stability.ai/) and [Runway](https://runwayml.com/) and builds upon our previous work:*

Expand Down
1 change: 1 addition & 0 deletions archimulti_minisd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
echo deprecated.
60 changes: 60 additions & 0 deletions diffusers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from .utils import (
is_inflect_available,
is_onnx_available,
is_scipy_available,
is_transformers_available,
is_unidecode_available,
)


__version__ = "0.3.0"

from .configuration_utils import ConfigMixin
from .modeling_utils import ModelMixin
from .models import AutoencoderKL, UNet2DConditionModel, UNet2DModel, VQModel
from .onnx_utils import OnnxRuntimeModel
from .optimization import (
get_constant_schedule,
get_constant_schedule_with_warmup,
get_cosine_schedule_with_warmup,
get_cosine_with_hard_restarts_schedule_with_warmup,
get_linear_schedule_with_warmup,
get_polynomial_decay_schedule_with_warmup,
get_scheduler,
)
from .pipeline_utils import DiffusionPipeline
from .pipelines import DDIMPipeline, DDPMPipeline, KarrasVePipeline, LDMPipeline, PNDMPipeline, ScoreSdeVePipeline
from .schedulers import (
DDIMScheduler,
DDPMScheduler,
KarrasVeScheduler,
PNDMScheduler,
SchedulerMixin,
ScoreSdeVeScheduler,
)
from .utils import logging


if is_scipy_available():
from .schedulers import LMSDiscreteScheduler
else:
from .utils.dummy_scipy_objects import * # noqa F403

from .training_utils import EMAModel


if is_transformers_available():
from .pipelines import (
LDMTextToImagePipeline,
StableDiffusionImg2ImgPipeline,
StableDiffusionInpaintPipeline,
StableDiffusionPipeline,
)
else:
from .utils.dummy_transformers_objects import * # noqa F403


if is_transformers_available() and is_onnx_available():
from .pipelines import StableDiffusionOnnxPipeline
else:
from .utils.dummy_transformers_and_onnx_objects import * # noqa F403
27 changes: 27 additions & 0 deletions diffusers/commands/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2022 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from abc import ABC, abstractmethod
from argparse import ArgumentParser


class BaseDiffusersCLICommand(ABC):
@staticmethod
@abstractmethod
def register_subcommand(parser: ArgumentParser):
raise NotImplementedError()

@abstractmethod
def run(self):
raise NotImplementedError()
41 changes: 41 additions & 0 deletions diffusers/commands/diffusers_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env python
# Copyright 2022 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from argparse import ArgumentParser

from .env import EnvironmentCommand


def main():
parser = ArgumentParser("Diffusers CLI tool", usage="diffusers-cli <command> [<args>]")
commands_parser = parser.add_subparsers(help="diffusers-cli command helpers")

# Register commands
EnvironmentCommand.register_subcommand(commands_parser)

# Let's go
args = parser.parse_args()

if not hasattr(args, "func"):
parser.print_help()
exit(1)

# Run
service = args.func(args)
service.run()


if __name__ == "__main__":
main()
70 changes: 70 additions & 0 deletions diffusers/commands/env.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Copyright 2022 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import platform
from argparse import ArgumentParser

import huggingface_hub

from .. import __version__ as version
from ..utils import is_torch_available, is_transformers_available
from . import BaseDiffusersCLICommand


def info_command_factory(_):
return EnvironmentCommand()


class EnvironmentCommand(BaseDiffusersCLICommand):
@staticmethod
def register_subcommand(parser: ArgumentParser):
download_parser = parser.add_parser("env")
download_parser.set_defaults(func=info_command_factory)

def run(self):
hub_version = huggingface_hub.__version__

pt_version = "not installed"
pt_cuda_available = "NA"
if is_torch_available():
import torch

pt_version = torch.__version__
pt_cuda_available = torch.cuda.is_available()

transformers_version = "not installed"
if is_transformers_available:
import transformers

transformers_version = transformers.__version__

info = {
"`diffusers` version": version,
"Platform": platform.platform(),
"Python version": platform.python_version(),
"PyTorch version (GPU?)": f"{pt_version} ({pt_cuda_available})",
"Huggingface_hub version": hub_version,
"Transformers version": transformers_version,
"Using GPU in script?": "<fill in>",
"Using distributed or parallel set-up in script?": "<fill in>",
}

print("\nCopy-and-paste the text below in your GitHub issue and FILL OUT the two last points.\n")
print(self.format_dict(info))

return info

@staticmethod
def format_dict(d):
return "\n".join([f"- {prop}: {val}" for prop, val in d.items()]) + "\n"
Loading