Buckets:

mishig's picture
|
download
raw
2.03 kB

Generasi gambar dari kedalaman yang dipandu teks

StableDiffusionDepth2ImgPipeline memungkinkan Anda untuk memberikan prompt teks dan gambar awal untuk mengondisikan pembuatan gambar baru. Selain itu, Anda juga dapat memberikan depth_map untuk mempertahankan struktur gambar. Jika tidak ada depth_map yang diberikan, pipeline secara otomatis memprediksi kedalaman melalui model estimasi kedalaman yang terintegrasi.

Mulai dengan membuat instance dari StableDiffusionDepth2ImgPipeline:

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

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

Sekarang kirimkan prompt Anda ke pipeline. Anda juga dapat mengirim negative_prompt untuk mencegah kata-kata tertentu mengarahkan cara gambar dihasilkan:

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

Xet Storage Details

Size:
2.03 kB
·
Xet hash:
d49427c2847b936d56df6c1f897b85ffb7d9403d17ec70ad836c372adf8af31d

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