Skip to content

Installation

๐Ÿค— Diffusers is tested on Python 3.8+, MindSpore 2.3+. Follow the installation instructions below for the deep learning library you are using:

Install with pip

You should install ๐Ÿค— Diffusers in a virtual environment. If you're unfamiliar with Python virtual environments, take a look at this guide. A virtual environment makes it easier to manage different projects and avoid compatibility issues between dependencies.

Start by creating a virtual environment in your project directory:

python -m venv .env

Activate the virtual environment:

source .env/bin/activate

You should also install ๐Ÿค— Transformers because ๐Ÿค— Diffusers relies on its models:

pip install mindone transformers

Install from source

Before installing ๐Ÿค— Diffusers from source, make sure you have MindSpore installed.

Then install ๐Ÿค— Diffusers from source:

pip install git+https://github.com/mindspore-lab/mindone

This command installs the bleeding edge main version rather than the latest stable version. The main version is useful for staying up-to-date with the latest developments. For instance, if a bug has been fixed since the last official release but a new release hasn't been rolled out yet. However, this means the main version may not always be stable. We strive to keep the main version operational, and most issues are usually resolved within a few hours or a day. If you run into a problem, please open an Issue so we can fix it even sooner!

Editable install

You will need an editable install if you'd like to:

  • Use the main version of the source code.
  • Contribute to ๐Ÿค— Diffusers and need to test changes in the code.

Clone the repository and install ๐Ÿค— Diffusers with the following commands:

git clone https://github.com/mindspore-lab/mindone.git
cd mindone
pip install -e .

These commands will link the folder you cloned the repository to and your Python library paths. Python will now look inside the folder you cloned to in addition to the normal library paths. For example, if your Python packages are typically installed in ~/anaconda3/envs/main/lib/python3.8/site-packages/, Python will also search the ~/mindone/ folder you cloned to.

Warning

You must keep the mindone folder if you want to keep using the library.

Now you can easily update your clone to the latest version of ๐Ÿค— Diffusers with the following command:

cd ~/mindone/
git pull

Your Python environment will find the main version of ๐Ÿค— Diffusers on the next run.

Cache

Model weights and files are downloaded from the Hub to a cache which is usually your home directory. You can change the cache location by specifying the HF_HOME or HUGGINFACE_HUB_CACHE environment variables or configuring the cache_dir parameter in methods like [~DiffusionPipeline.from_pretrained].

Cached files allow you to run ๐Ÿค— Diffusers offline. To prevent ๐Ÿค— Diffusers from connecting to the internet, set the HF_HUB_OFFLINE environment variable to True and ๐Ÿค— Diffusers will only load previously downloaded files in the cache.

export HF_HUB_OFFLINE=True

For more details about managing and cleaning the cache, take a look at the caching guide.

Telemetry logging

Our library gathers telemetry information during [~DiffusionPipeline.from_pretrained] requests. The data gathered includes the version of ๐Ÿค— Diffusers and PyTorch/Flax, the requested model or pipeline class, and the path to a pretrained checkpoint if it is hosted on the Hugging Face Hub. This usage data helps us debug issues and prioritize new features. Telemetry is only sent when loading models and pipelines from the Hub, and it is not collected if you're loading local files.

We understand that not everyone wants to share additional information,and we respect your privacy. You can disable telemetry collection by setting the DISABLE_TELEMETRY environment variable from your terminal:

On Linux/MacOS:

export DISABLE_TELEMETRY=YES

On Windows:

set DISABLE_TELEMETRY=YES