Buckets:
| # Génération d'images à partir de profondeur guidée par le texte | |
| Le [StableDiffusionDepth2ImgPipeline](/docs/diffusers/main/fr/api/pipelines/stable_diffusion/depth2img#diffusers.StableDiffusionDepth2ImgPipeline) vous permet de transmettre un prompt texte et une image initiale pour conditionner la génération de nouvelles images. En outre, vous pouvez également passer une `depth_map` pour préserver la structure de l'image. Si aucune `depth_map` n'est fournie, le pipeline prédit automatiquement la profondeur via un [modèle d'estimation de la profondeur](https://github.com/isl-org/MiDaS) intégré. | |
| Commencez par créer une instance de [StableDiffusionDepth2ImgPipeline](/docs/diffusers/main/fr/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" | |
| ``` | |
| Passez maintenant votre invite au pipeline. Vous pouvez également passer un `negative_prompt` pour empêcher certains mots de guider la génération d'une image : | |
| ```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) | |
| ``` | |
| | Entrée | Sortie | | |
| |---------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------| | |
| | | | | |
Xet Storage Details
- Size:
- 2.09 kB
- Xet hash:
- d2c6adb78c703be678ac74d706c824c20ac568ae7b34db9f78854f61434d0ea8
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.