feat(sd-3): add stablediffusion 3 support (#2591)

* feat(sd-3): add stablediffusion 3 support

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* deps(diffusers): add sentencepiece

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* models(gallery): add stablediffusion-3

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

---------

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
Ettore Di Giacinto 2024-06-18 15:09:39 +02:00 committed by GitHub
parent 7f13e3a783
commit ecbb61cbf4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 43 additions and 2 deletions

View File

@ -17,7 +17,7 @@ import backend_pb2_grpc
import grpc 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 import StableDiffusionImg2ImgPipeline, AutoPipelineForText2Image, ControlNetModel, StableVideoDiffusionPipeline
from diffusers.pipelines.stable_diffusion import safety_checker from diffusers.pipelines.stable_diffusion import safety_checker
from diffusers.utils import load_image,export_to_video from diffusers.utils import load_image,export_to_video
@ -225,6 +225,17 @@ class BackendServicer(backend_pb2_grpc.BackendServicer):
torch_dtype=torchType, torch_dtype=torchType,
use_safetensors=True, use_safetensors=True,
variant=variant) 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: if CLIPSKIP and request.CLIPSkip != 0:
self.clip_skip = request.CLIPSkip self.clip_skip = request.CLIPSkip

View File

@ -5,6 +5,7 @@ grpcio==1.64.0
opencv-python opencv-python
pillow pillow
protobuf protobuf
sentencepiece
torch torch
transformers transformers
certifi certifi

View File

@ -2580,6 +2580,21 @@
- filename: DreamShaper_8_pruned.safetensors - filename: DreamShaper_8_pruned.safetensors
uri: huggingface://Lykon/DreamShaper/DreamShaper_8_pruned.safetensors uri: huggingface://Lykon/DreamShaper/DreamShaper_8_pruned.safetensors
sha256: 879db523c30d3b9017143d56705015e15a2cb5628762c11d086fed9538abd7fd 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
## Whisper ## Whisper
url: "github:mudler/LocalAI/gallery/whisper-base.yaml@master" url: "github:mudler/LocalAI/gallery/whisper-base.yaml@master"

View File

@ -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