Spaces:
Runtime error
Runtime error
| <!--Copyright 2022 The HuggingFace Team. All rights reserved. | |
| Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | |
| the License. You may obtain a copy of the License at | |
| http://www.apache.org/licenses/LICENSE-2.0 | |
| Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | |
| an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | |
| specific language governing permissions and limitations under the License. | |
| --> | |
| # Text-Guided Image-to-Image Generation | |
| The [`StableDiffusionDepth2ImgPipeline`] lets you pass a text prompt and an initial image to condition the generation of new images as well as a `depth_map` to preserve the images' structure. If no `depth_map` is provided, the pipeline will automatically predict the depth via an integrated depth-estimation model. | |
| ```python | |
| import torch | |
| import requests | |
| from PIL import Image | |
| from diffusers import StableDiffusionDepth2ImgPipeline | |
| pipe = StableDiffusionDepth2ImgPipeline.from_pretrained( | |
| "stabilityai/stable-diffusion-2-depth", | |
| torch_dtype=torch.float16, | |
| ).to("cuda") | |
| url = "http://images.cocodataset.org/val2017/000000039769.jpg" | |
| init_image = Image.open(requests.get(url, stream=True).raw) | |
| prompt = "two tigers" | |
| n_prompt = "bad, deformed, ugly, bad anatomy" | |
| image = pipe(prompt=prompt, image=init_image, negative_prompt=n_prompt, strength=0.7).images[0] | |
| ``` | |