Buckets:
| # 无条件图像生成 | |
| 无条件图像生成会生成看起来像是从模型训练数据中随机采样的图像,因为去噪过程不受文本或图像等额外上下文的引导。 | |
| 要开始使用,请使用 [DiffusionPipeline](/docs/diffusers/v0.43.0/zh/api/pipelines/overview#diffusers.DiffusionPipeline) 加载 [anton-l/ddpm-butterflies-128](https://huggingface.co/anton-l/ddpm-butterflies-128) 检查点以生成蝴蝶图像。[DiffusionPipeline](/docs/diffusers/v0.43.0/zh/api/pipelines/overview#diffusers.DiffusionPipeline) 会下载并缓存生成图像所需的所有模型组件。 | |
| ```py | |
| from diffusers import DiffusionPipeline | |
| generator = DiffusionPipeline.from_pretrained("anton-l/ddpm-butterflies-128").to("cuda") # or "mps", "xpu", "cpu" | |
| image = generator().images[0] | |
| image | |
| ``` | |
| > [!TIP] | |
| > 想生成其他主题的图片吗?请查看训练[指南](../training/unconditional_training),了解如何训练模型以生成您自己的图片。 | |
| 输出图像是一个 [`PIL.Image`](https://pillow.readthedocs.io/en/stable/reference/Image.html?highlight=image#the-image-class) 对象,可以保存: | |
| ```py | |
| image.save("generated_image.png") | |
| ``` | |
| 你也可以尝试调整 `num_inference_steps` 参数,该参数用于控制去噪步数。更多的去噪步数通常能生成更高质量的图像,但生成所需的时间也会更长。你可以自由调整此参数,观察其对图像质量的影响。 | |
| ```py | |
| image = generator(num_inference_steps=100).images[0] | |
| image | |
| ``` | |
| 试试下面的 Space,生成一张蝴蝶的图片吧! | |
| <iframe src="https://stevhliu-unconditional-image-generation.hf.space" frameborder="0" width="850" height="500" | |
| > | |
Xet Storage Details
- Size:
- 1.68 kB
- Xet hash:
- 963c49e10b329e6a7d79f232114071c03b8b717ac1b257482a64d380d735047c
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.