Buckets:

mishig's picture
|
download
raw
6.61 kB

Stable Diffusion 2

Stable Diffusion 2, orijinal Stable Diffusion çalışmasının üzerine inşa edilmiş, Stability AI ve LAION’dan Robin Rombach ve Katherine Crowson tarafından yönetilen bir metinden görüntüye latent diffusion modelidir.

Stable Diffusion 2.0 sürümü, LAION tarafından Stability AI desteğiyle geliştirilen ve daha önceki V1 sürümlerine kıyasla üretilen görsellerin kalitesini büyük ölçüde artıran, tamamen yeni bir metin kodlayıcı (OpenCLIP) kullanılarak eğitilen sağlam metinden görsel modellerini içerir. Bu sürümdeki metinden görsel modelleri, varsayılan olarak hem 512x512 hem de 768x768 piksel çözünürlüklerinde görsel üretebilir. Bu modeller, Stability AI'daki DeepFloyd ekibi tarafından oluşturulan LAION-5B veri setinin estetik bir alt kümesinde eğitilmiş olup ardından LAION'un NSFW filtresi kullanılarak yetişkin içeriği kaldırılacak şekilde daha da filtrelenmiştir.

Stable Diffusion 2'nin nasıl çalıştığı ve orijinal Stable Diffusion'dan nasıl farklılaştığına dair daha fazla ayrıntı için lütfen resmi duyuru yazısına bakın.

Stable Diffusion 2 mimarisi, orijinal Stable Diffusion model mimarisiyle büyük ölçüde aynıdır; Stable Diffusion 2'nin nasıl kullanılacağına dair API dokümantasyonuna göz atın. Makul bir hız/kalite dengesi sağladığı ve yalnızca 20 adımla çalıştırılabildiği için DPMSolverMultistepScheduler kullanmanızı öneririz.

Stable Diffusion 2, metinden görüntüye, inpainting, süper çözünürlük ve derinlikten görüntüye gibi görevler için kullanılabilir:

Görev Depo
metinden görüntüye (512x512) stabilityai/stable-diffusion-2-base
metinden görüntüye (768x768) stabilityai/stable-diffusion-2
inpainting stabilityai/stable-diffusion-2-inpainting
super-resolution stable-diffusion-x4-upscaler
derinlikten görüntüye stabilityai/stable-diffusion-2-depth

Stable Diffusion 2'nin her görev için nasıl kullanılacağına dair bazı örnekler:

Scheduler hızı ve kalitesi arasındaki ödünleşimi nasıl keşfedebileceğinizi ve pipeline bileşenlerini nasıl verimli bir şekilde yeniden kullanabileceğinizi öğrenmek için Stable Diffusion İpuçları bölümünü mutlaka inceleyin!

Bir görev için resmi kontrol noktalarından birini kullanmakla ilgileniyorsanız, CompVis ve Stability AI Hub kuruluşlarını keşfedin!

Metinden görüntüye

from diffusers import DiffusionPipeline, DPMSolverMultistepScheduler
import torch

repo_id = "stabilityai/stable-diffusion-2-base"
pipe = DiffusionPipeline.from_pretrained(repo_id, dtype=torch.float16, variant="fp16")

pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
pipe = pipe.to("cuda")  # or "mps", "xpu", "cpu"

prompt = "High quality photo of an astronaut riding a horse in space"
image = pipe(prompt, num_inference_steps=25).images[0]
image

Inpainting

import torch
from diffusers import DiffusionPipeline, DPMSolverMultistepScheduler
from diffusers.utils import load_image, make_image_grid

img_url = "https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo.png"
mask_url = "https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo_mask.png"

init_image = load_image(img_url).resize((512, 512))
mask_image = load_image(mask_url).resize((512, 512))

repo_id = "stabilityai/stable-diffusion-2-inpainting"
pipe = DiffusionPipeline.from_pretrained(repo_id, dtype=torch.float16, variant="fp16")

pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
pipe = pipe.to("cuda")  # or "mps", "xpu", "cpu"

prompt = "Face of a yellow cat, high resolution, sitting on a park bench"
image = pipe(prompt=prompt, image=init_image, mask_image=mask_image, num_inference_steps=25).images[0]
make_image_grid([init_image, mask_image, image], rows=1, cols=3)

Süper çözünürlük

from diffusers import StableDiffusionUpscalePipeline
from diffusers.utils import load_image, make_image_grid
import torch

# load model and scheduler
model_id = "stabilityai/stable-diffusion-x4-upscaler"
pipeline = StableDiffusionUpscalePipeline.from_pretrained(model_id, dtype=torch.float16)
pipeline = pipeline.to("cuda")  # or "mps", "xpu", "cpu"

# let's download an  image
url = "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd2-upscale/low_res_cat.png"
low_res_img = load_image(url)
low_res_img = low_res_img.resize((128, 128))
prompt = "a white cat"
upscaled_image = pipeline(prompt=prompt, image=low_res_img).images[0]
make_image_grid([low_res_img.resize((512, 512)), upscaled_image.resize((512, 512))], rows=1, cols=2)

Derinlikten görüntüye

import torch
from diffusers import StableDiffusionDepth2ImgPipeline
from diffusers.utils import load_image, make_image_grid

pipe = StableDiffusionDepth2ImgPipeline.from_pretrained(
    "stabilityai/stable-diffusion-2-depth",
    dtype=torch.float16,
).to("cuda")  # or "mps", "xpu", "cpu"

url = "http://images.cocodataset.org/val2017/000000039769.jpg"
init_image = load_image(url)
prompt = "two tigers"
negative_prompt = "bad, deformed, ugly, bad anotomy"
image = pipe(prompt=prompt, image=init_image, negative_prompt=negative_prompt, strength=0.7).images[0]
make_image_grid([init_image, image], rows=1, cols=2)

Xet Storage Details

Size:
6.61 kB
·
Xet hash:
45df7a30c0dcc8761f99cc25484931593bc790cafc70e4ac51e84ae1a3878d37

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.