Skip to content

Commit

Permalink
feat(sd-3): add stablediffusion 3 support (mudler#2591)
Browse files Browse the repository at this point in the history
* feat(sd-3): add stablediffusion 3 support

Signed-off-by: Ettore Di Giacinto <[email protected]>

* deps(diffusers): add sentencepiece

Signed-off-by: Ettore Di Giacinto <[email protected]>

* models(gallery): add stablediffusion-3

Signed-off-by: Ettore Di Giacinto <[email protected]>

---------

Signed-off-by: Ettore Di Giacinto <[email protected]>
  • Loading branch information
mudler authored Jun 18, 2024
1 parent 7f13e3a commit ecbb61c
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
13 changes: 12 additions & 1 deletion backend/python/diffusers/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import grpc

from diffusers import StableDiffusionXLPipeline, StableDiffusionDepth2ImgPipeline, DPMSolverMultistepScheduler, StableDiffusionPipeline, DiffusionPipeline, EulerAncestralDiscreteScheduler
from diffusers import StableDiffusion3Pipeline, StableDiffusionXLPipeline, StableDiffusionDepth2ImgPipeline, DPMSolverMultistepScheduler, StableDiffusionPipeline, DiffusionPipeline, EulerAncestralDiscreteScheduler
from diffusers import StableDiffusionImg2ImgPipeline, AutoPipelineForText2Image, ControlNetModel, StableVideoDiffusionPipeline
from diffusers.pipelines.stable_diffusion import safety_checker
from diffusers.utils import load_image,export_to_video
Expand Down Expand Up @@ -225,6 +225,17 @@ def LoadModel(self, request, context):
torch_dtype=torchType,
use_safetensors=True,
variant=variant)
elif request.PipelineType == "StableDiffusion3Pipeline":
if fromSingleFile:
self.pipe = StableDiffusion3Pipeline.from_single_file(modelFile,
torch_dtype=torchType,
use_safetensors=True)
else:
self.pipe = StableDiffusion3Pipeline.from_pretrained(
request.Model,
torch_dtype=torchType,
use_safetensors=True,
variant=variant)

if CLIPSKIP and request.CLIPSkip != 0:
self.clip_skip = request.CLIPSkip
Expand Down
3 changes: 2 additions & 1 deletion backend/python/diffusers/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ grpcio==1.64.0
opencv-python
pillow
protobuf
sentencepiece
torch
transformers
certifi
certifi
15 changes: 15 additions & 0 deletions gallery/index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2580,6 +2580,21 @@
- filename: DreamShaper_8_pruned.safetensors
uri: huggingface://Lykon/DreamShaper/DreamShaper_8_pruned.safetensors
sha256: 879db523c30d3b9017143d56705015e15a2cb5628762c11d086fed9538abd7fd
- name: stable-diffusion-3-medium
icon: https://huggingface.co/leo009/stable-diffusion-3-medium/resolve/main/sd3demo.jpg
license: other
description: |
Stable Diffusion 3 Medium is a Multimodal Diffusion Transformer (MMDiT) text-to-image model that features greatly improved performance in image quality, typography, complex prompt understanding, and resource-efficiency.
urls:
- https://huggingface.co/stabilityai/stable-diffusion-3-medium
- https://huggingface.co/leo009/stable-diffusion-3-medium
tags:
- text-to-image
- stablediffusion
- python
- sd-3
- gpu
url: "github:mudler/LocalAI/gallery/stablediffusion3.yaml@master"
- &whisper
## Whisper
url: "github:mudler/LocalAI/gallery/whisper-base.yaml@master"
Expand Down
14 changes: 14 additions & 0 deletions gallery/stablediffusion3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: "stable-diffusion-3-medium"

config_file: |
backend: diffusers
diffusers:
cuda: true
enable_parameters: negative_prompt,num_inference_steps
pipeline_type: StableDiffusion3Pipeline
f16: false
name: sd3
parameters:
model: v2ray/stable-diffusion-3-medium-diffusers
step: 25

0 comments on commit ecbb61c

Please sign in to comment.