拥抱脸
/
扩散器






? diffusers 是最先进的预训练扩散模型的首选库,用于生成图像、音频甚至分子的 3d 结构。无论您是在寻找简单的推理解决方案还是训练自己的扩散模型,? diffusers 都是一个支持两者的模块化工具箱。我们的库的设计重点是可用性而不是性能,简单而不是简单,可定制性而不是抽象。
? diffusers 提供三个核心组件:
我们建议在 pypi 或 conda 的虚拟环境中安装 ? diffusers。有关安装 pytorch 和 flax 的更多详细信息,请参阅他们的官方文档。
与点(官方...
https://blackforestlabs.ai/announcing-black-forest-labs/
python3 -m venv fluxtest source fluxtest/bin/activate
https://huggingface.co/docs/huggingface_hub/main/en/guides/cli
pip install -u "huggingface_hub[cli]" huggingface-cli login
pip install torch==2.3.1 pip install git+https://github.com/huggingface/diffusers.git pip install transformers==4.43.3 sentencepiece==0.2.0 accelerate==0.33.0 protobuf==5
图像.py
import torch
from diffusers import fluxpipeline
import diffusers
_flux_rope = diffusers.models.transformers.transformer_flux.rope
def new_flux_rope(pos: torch.tensor, dim: int, theta: int) -> torch.tensor:
assert dim % 2 == 0, "the dimension must be even."
if pos.device.type == "mps":
return _flux_rope(pos.to("cpu"), dim, theta).to(device=pos.device)
else:
return _flux_rope(pos, dim, theta)
diffusers.models.transformers.transformer_flux.rope = new_flux_rope
pipe = fluxpipeline.from_pretrained("black-forest-labs/flux.1-schnell", revision='refs/pr/1', torch_dtype=torch.bfloat16).to("mps")
prompt = "japanese girl, photo-realistic"
out = pipe(
prompt=prompt,
guidance_scale=0.,
height=1024,
width=1024,
num_inference_steps=4,
max_sequence_length=256,
).images[0]
out.save("image.png")
最后,运行python脚本生成图像。
python image.py
输出

以上就是使用 Diffuser 运行 Fluxn Mac的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号