111 lines
4.5 KiB
Plaintext
111 lines
4.5 KiB
Plaintext
|
<!--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.
|
||
|
-->
|
||
|
|
||
|
<p align="center">
|
||
|
<br>
|
||
|
<img src="https://raw.githubusercontent.com/huggingface/diffusers/77aadfee6a891ab9fcfb780f87c693f7a5beeb8e/docs/source/imgs/diffusers_library.jpg" width="400"/>
|
||
|
<br>
|
||
|
</p>
|
||
|
|
||
|
# 🧨 Diffusers
|
||
|
|
||
|
|
||
|
🤗 Diffusers provides pretrained diffusion models across multiple modalities, such as vision and audio, and serves
|
||
|
as a modular toolbox for inference and training of diffusion models.
|
||
|
|
||
|
More precisely, 🤗 Diffusers offers:
|
||
|
|
||
|
- State-of-the-art diffusion pipelines that can be run in inference with just a couple of lines of code (see [src/diffusers/pipelines](https://github.com/huggingface/diffusers/tree/main/src/diffusers/pipelines)).
|
||
|
- Various noise schedulers that can be used interchangeably for the prefered speed vs. quality trade-off in inference (see [src/diffusers/schedulers](https://github.com/huggingface/diffusers/tree/main/src/diffusers/schedulers)).
|
||
|
- Multiple types of models, such as UNet, that can be used as building blocks in an end-to-end diffusion system (see [src/diffusers/models](https://github.com/huggingface/diffusers/tree/main/src/diffusers/models)).
|
||
|
- Training examples to show how to train the most popular diffusion models (see [examples](https://github.com/huggingface/diffusers/tree/main/examples)).
|
||
|
|
||
|
# Installation
|
||
|
|
||
|
Install Diffusers for with PyTorch. Support for other libraries will come in the future
|
||
|
|
||
|
🤗 Diffusers is tested on Python 3.6+, and PyTorch 1.4.0+.
|
||
|
|
||
|
## Install with pip
|
||
|
|
||
|
You should install 🤗 Diffusers in a [virtual environment](https://docs.python.org/3/library/venv.html).
|
||
|
If you're unfamiliar with Python virtual environments, take a look at this [guide](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/).
|
||
|
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:
|
||
|
|
||
|
```bash
|
||
|
python -m venv .env
|
||
|
```
|
||
|
|
||
|
Activate the virtual environment:
|
||
|
|
||
|
```bash
|
||
|
source .env/bin/activate
|
||
|
```
|
||
|
|
||
|
Now you're ready to install 🤗 Diffusers with the following command:
|
||
|
|
||
|
```bash
|
||
|
pip install diffusers
|
||
|
```
|
||
|
|
||
|
## Install from source
|
||
|
|
||
|
Install 🤗 Diffusers from source with the following command:
|
||
|
|
||
|
```bash
|
||
|
pip install git+https://github.com/huggingface/diffusers
|
||
|
```
|
||
|
|
||
|
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](https://github.com/huggingface/transformers/issues) 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:
|
||
|
|
||
|
```bash
|
||
|
git clone https://github.com/huggingface/diffusers.git
|
||
|
cd transformers
|
||
|
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.7/site-packages/`, Python will also search the folder you cloned to: `~/diffusers/`.
|
||
|
|
||
|
<Tip warning={true}>
|
||
|
|
||
|
You must keep the `diffusers` folder if you want to keep using the library.
|
||
|
|
||
|
</Tip>
|
||
|
|
||
|
Now you can easily update your clone to the latest version of 🤗 Diffusers with the following command:
|
||
|
|
||
|
```bash
|
||
|
cd ~/diffusers/
|
||
|
git pull
|
||
|
```
|
||
|
|
||
|
Your Python environment will find the `main` version of 🤗 Diffuers on the next run.
|
||
|
|