Buckets:

mishig's picture
|
download
raw
2.16 kB
# توليد الصور من العمق بتوجيه النص
يتيح لك [StableDiffusionDepth2ImgPipeline](/docs/diffusers/main/ar/api/pipelines/stable_diffusion/depth2img#diffusers.StableDiffusionDepth2ImgPipeline) تمرير موجه نصي وصورة أولية لتوجيه توليد صور جديدة. بالإضافة إلى ذلك، يمكنك أيضًا تمرير `depth_map` للحفاظ على بنية الصورة. إذا لم يتم توفير `depth_map`، فإن خط الأنابيب يتنبأ تلقائيًا بالعمق عبر [نموذج تقدير العمق](https://github.com/isl-org/MiDaS) المدمج.
ابدأ بإنشاء كائن من [StableDiffusionDepth2ImgPipeline](/docs/diffusers/main/ar/api/pipelines/stable_diffusion/depth2img#diffusers.StableDiffusionDepth2ImgPipeline):
```python
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"
```
الآن مرّر موجهك إلى خطّ الأنابيب. يمكنك أيضًا تمرير `negative_prompt` لمنع كلمات معينة من توجيه كيفية توليد الصورة:
```python
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)
```
| المدخل | المخرجات |
|---------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------|
| | |

Xet Storage Details

Size:
2.16 kB
·
Xet hash:
a69f1af04449c9e487635ab2e3ae64c30ef315162978fcf0f628bf62e680ff1d

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