From a3184303b24a28b7b17f0e747f6b01ae1949a37e Mon Sep 17 00:00:00 2001 From: Thomas Chaton Date: Mon, 21 Nov 2022 09:48:23 -0500 Subject: [PATCH 1/2] update --- README.md | 4 ++-- dreambooth_component.py | 2 +- lightning_diffusion/base_diffusion.py | 4 ++++ serve_diffusion_component.py | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d9abb3a..79590f1 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ from lightning_diffusion import BaseDiffusion, models class ServeDiffusion(BaseDiffusion): def setup(self, *args, **kwargs): - self._model = diffusers.StableDiffusionPipeline.from_pretrained( + self.model = diffusers.StableDiffusionPipeline.from_pretrained( "CompVis/stable-diffusion-v1-4", **models.extras ).to(self.device) @@ -41,7 +41,7 @@ import torch, diffusers class ServeDreamBoothDiffusion(BaseDiffusion): def setup(self): - self._model = diffusers.StableDiffusionPipeline.from_pretrained( + self.model = diffusers.StableDiffusionPipeline.from_pretrained( **models.get_kwargs("CompVis/stable-diffusion-v1-4", self.weights_drive), ).to(self.device) diff --git a/dreambooth_component.py b/dreambooth_component.py index c5eb312..b41800c 100644 --- a/dreambooth_component.py +++ b/dreambooth_component.py @@ -6,7 +6,7 @@ class ServeDreamBoothDiffusion(BaseDiffusion): def setup(self): - self._model = StableDiffusionPipeline.from_pretrained( + self.model = StableDiffusionPipeline.from_pretrained( **models.get_kwargs("CompVis/stable-diffusion-v1-4", self.weights_drive), ).to(self.device) diff --git a/lightning_diffusion/base_diffusion.py b/lightning_diffusion/base_diffusion.py index 3955477..b72553c 100644 --- a/lightning_diffusion/base_diffusion.py +++ b/lightning_diffusion/base_diffusion.py @@ -87,6 +87,10 @@ def model(self) -> StableDiffusionPipeline: assert self._model return self._model + @model.setter + def model(self, model) -> None: + self._model = model + @property def device(self): import torch diff --git a/serve_diffusion_component.py b/serve_diffusion_component.py index 7a1efa1..ed60697 100644 --- a/serve_diffusion_component.py +++ b/serve_diffusion_component.py @@ -7,7 +7,7 @@ class ServeDiffusion(BaseDiffusion): def setup(self, *args, **kwargs): - self._model = diffusers.StableDiffusionPipeline.from_pretrained( + self.model = diffusers.StableDiffusionPipeline.from_pretrained( "CompVis/stable-diffusion-v1-4", **models.extras ).to(self.device) From 8dcc9a7ae423c1e6df7109f73d1adac59699c3d1 Mon Sep 17 00:00:00 2001 From: thomas chaton Date: Wed, 23 Nov 2022 14:17:30 +0000 Subject: [PATCH 2/2] update --- README.md | 11 ++++++----- requirements.txt | 3 +-- serve_diffusion_component.py | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e08ad8a..dc5154d 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ Lightning Diffusion provides components to finetune and serve diffusion model on ### Serve ANY Diffusion Models ```python -# !pip install torch diffusers lightning_diffusion@git+https://github.com/Lightning-AI/lightning-diffusion.git +# !pip install lightning_diffusion@git+https://github.com/Lightning-AI/lightning-diffusion.git import lightning as L -import torch, diffusers +import diffusers from lightning_diffusion import BaseDiffusion, models @@ -21,7 +21,7 @@ class ServeDiffusion(BaseDiffusion): ).to(self.device) def predict(self, data): - out = self.model(prompt=data.prompt) + out = self.model(prompt=data.prompt, num_inference_steps=23) return {"image": self.serialize(out[0][0])} @@ -36,12 +36,13 @@ Use the DreamBooth fine-tuning methodology from the paper `Fine Tuning Text-to-I ```python import lightning as L from lightning_diffusion import BaseDiffusion, DreamBoothTuner, models -import torch, diffusers +from diffusers import StableDiffusionPipeline + class ServeDreamBoothDiffusion(BaseDiffusion): def setup(self): - self.model = diffusers.StableDiffusionPipeline.from_pretrained( + self.model = StableDiffusionPipeline.from_pretrained( **models.get_kwargs("CompVis/stable-diffusion-v1-4", self.weights_drive), ).to(self.device) diff --git a/requirements.txt b/requirements.txt index 7d75728..dfd78e2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,6 @@ jsonargparse[signatures] pyyaml==5.4.0 protobuf<4.21.0 lightning_hpo -lightning Pillow>=2.9.0 numpy>=1.9.2 diffusers==0.7.2 @@ -12,6 +11,6 @@ deepspeed ftfy lightning-api-access clip@git+https://github.com/openai/CLIP.git -lightning==1.8.1 +lightning==1.8.3 redis diff --git a/serve_diffusion_component.py b/serve_diffusion_component.py index ed60697..f81bbad 100644 --- a/serve_diffusion_component.py +++ b/serve_diffusion_component.py @@ -1,6 +1,6 @@ # !pip install lightning_diffusion@git+https://github.com/Lightning-AI/lightning-diffusion.git import lightning as L -import torch, diffusers +import diffusers from lightning_diffusion import BaseDiffusion, models