diffusers是由 Hugging Face团队开发并维护的开源 Python 库,专门用于加载、使用和定制扩散模型(Diffusion Models),聚焦于生成式 AI 领域(如图像生成、文生图、图生图等)。
它的核心定位是:降低扩散模型的使用门槛 —— 不需要从零实现复杂的扩散算法,实现简单调用 Stable Diffusion、DALL-E 类的扩散模型,同时也支持研究者对模型进行定制和扩展。
在安装diffusers库也遇到了一些问题,这里做一个安装顺序记录:
参考diffusers安装教程:https://huggingface.co/docs/diffusers/installation?install=conda
diffusers库支持:Python 3.8+ and PyTorch 1.4+
(1)创建虚拟环境:
conda create-n diffusion_env python=3.9(2)安装pytorch
conda install pytorch==2.1.1torchvision==0.16.1torchaudio==2.1.1pytorch-cuda=11.8-c pytorch-c nvidia(3)安装diffusers库(利用conda安装):
conda install-c conda-forge diffusers安装后遇到numpy兼容报错问题,解决方法见这篇博文
导出requirements.txt文件:
# 导出所有包(包括系统级包)pip freeze>requirements.txt# 导出当前虚拟环境中的包piplist--format=freeze>requirements.txtdatasets==4.4.2 diffusers==0.35.2 huggingface_hub==0.34.4 matplotlib==3.6.0 numpy==1.26.4 pandas==2.3.3 pillow==11.3.0 torch==2.1.1 torchaudio==2.1.1 torchvision==0.16.1