+
+## Popular libraries using 🧨 Diffusers
+
+- https://github.com/microsoft/TaskMatrix
+- https://github.com/invoke-ai/InvokeAI
+- https://github.com/apple/ml-stable-diffusion
+- https://github.com/Sanster/lama-cleaner
+- https://github.com/IDEA-Research/Grounded-Segment-Anything
+- https://github.com/ashawkey/stable-dreamfusion
+- https://github.com/deep-floyd/IF
+- https://github.com/bentoml/BentoML
+- https://github.com/bmaltais/kohya_ss
+- +3000 other amazing GitHub repositories 💪
+
+Thank you for using us ❤️
+
+## Credits
+
+This library concretizes previous work by many different authors and would not have been possible without their great research and implementations. We'd like to thank, in particular, the following implementations which have helped us in our development and without which the API could not have been as polished today:
+
+- @CompVis' latent diffusion models library, available [here](https://github.com/CompVis/latent-diffusion)
+- @hojonathanho original DDPM implementation, available [here](https://github.com/hojonathanho/diffusion) as well as the extremely useful translation into PyTorch by @pesser, available [here](https://github.com/pesser/pytorch_diffusion)
+- @ermongroup's DDIM implementation, available [here](https://github.com/ermongroup/ddim)
+- @yang-song's Score-VE and Score-VP implementations, available [here](https://github.com/yang-song/score_sde_pytorch)
+
+We also want to thank @heejkoo for the very helpful overview of papers, code and resources on diffusion models, available [here](https://github.com/heejkoo/Awesome-Diffusion-Models) as well as @crowsonkb and @rromb for useful discussions and insights.
+
+## Citation
+
+```bibtex
+@misc{von-platen-etal-2022-diffusers,
+ author = {Patrick von Platen and Suraj Patil and Anton Lozhkov and Pedro Cuenca and Nathan Lambert and Kashif Rasul and Mishig Davaadorj and Thomas Wolf},
+ title = {Diffusers: State-of-the-art diffusion models},
+ year = {2022},
+ publisher = {GitHub},
+ journal = {GitHub repository},
+ howpublished = {\url{https://github.com/huggingface/diffusers}}
+}
+```
diff --git a/diffusers/_typos.toml b/diffusers/_typos.toml
new file mode 100644
index 0000000000000000000000000000000000000000..551099f981e7885fbda9ed28e297bace0e13407b
--- /dev/null
+++ b/diffusers/_typos.toml
@@ -0,0 +1,13 @@
+# Files for typos
+# Instruction: https://github.com/marketplace/actions/typos-action#getting-started
+
+[default.extend-identifiers]
+
+[default.extend-words]
+NIN="NIN" # NIN is used in scripts/convert_ncsnpp_original_checkpoint_to_diffusers.py
+nd="np" # nd may be np (numpy)
+parms="parms" # parms is used in scripts/convert_original_stable_diffusion_to_diffusers.py
+
+
+[files]
+extend-exclude = ["_typos.toml"]
diff --git a/diffusers/diffusers/.github/ISSUE_TEMPLATE/bug-report.yml b/diffusers/diffusers/.github/ISSUE_TEMPLATE/bug-report.yml
new file mode 100644
index 0000000000000000000000000000000000000000..81503635895349c0305a8dea1c2d13fb059754aa
--- /dev/null
+++ b/diffusers/diffusers/.github/ISSUE_TEMPLATE/bug-report.yml
@@ -0,0 +1,80 @@
+name: "\U0001F41B Bug Report"
+description: Report a bug on diffusers
+labels: [ "bug" ]
+body:
+ - type: markdown
+ attributes:
+ value: |
+ Thanks a lot for taking the time to file this issue 🤗.
+ Issues do not only help to improve the library, but also publicly document common problems, questions, workflows for the whole community!
+ Thus, issues are of the same importance as pull requests when contributing to this library ❤️.
+ In order to make your issue as **useful for the community as possible**, let's try to stick to some simple guidelines:
+ - 1. Please try to be as precise and concise as possible.
+ *Give your issue a fitting title. Assume that someone which very limited knowledge of diffusers can understand your issue. Add links to the source code, documentation other issues, pull requests etc...*
+ - 2. If your issue is about something not working, **always** provide a reproducible code snippet. The reader should be able to reproduce your issue by **only copy-pasting your code snippet into a Python shell**.
+ *The community cannot solve your issue if it cannot reproduce it. If your bug is related to training, add your training script and make everything needed to train public. Otherwise, just add a simple Python code snippet.*
+ - 3. Add the **minimum amount of code / context that is needed to understand, reproduce your issue**.
+ *Make the life of maintainers easy. `diffusers` is getting many issues every day. Make sure your issue is about one bug and one bug only. Make sure you add only the context, code needed to understand your issues - nothing more. Generally, every issue is a way of documenting this library, try to make it a good documentation entry.*
+ - type: markdown
+ attributes:
+ value: |
+ For more in-detail information on how to write good issues you can have a look [here](https://huggingface.co/course/chapter8/5?fw=pt)
+ - type: textarea
+ id: bug-description
+ attributes:
+ label: Describe the bug
+ description: A clear and concise description of what the bug is. If you intend to submit a pull request for this issue, tell us in the description. Thanks!
+ placeholder: Bug description
+ validations:
+ required: true
+ - type: textarea
+ id: reproduction
+ attributes:
+ label: Reproduction
+ description: Please provide a minimal reproducible code which we can copy/paste and reproduce the issue.
+ placeholder: Reproduction
+ validations:
+ required: true
+ - type: textarea
+ id: logs
+ attributes:
+ label: Logs
+ description: "Please include the Python logs if you can."
+ render: shell
+ - type: textarea
+ id: system-info
+ attributes:
+ label: System Info
+ description: Please share your system info with us. You can run the command `diffusers-cli env` and copy-paste its output below.
+ placeholder: diffusers version, platform, python version, ...
+ validations:
+ required: true
+ - type: textarea
+ id: who-can-help
+ attributes:
+ label: Who can help?
+ description: |
+ Your issue will be replied to more quickly if you can figure out the right person to tag with @
+ If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
+
+ All issues are read by one of the core maintainers, so if you don't know who to tag, just leave this blank and
+ a core maintainer will ping the right person.
+
+ Please tag fewer than 3 people.
+
+ General library related questions: @patrickvonplaten and @sayakpaul
+
+ Questions on the training examples: @williamberman, @sayakpaul, @yiyixuxu
+
+ Questions on memory optimizations, LoRA, float16, etc.: @williamberman, @patrickvonplaten, and @sayakpaul
+
+ Questions on schedulers: @patrickvonplaten and @williamberman
+
+ Questions on models and pipelines: @patrickvonplaten, @sayakpaul, and @williamberman
+
+ Questions on JAX- and MPS-related things: @pcuenca
+
+ Questions on audio pipelines: @patrickvonplaten, @kashif, and @sanchit-gandhi
+
+ Documentation: @stevhliu and @yiyixuxu
+ placeholder: "@Username ..."
diff --git a/diffusers/diffusers/.github/ISSUE_TEMPLATE/config.yml b/diffusers/diffusers/.github/ISSUE_TEMPLATE/config.yml
new file mode 100644
index 0000000000000000000000000000000000000000..304c02ca9cc44d79b2616ae59023da21f6283c65
--- /dev/null
+++ b/diffusers/diffusers/.github/ISSUE_TEMPLATE/config.yml
@@ -0,0 +1,7 @@
+contact_links:
+ - name: Blank issue
+ url: https://github.com/huggingface/diffusers/issues/new
+ about: Other
+ - name: Forum
+ url: https://discuss.huggingface.co/
+ about: General usage questions and community discussions
\ No newline at end of file
diff --git a/diffusers/diffusers/.github/ISSUE_TEMPLATE/feature_request.md b/diffusers/diffusers/.github/ISSUE_TEMPLATE/feature_request.md
new file mode 100644
index 0000000000000000000000000000000000000000..24405ec4fa1d1ebf802813bc1af3ce2840ef2f9c
--- /dev/null
+++ b/diffusers/diffusers/.github/ISSUE_TEMPLATE/feature_request.md
@@ -0,0 +1,20 @@
+---
+name: "\U0001F680 Feature request"
+about: Suggest an idea for this project
+title: ''
+labels: ''
+assignees: ''
+
+---
+
+**Is your feature request related to a problem? Please describe.**
+A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
+
+**Describe the solution you'd like**
+A clear and concise description of what you want to happen.
+
+**Describe alternatives you've considered**
+A clear and concise description of any alternative solutions or features you've considered.
+
+**Additional context**
+Add any other context or screenshots about the feature request here.
diff --git a/diffusers/diffusers/.github/ISSUE_TEMPLATE/feedback.md b/diffusers/diffusers/.github/ISSUE_TEMPLATE/feedback.md
new file mode 100644
index 0000000000000000000000000000000000000000..25808b6575a405694f64dbf1b5a0ece8e0fcd2e2
--- /dev/null
+++ b/diffusers/diffusers/.github/ISSUE_TEMPLATE/feedback.md
@@ -0,0 +1,12 @@
+---
+name: "💬 Feedback about API Design"
+about: Give feedback about the current API design
+title: ''
+labels: ''
+assignees: ''
+
+---
+
+**What API design would you like to have changed or added to the library? Why?**
+
+**What use case would this enable or better enable? Can you give us a code example?**
diff --git a/diffusers/diffusers/.github/ISSUE_TEMPLATE/new-model-addition.yml b/diffusers/diffusers/.github/ISSUE_TEMPLATE/new-model-addition.yml
new file mode 100644
index 0000000000000000000000000000000000000000..2055599e44cd3f61ac6a8b07dea114fb54bf9210
--- /dev/null
+++ b/diffusers/diffusers/.github/ISSUE_TEMPLATE/new-model-addition.yml
@@ -0,0 +1,31 @@
+name: "\U0001F31F New model/pipeline/scheduler addition"
+description: Submit a proposal/request to implement a new diffusion model / pipeline / scheduler
+labels: [ "New model/pipeline/scheduler" ]
+
+body:
+ - type: textarea
+ id: description-request
+ validations:
+ required: true
+ attributes:
+ label: Model/Pipeline/Scheduler description
+ description: |
+ Put any and all important information relative to the model/pipeline/scheduler
+
+ - type: checkboxes
+ id: information-tasks
+ attributes:
+ label: Open source status
+ description: |
+ Please note that if the model implementation isn't available or if the weights aren't open-source, we are less likely to implement it in `diffusers`.
+ options:
+ - label: "The model implementation is available"
+ - label: "The model weights are available (Only relevant if addition is not a scheduler)."
+
+ - type: textarea
+ id: additional-info
+ attributes:
+ label: Provide useful links for the implementation
+ description: |
+ Please provide information regarding the implementation, the weights, and the authors.
+ Please mention the authors by @gh-username if you're aware of their usernames.
diff --git a/diffusers/diffusers/.github/PULL_REQUEST_TEMPLATE.md b/diffusers/diffusers/.github/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 0000000000000000000000000000000000000000..05c2116453309cbda56cc82276cd8705f95bf4bc
--- /dev/null
+++ b/diffusers/diffusers/.github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,60 @@
+# What does this PR do?
+
+
+
+
+
+Fixes # (issue)
+
+
+## Before submitting
+- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
+- [ ] Did you read the [contributor guideline](https://github.com/huggingface/diffusers/blob/main/CONTRIBUTING.md)?
+- [ ] Did you read our [philosophy doc](https://github.com/huggingface/diffusers/blob/main/PHILOSOPHY.md) (important for complex PRs)?
+- [ ] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link to it if that's the case.
+- [ ] Did you make sure to update the documentation with your changes? Here are the
+ [documentation guidelines](https://github.com/huggingface/diffusers/tree/main/docs), and
+ [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
+- [ ] Did you write any new necessary tests?
+
+
+## Who can review?
+
+Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
+members/contributors who may be interested in your PR.
+
+
diff --git a/diffusers/diffusers/.github/actions/setup-miniconda/action.yml b/diffusers/diffusers/.github/actions/setup-miniconda/action.yml
new file mode 100644
index 0000000000000000000000000000000000000000..cc755d3aad792ab82d85a33daed26dbe33e99267
--- /dev/null
+++ b/diffusers/diffusers/.github/actions/setup-miniconda/action.yml
@@ -0,0 +1,146 @@
+name: Set up conda environment for testing
+
+description: Sets up miniconda in your ${RUNNER_TEMP} environment and gives you the ${CONDA_RUN} environment variable so you don't have to worry about polluting non-empeheral runners anymore
+
+inputs:
+ python-version:
+ description: If set to any value, dont use sudo to clean the workspace
+ required: false
+ type: string
+ default: "3.9"
+ miniconda-version:
+ description: Miniconda version to install
+ required: false
+ type: string
+ default: "4.12.0"
+ environment-file:
+ description: Environment file to install dependencies from
+ required: false
+ type: string
+ default: ""
+
+runs:
+ using: composite
+ steps:
+ # Use the same trick from https://github.com/marketplace/actions/setup-miniconda
+ # to refresh the cache daily. This is kind of optional though
+ - name: Get date
+ id: get-date
+ shell: bash
+ run: echo "today=$(/bin/date -u '+%Y%m%d')d" >> $GITHUB_OUTPUT
+ - name: Setup miniconda cache
+ id: miniconda-cache
+ uses: actions/cache@v2
+ with:
+ path: ${{ runner.temp }}/miniconda
+ key: miniconda-${{ runner.os }}-${{ runner.arch }}-${{ inputs.python-version }}-${{ steps.get-date.outputs.today }}
+ - name: Install miniconda (${{ inputs.miniconda-version }})
+ if: steps.miniconda-cache.outputs.cache-hit != 'true'
+ env:
+ MINICONDA_VERSION: ${{ inputs.miniconda-version }}
+ shell: bash -l {0}
+ run: |
+ MINICONDA_INSTALL_PATH="${RUNNER_TEMP}/miniconda"
+ mkdir -p "${MINICONDA_INSTALL_PATH}"
+ case ${RUNNER_OS}-${RUNNER_ARCH} in
+ Linux-X64)
+ MINICONDA_ARCH="Linux-x86_64"
+ ;;
+ macOS-ARM64)
+ MINICONDA_ARCH="MacOSX-arm64"
+ ;;
+ macOS-X64)
+ MINICONDA_ARCH="MacOSX-x86_64"
+ ;;
+ *)
+ echo "::error::Platform ${RUNNER_OS}-${RUNNER_ARCH} currently unsupported using this action"
+ exit 1
+ ;;
+ esac
+ MINICONDA_URL="https://repo.anaconda.com/miniconda/Miniconda3-py39_${MINICONDA_VERSION}-${MINICONDA_ARCH}.sh"
+ curl -fsSL "${MINICONDA_URL}" -o "${MINICONDA_INSTALL_PATH}/miniconda.sh"
+ bash "${MINICONDA_INSTALL_PATH}/miniconda.sh" -b -u -p "${MINICONDA_INSTALL_PATH}"
+ rm -rf "${MINICONDA_INSTALL_PATH}/miniconda.sh"
+ - name: Update GitHub path to include miniconda install
+ shell: bash
+ run: |
+ MINICONDA_INSTALL_PATH="${RUNNER_TEMP}/miniconda"
+ echo "${MINICONDA_INSTALL_PATH}/bin" >> $GITHUB_PATH
+ - name: Setup miniconda env cache (with env file)
+ id: miniconda-env-cache-env-file
+ if: ${{ runner.os }} == 'macOS' && ${{ inputs.environment-file }} != ''
+ uses: actions/cache@v2
+ with:
+ path: ${{ runner.temp }}/conda-python-${{ inputs.python-version }}
+ key: miniconda-env-${{ runner.os }}-${{ runner.arch }}-${{ inputs.python-version }}-${{ steps.get-date.outputs.today }}-${{ hashFiles(inputs.environment-file) }}
+ - name: Setup miniconda env cache (without env file)
+ id: miniconda-env-cache
+ if: ${{ runner.os }} == 'macOS' && ${{ inputs.environment-file }} == ''
+ uses: actions/cache@v2
+ with:
+ path: ${{ runner.temp }}/conda-python-${{ inputs.python-version }}
+ key: miniconda-env-${{ runner.os }}-${{ runner.arch }}-${{ inputs.python-version }}-${{ steps.get-date.outputs.today }}
+ - name: Setup conda environment with python (v${{ inputs.python-version }})
+ if: steps.miniconda-env-cache-env-file.outputs.cache-hit != 'true' && steps.miniconda-env-cache.outputs.cache-hit != 'true'
+ shell: bash
+ env:
+ PYTHON_VERSION: ${{ inputs.python-version }}
+ ENV_FILE: ${{ inputs.environment-file }}
+ run: |
+ CONDA_BASE_ENV="${RUNNER_TEMP}/conda-python-${PYTHON_VERSION}"
+ ENV_FILE_FLAG=""
+ if [[ -f "${ENV_FILE}" ]]; then
+ ENV_FILE_FLAG="--file ${ENV_FILE}"
+ elif [[ -n "${ENV_FILE}" ]]; then
+ echo "::warning::Specified env file (${ENV_FILE}) not found, not going to include it"
+ fi
+ conda create \
+ --yes \
+ --prefix "${CONDA_BASE_ENV}" \
+ "python=${PYTHON_VERSION}" \
+ ${ENV_FILE_FLAG} \
+ cmake=3.22 \
+ conda-build=3.21 \
+ ninja=1.10 \
+ pkg-config=0.29 \
+ wheel=0.37
+ - name: Clone the base conda environment and update GitHub env
+ shell: bash
+ env:
+ PYTHON_VERSION: ${{ inputs.python-version }}
+ CONDA_BASE_ENV: ${{ runner.temp }}/conda-python-${{ inputs.python-version }}
+ run: |
+ CONDA_ENV="${RUNNER_TEMP}/conda_environment_${GITHUB_RUN_ID}"
+ conda create \
+ --yes \
+ --prefix "${CONDA_ENV}" \
+ --clone "${CONDA_BASE_ENV}"
+ # TODO: conda-build could not be cloned because it hardcodes the path, so it
+ # could not be cached
+ conda install --yes -p ${CONDA_ENV} conda-build=3.21
+ echo "CONDA_ENV=${CONDA_ENV}" >> "${GITHUB_ENV}"
+ echo "CONDA_RUN=conda run -p ${CONDA_ENV} --no-capture-output" >> "${GITHUB_ENV}"
+ echo "CONDA_BUILD=conda run -p ${CONDA_ENV} conda-build" >> "${GITHUB_ENV}"
+ echo "CONDA_INSTALL=conda install -p ${CONDA_ENV}" >> "${GITHUB_ENV}"
+ - name: Get disk space usage and throw an error for low disk space
+ shell: bash
+ run: |
+ echo "Print the available disk space for manual inspection"
+ df -h
+ # Set the minimum requirement space to 4GB
+ MINIMUM_AVAILABLE_SPACE_IN_GB=4
+ MINIMUM_AVAILABLE_SPACE_IN_KB=$(($MINIMUM_AVAILABLE_SPACE_IN_GB * 1024 * 1024))
+ # Use KB to avoid floating point warning like 3.1GB
+ df -k | tr -s ' ' | cut -d' ' -f 4,9 | while read -r LINE;
+ do
+ AVAIL=$(echo $LINE | cut -f1 -d' ')
+ MOUNT=$(echo $LINE | cut -f2 -d' ')
+ if [ "$MOUNT" = "/" ]; then
+ if [ "$AVAIL" -lt "$MINIMUM_AVAILABLE_SPACE_IN_KB" ]; then
+ echo "There is only ${AVAIL}KB free space left in $MOUNT, which is less than the minimum requirement of ${MINIMUM_AVAILABLE_SPACE_IN_KB}KB. Please help create an issue to PyTorch Release Engineering via https://github.com/pytorch/test-infra/issues and provide the link to the workflow run."
+ exit 1;
+ else
+ echo "There is ${AVAIL}KB free space left in $MOUNT, continue"
+ fi
+ fi
+ done
diff --git a/diffusers/diffusers/.github/workflows/build_docker_images.yml b/diffusers/diffusers/.github/workflows/build_docker_images.yml
new file mode 100644
index 0000000000000000000000000000000000000000..ff4bd66fdde5570958c282398b8148bc2d335112
--- /dev/null
+++ b/diffusers/diffusers/.github/workflows/build_docker_images.yml
@@ -0,0 +1,50 @@
+name: Build Docker images (nightly)
+
+on:
+ workflow_dispatch:
+ schedule:
+ - cron: "0 0 * * *" # every day at midnight
+
+concurrency:
+ group: docker-image-builds
+ cancel-in-progress: false
+
+env:
+ REGISTRY: diffusers
+
+jobs:
+ build-docker-images:
+ runs-on: ubuntu-latest
+
+ permissions:
+ contents: read
+ packages: write
+
+ strategy:
+ fail-fast: false
+ matrix:
+ image-name:
+ - diffusers-pytorch-cpu
+ - diffusers-pytorch-cuda
+ - diffusers-flax-cpu
+ - diffusers-flax-tpu
+ - diffusers-onnxruntime-cpu
+ - diffusers-onnxruntime-cuda
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v3
+
+ - name: Login to Docker Hub
+ uses: docker/login-action@v2
+ with:
+ username: ${{ env.REGISTRY }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+ - name: Build and push
+ uses: docker/build-push-action@v3
+ with:
+ no-cache: true
+ context: ./docker/${{ matrix.image-name }}
+ push: true
+ tags: ${{ env.REGISTRY }}/${{ matrix.image-name }}:latest
diff --git a/diffusers/diffusers/.github/workflows/build_documentation.yml b/diffusers/diffusers/.github/workflows/build_documentation.yml
new file mode 100644
index 0000000000000000000000000000000000000000..bd45b08d24f730bbeff86a7335020a76158eb144
--- /dev/null
+++ b/diffusers/diffusers/.github/workflows/build_documentation.yml
@@ -0,0 +1,23 @@
+name: Build documentation
+
+on:
+ push:
+ branches:
+ - main
+ - doc-builder*
+ - v*-release
+ - v*-patch
+
+jobs:
+ build:
+ uses: huggingface/doc-builder/.github/workflows/build_main_documentation.yml@main
+ with:
+ commit_sha: ${{ github.sha }}
+ install_libgl1: true
+ package: diffusers
+ notebook_folder: diffusers_doc
+ languages: en ko zh
+
+ secrets:
+ token: ${{ secrets.HUGGINGFACE_PUSH }}
+ hf_token: ${{ secrets.HF_DOC_BUILD_PUSH }}
diff --git a/diffusers/diffusers/.github/workflows/build_pr_documentation.yml b/diffusers/diffusers/.github/workflows/build_pr_documentation.yml
new file mode 100644
index 0000000000000000000000000000000000000000..18b606ca754cb59e72949cdcd8e495eaeec1f940
--- /dev/null
+++ b/diffusers/diffusers/.github/workflows/build_pr_documentation.yml
@@ -0,0 +1,18 @@
+name: Build PR Documentation
+
+on:
+ pull_request:
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
+ cancel-in-progress: true
+
+jobs:
+ build:
+ uses: huggingface/doc-builder/.github/workflows/build_pr_documentation.yml@main
+ with:
+ commit_sha: ${{ github.event.pull_request.head.sha }}
+ pr_number: ${{ github.event.number }}
+ install_libgl1: true
+ package: diffusers
+ languages: en ko zh
diff --git a/diffusers/diffusers/.github/workflows/delete_doc_comment.yml b/diffusers/diffusers/.github/workflows/delete_doc_comment.yml
new file mode 100644
index 0000000000000000000000000000000000000000..8604019d76eb507fb41c6446ab8875452337e40a
--- /dev/null
+++ b/diffusers/diffusers/.github/workflows/delete_doc_comment.yml
@@ -0,0 +1,14 @@
+name: Delete doc comment
+
+on:
+ workflow_run:
+ workflows: ["Delete doc comment trigger"]
+ types:
+ - completed
+
+
+jobs:
+ delete:
+ uses: huggingface/doc-builder/.github/workflows/delete_doc_comment.yml@main
+ secrets:
+ comment_bot_token: ${{ secrets.COMMENT_BOT_TOKEN }}
\ No newline at end of file
diff --git a/diffusers/diffusers/.github/workflows/delete_doc_comment_trigger.yml b/diffusers/diffusers/.github/workflows/delete_doc_comment_trigger.yml
new file mode 100644
index 0000000000000000000000000000000000000000..f87d9bd4dca7051cce469c5c4c06d007cd505905
--- /dev/null
+++ b/diffusers/diffusers/.github/workflows/delete_doc_comment_trigger.yml
@@ -0,0 +1,12 @@
+name: Delete doc comment trigger
+
+on:
+ pull_request:
+ types: [ closed ]
+
+
+jobs:
+ delete:
+ uses: huggingface/doc-builder/.github/workflows/delete_doc_comment_trigger.yml@main
+ with:
+ pr_number: ${{ github.event.number }}
diff --git a/diffusers/diffusers/.github/workflows/nightly_tests.yml b/diffusers/diffusers/.github/workflows/nightly_tests.yml
new file mode 100644
index 0000000000000000000000000000000000000000..fb0ce92cb61c1f9e38e56b23b2812d9c92dd92b1
--- /dev/null
+++ b/diffusers/diffusers/.github/workflows/nightly_tests.yml
@@ -0,0 +1,162 @@
+name: Nightly tests on main
+
+on:
+ schedule:
+ - cron: "0 0 * * *" # every day at midnight
+
+env:
+ DIFFUSERS_IS_CI: yes
+ HF_HOME: /mnt/cache
+ OMP_NUM_THREADS: 8
+ MKL_NUM_THREADS: 8
+ PYTEST_TIMEOUT: 600
+ RUN_SLOW: yes
+ RUN_NIGHTLY: yes
+
+jobs:
+ run_nightly_tests:
+ strategy:
+ fail-fast: false
+ matrix:
+ config:
+ - name: Nightly PyTorch CUDA tests on Ubuntu
+ framework: pytorch
+ runner: docker-gpu
+ image: diffusers/diffusers-pytorch-cuda
+ report: torch_cuda
+ - name: Nightly Flax TPU tests on Ubuntu
+ framework: flax
+ runner: docker-tpu
+ image: diffusers/diffusers-flax-tpu
+ report: flax_tpu
+ - name: Nightly ONNXRuntime CUDA tests on Ubuntu
+ framework: onnxruntime
+ runner: docker-gpu
+ image: diffusers/diffusers-onnxruntime-cuda
+ report: onnx_cuda
+
+ name: ${{ matrix.config.name }}
+
+ runs-on: ${{ matrix.config.runner }}
+
+ container:
+ image: ${{ matrix.config.image }}
+ options: --shm-size "16gb" --ipc host -v /mnt/hf_cache:/mnt/cache/ ${{ matrix.config.runner == 'docker-tpu' && '--privileged' || '--gpus 0'}}
+
+ defaults:
+ run:
+ shell: bash
+
+ steps:
+ - name: Checkout diffusers
+ uses: actions/checkout@v3
+ with:
+ fetch-depth: 2
+
+ - name: NVIDIA-SMI
+ if: ${{ matrix.config.runner == 'docker-gpu' }}
+ run: |
+ nvidia-smi
+
+ - name: Install dependencies
+ run: |
+ python -m pip install -e .[quality,test]
+ python -m pip install -U git+https://github.com/huggingface/transformers
+ python -m pip install git+https://github.com/huggingface/accelerate
+
+ - name: Environment
+ run: |
+ python utils/print_env.py
+
+ - name: Run nightly PyTorch CUDA tests
+ if: ${{ matrix.config.framework == 'pytorch' }}
+ env:
+ HUGGING_FACE_HUB_TOKEN: ${{ secrets.HUGGING_FACE_HUB_TOKEN }}
+ run: |
+ python -m pytest -n 1 --max-worker-restart=0 --dist=loadfile \
+ -s -v -k "not Flax and not Onnx" \
+ --make-reports=tests_${{ matrix.config.report }} \
+ tests/
+
+ - name: Run nightly Flax TPU tests
+ if: ${{ matrix.config.framework == 'flax' }}
+ env:
+ HUGGING_FACE_HUB_TOKEN: ${{ secrets.HUGGING_FACE_HUB_TOKEN }}
+ run: |
+ python -m pytest -n 0 \
+ -s -v -k "Flax" \
+ --make-reports=tests_${{ matrix.config.report }} \
+ tests/
+
+ - name: Run nightly ONNXRuntime CUDA tests
+ if: ${{ matrix.config.framework == 'onnxruntime' }}
+ env:
+ HUGGING_FACE_HUB_TOKEN: ${{ secrets.HUGGING_FACE_HUB_TOKEN }}
+ run: |
+ python -m pytest -n 1 --max-worker-restart=0 --dist=loadfile \
+ -s -v -k "Onnx" \
+ --make-reports=tests_${{ matrix.config.report }} \
+ tests/
+
+ - name: Failure short reports
+ if: ${{ failure() }}
+ run: cat reports/tests_${{ matrix.config.report }}_failures_short.txt
+
+ - name: Test suite reports artifacts
+ if: ${{ always() }}
+ uses: actions/upload-artifact@v2
+ with:
+ name: ${{ matrix.config.report }}_test_reports
+ path: reports
+
+ run_nightly_tests_apple_m1:
+ name: Nightly PyTorch MPS tests on MacOS
+ runs-on: [ self-hosted, apple-m1 ]
+
+ steps:
+ - name: Checkout diffusers
+ uses: actions/checkout@v3
+ with:
+ fetch-depth: 2
+
+ - name: Clean checkout
+ shell: arch -arch arm64 bash {0}
+ run: |
+ git clean -fxd
+
+ - name: Setup miniconda
+ uses: ./.github/actions/setup-miniconda
+ with:
+ python-version: 3.9
+
+ - name: Install dependencies
+ shell: arch -arch arm64 bash {0}
+ run: |
+ ${CONDA_RUN} python -m pip install --upgrade pip
+ ${CONDA_RUN} python -m pip install -e .[quality,test]
+ ${CONDA_RUN} python -m pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cpu
+ ${CONDA_RUN} python -m pip install git+https://github.com/huggingface/accelerate
+
+ - name: Environment
+ shell: arch -arch arm64 bash {0}
+ run: |
+ ${CONDA_RUN} python utils/print_env.py
+
+ - name: Run nightly PyTorch tests on M1 (MPS)
+ shell: arch -arch arm64 bash {0}
+ env:
+ HF_HOME: /System/Volumes/Data/mnt/cache
+ HUGGING_FACE_HUB_TOKEN: ${{ secrets.HUGGING_FACE_HUB_TOKEN }}
+ run: |
+ ${CONDA_RUN} python -m pytest -n 1 -s -v --make-reports=tests_torch_mps tests/
+
+ - name: Failure short reports
+ if: ${{ failure() }}
+ run: cat reports/tests_torch_mps_failures_short.txt
+
+ - name: Test suite reports artifacts
+ if: ${{ always() }}
+ uses: actions/upload-artifact@v2
+ with:
+ name: torch_mps_test_reports
+ path: reports
diff --git a/diffusers/diffusers/.github/workflows/pr_dependency_test.yml b/diffusers/diffusers/.github/workflows/pr_dependency_test.yml
new file mode 100644
index 0000000000000000000000000000000000000000..baa83e20bf304f371143ddfb1ef2a4f5e401631a
--- /dev/null
+++ b/diffusers/diffusers/.github/workflows/pr_dependency_test.yml
@@ -0,0 +1,32 @@
+name: Run dependency tests
+
+on:
+ pull_request:
+ branches:
+ - main
+ push:
+ branches:
+ - main
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
+ cancel-in-progress: true
+
+jobs:
+ check_dependencies:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - name: Set up Python
+ uses: actions/setup-python@v4
+ with:
+ python-version: "3.7"
+ - name: Install dependencies
+ run: |
+ python -m pip install --upgrade pip
+ pip install -e .
+ pip install pytest
+ - name: Check for soft dependencies
+ run: |
+ pytest tests/others/test_dependencies.py
+
\ No newline at end of file
diff --git a/diffusers/diffusers/.github/workflows/pr_quality.yml b/diffusers/diffusers/.github/workflows/pr_quality.yml
new file mode 100644
index 0000000000000000000000000000000000000000..945c7bcc0b7430d36cd42f8ec3d32eb6121a99d5
--- /dev/null
+++ b/diffusers/diffusers/.github/workflows/pr_quality.yml
@@ -0,0 +1,50 @@
+name: Run code quality checks
+
+on:
+ pull_request:
+ branches:
+ - main
+ push:
+ branches:
+ - main
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
+ cancel-in-progress: true
+
+jobs:
+ check_code_quality:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - name: Set up Python
+ uses: actions/setup-python@v4
+ with:
+ python-version: "3.7"
+ - name: Install dependencies
+ run: |
+ python -m pip install --upgrade pip
+ pip install .[quality]
+ - name: Check quality
+ run: |
+ black --check examples tests src utils scripts
+ ruff examples tests src utils scripts
+ doc-builder style src/diffusers docs/source --max_len 119 --check_only --path_to_docs docs/source
+
+ check_repository_consistency:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - name: Set up Python
+ uses: actions/setup-python@v4
+ with:
+ python-version: "3.7"
+ - name: Install dependencies
+ run: |
+ python -m pip install --upgrade pip
+ pip install .[quality]
+ - name: Check quality
+ run: |
+ python utils/check_copies.py
+ python utils/check_dummies.py
+ make deps_table_check_updated
diff --git a/diffusers/diffusers/.github/workflows/pr_tests.yml b/diffusers/diffusers/.github/workflows/pr_tests.yml
new file mode 100644
index 0000000000000000000000000000000000000000..1c52428310adf9d4e31a0cd4355dae269552800e
--- /dev/null
+++ b/diffusers/diffusers/.github/workflows/pr_tests.yml
@@ -0,0 +1,115 @@
+name: Fast tests for PRs
+
+on:
+ pull_request:
+ branches:
+ - main
+ push:
+ branches:
+ - ci-*
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
+ cancel-in-progress: true
+
+env:
+ DIFFUSERS_IS_CI: yes
+ OMP_NUM_THREADS: 4
+ MKL_NUM_THREADS: 4
+ PYTEST_TIMEOUT: 60
+
+jobs:
+ run_fast_tests:
+ strategy:
+ fail-fast: false
+ matrix:
+ config:
+ - name: Fast PyTorch Pipeline CPU tests
+ framework: pytorch_pipelines
+ runner: docker-cpu
+ image: diffusers/diffusers-pytorch-cpu
+ report: torch_cpu_pipelines
+ - name: Fast PyTorch Models & Schedulers CPU tests
+ framework: pytorch_models
+ runner: docker-cpu
+ image: diffusers/diffusers-pytorch-cpu
+ report: torch_cpu_models_schedulers
+ - name: Fast Flax CPU tests
+ framework: flax
+ runner: docker-cpu
+ image: diffusers/diffusers-flax-cpu
+ report: flax_cpu
+ - name: PyTorch Example CPU tests
+ framework: pytorch_examples
+ runner: docker-cpu
+ image: diffusers/diffusers-pytorch-cpu
+ report: torch_example_cpu
+
+ name: ${{ matrix.config.name }}
+
+ runs-on: ${{ matrix.config.runner }}
+
+ container:
+ image: ${{ matrix.config.image }}
+ options: --shm-size "16gb" --ipc host -v /mnt/hf_cache:/mnt/cache/
+
+ defaults:
+ run:
+ shell: bash
+
+ steps:
+ - name: Checkout diffusers
+ uses: actions/checkout@v3
+ with:
+ fetch-depth: 2
+
+ - name: Install dependencies
+ run: |
+ apt-get update && apt-get install libsndfile1-dev libgl1 -y
+ python -m pip install -e .[quality,test]
+
+ - name: Environment
+ run: |
+ python utils/print_env.py
+
+ - name: Run fast PyTorch Pipeline CPU tests
+ if: ${{ matrix.config.framework == 'pytorch_pipelines' }}
+ run: |
+ python -m pytest -n 2 --max-worker-restart=0 --dist=loadfile \
+ -s -v -k "not Flax and not Onnx" \
+ --make-reports=tests_${{ matrix.config.report }} \
+ tests/pipelines
+
+ - name: Run fast PyTorch Model Scheduler CPU tests
+ if: ${{ matrix.config.framework == 'pytorch_models' }}
+ run: |
+ python -m pytest -n 2 --max-worker-restart=0 --dist=loadfile \
+ -s -v -k "not Flax and not Onnx and not Dependency" \
+ --make-reports=tests_${{ matrix.config.report }} \
+ tests/models tests/schedulers tests/others
+
+ - name: Run fast Flax TPU tests
+ if: ${{ matrix.config.framework == 'flax' }}
+ run: |
+ python -m pytest -n 2 --max-worker-restart=0 --dist=loadfile \
+ -s -v -k "Flax" \
+ --make-reports=tests_${{ matrix.config.report }} \
+ tests
+
+ - name: Run example PyTorch CPU tests
+ if: ${{ matrix.config.framework == 'pytorch_examples' }}
+ run: |
+ python -m pytest -n 2 --max-worker-restart=0 --dist=loadfile \
+ --make-reports=tests_${{ matrix.config.report }} \
+ examples/test_examples.py
+
+ - name: Failure short reports
+ if: ${{ failure() }}
+ run: cat reports/tests_${{ matrix.config.report }}_failures_short.txt
+
+ - name: Test suite reports artifacts
+ if: ${{ always() }}
+ uses: actions/upload-artifact@v2
+ with:
+ name: pr_${{ matrix.config.report }}_test_reports
+ path: reports
diff --git a/diffusers/diffusers/.github/workflows/push_tests.yml b/diffusers/diffusers/.github/workflows/push_tests.yml
new file mode 100644
index 0000000000000000000000000000000000000000..5ec8dbdc4026b2ce09eda62dd46611dfba068d9f
--- /dev/null
+++ b/diffusers/diffusers/.github/workflows/push_tests.yml
@@ -0,0 +1,157 @@
+name: Slow tests on main
+
+on:
+ push:
+ branches:
+ - main
+
+env:
+ DIFFUSERS_IS_CI: yes
+ HF_HOME: /mnt/cache
+ OMP_NUM_THREADS: 8
+ MKL_NUM_THREADS: 8
+ PYTEST_TIMEOUT: 600
+ RUN_SLOW: yes
+
+jobs:
+ run_slow_tests:
+ strategy:
+ fail-fast: false
+ max-parallel: 1
+ matrix:
+ config:
+ - name: Slow PyTorch CUDA tests on Ubuntu
+ framework: pytorch
+ runner: docker-gpu
+ image: diffusers/diffusers-pytorch-cuda
+ report: torch_cuda
+ - name: Slow Flax TPU tests on Ubuntu
+ framework: flax
+ runner: docker-tpu
+ image: diffusers/diffusers-flax-tpu
+ report: flax_tpu
+ - name: Slow ONNXRuntime CUDA tests on Ubuntu
+ framework: onnxruntime
+ runner: docker-gpu
+ image: diffusers/diffusers-onnxruntime-cuda
+ report: onnx_cuda
+
+ name: ${{ matrix.config.name }}
+
+ runs-on: ${{ matrix.config.runner }}
+
+ container:
+ image: ${{ matrix.config.image }}
+ options: --shm-size "16gb" --ipc host -v /mnt/hf_cache:/mnt/cache/ ${{ matrix.config.runner == 'docker-tpu' && '--privileged' || '--gpus 0'}}
+
+ defaults:
+ run:
+ shell: bash
+
+ steps:
+ - name: Checkout diffusers
+ uses: actions/checkout@v3
+ with:
+ fetch-depth: 2
+
+ - name: NVIDIA-SMI
+ if : ${{ matrix.config.runner == 'docker-gpu' }}
+ run: |
+ nvidia-smi
+
+ - name: Install dependencies
+ run: |
+ apt-get update && apt-get install libsndfile1-dev libgl1 -y
+ python -m pip install -e .[quality,test]
+
+ - name: Environment
+ run: |
+ python utils/print_env.py
+
+ - name: Run slow PyTorch CUDA tests
+ if: ${{ matrix.config.framework == 'pytorch' }}
+ env:
+ HUGGING_FACE_HUB_TOKEN: ${{ secrets.HUGGING_FACE_HUB_TOKEN }}
+ # https://pytorch.org/docs/stable/notes/randomness.html#avoiding-nondeterministic-algorithms
+ CUBLAS_WORKSPACE_CONFIG: :16:8
+
+ run: |
+ python -m pytest -n 1 --max-worker-restart=0 --dist=loadfile \
+ -s -v -k "not Flax and not Onnx" \
+ --make-reports=tests_${{ matrix.config.report }} \
+ tests/
+
+ - name: Run slow Flax TPU tests
+ if: ${{ matrix.config.framework == 'flax' }}
+ env:
+ HUGGING_FACE_HUB_TOKEN: ${{ secrets.HUGGING_FACE_HUB_TOKEN }}
+ run: |
+ python -m pytest -n 0 \
+ -s -v -k "Flax" \
+ --make-reports=tests_${{ matrix.config.report }} \
+ tests/
+
+ - name: Run slow ONNXRuntime CUDA tests
+ if: ${{ matrix.config.framework == 'onnxruntime' }}
+ env:
+ HUGGING_FACE_HUB_TOKEN: ${{ secrets.HUGGING_FACE_HUB_TOKEN }}
+ run: |
+ python -m pytest -n 1 --max-worker-restart=0 --dist=loadfile \
+ -s -v -k "Onnx" \
+ --make-reports=tests_${{ matrix.config.report }} \
+ tests/
+
+ - name: Failure short reports
+ if: ${{ failure() }}
+ run: cat reports/tests_${{ matrix.config.report }}_failures_short.txt
+
+ - name: Test suite reports artifacts
+ if: ${{ always() }}
+ uses: actions/upload-artifact@v2
+ with:
+ name: ${{ matrix.config.report }}_test_reports
+ path: reports
+
+ run_examples_tests:
+ name: Examples PyTorch CUDA tests on Ubuntu
+
+ runs-on: docker-gpu
+
+ container:
+ image: diffusers/diffusers-pytorch-cuda
+ options: --gpus 0 --shm-size "16gb" --ipc host -v /mnt/hf_cache:/mnt/cache/
+
+ steps:
+ - name: Checkout diffusers
+ uses: actions/checkout@v3
+ with:
+ fetch-depth: 2
+
+ - name: NVIDIA-SMI
+ run: |
+ nvidia-smi
+
+ - name: Install dependencies
+ run: |
+ python -m pip install -e .[quality,test,training]
+
+ - name: Environment
+ run: |
+ python utils/print_env.py
+
+ - name: Run example tests on GPU
+ env:
+ HUGGING_FACE_HUB_TOKEN: ${{ secrets.HUGGING_FACE_HUB_TOKEN }}
+ run: |
+ python -m pytest -n 1 --max-worker-restart=0 --dist=loadfile -s -v --make-reports=examples_torch_cuda examples/
+
+ - name: Failure short reports
+ if: ${{ failure() }}
+ run: cat reports/examples_torch_cuda_failures_short.txt
+
+ - name: Test suite reports artifacts
+ if: ${{ always() }}
+ uses: actions/upload-artifact@v2
+ with:
+ name: examples_test_reports
+ path: reports
diff --git a/diffusers/diffusers/.github/workflows/push_tests_fast.yml b/diffusers/diffusers/.github/workflows/push_tests_fast.yml
new file mode 100644
index 0000000000000000000000000000000000000000..acd59ef80dc751827aa8a4a80f3b221f36579be1
--- /dev/null
+++ b/diffusers/diffusers/.github/workflows/push_tests_fast.yml
@@ -0,0 +1,110 @@
+name: Fast tests on main
+
+on:
+ push:
+ branches:
+ - main
+
+env:
+ DIFFUSERS_IS_CI: yes
+ HF_HOME: /mnt/cache
+ OMP_NUM_THREADS: 8
+ MKL_NUM_THREADS: 8
+ PYTEST_TIMEOUT: 600
+ RUN_SLOW: no
+
+jobs:
+ run_fast_tests:
+ strategy:
+ fail-fast: false
+ matrix:
+ config:
+ - name: Fast PyTorch CPU tests on Ubuntu
+ framework: pytorch
+ runner: docker-cpu
+ image: diffusers/diffusers-pytorch-cpu
+ report: torch_cpu
+ - name: Fast Flax CPU tests on Ubuntu
+ framework: flax
+ runner: docker-cpu
+ image: diffusers/diffusers-flax-cpu
+ report: flax_cpu
+ - name: Fast ONNXRuntime CPU tests on Ubuntu
+ framework: onnxruntime
+ runner: docker-cpu
+ image: diffusers/diffusers-onnxruntime-cpu
+ report: onnx_cpu
+ - name: PyTorch Example CPU tests on Ubuntu
+ framework: pytorch_examples
+ runner: docker-cpu
+ image: diffusers/diffusers-pytorch-cpu
+ report: torch_example_cpu
+
+ name: ${{ matrix.config.name }}
+
+ runs-on: ${{ matrix.config.runner }}
+
+ container:
+ image: ${{ matrix.config.image }}
+ options: --shm-size "16gb" --ipc host -v /mnt/hf_cache:/mnt/cache/
+
+ defaults:
+ run:
+ shell: bash
+
+ steps:
+ - name: Checkout diffusers
+ uses: actions/checkout@v3
+ with:
+ fetch-depth: 2
+
+ - name: Install dependencies
+ run: |
+ apt-get update && apt-get install libsndfile1-dev libgl1 -y
+ python -m pip install -e .[quality,test]
+
+ - name: Environment
+ run: |
+ python utils/print_env.py
+
+ - name: Run fast PyTorch CPU tests
+ if: ${{ matrix.config.framework == 'pytorch' }}
+ run: |
+ python -m pytest -n 2 --max-worker-restart=0 --dist=loadfile \
+ -s -v -k "not Flax and not Onnx" \
+ --make-reports=tests_${{ matrix.config.report }} \
+ tests/
+
+ - name: Run fast Flax TPU tests
+ if: ${{ matrix.config.framework == 'flax' }}
+ run: |
+ python -m pytest -n 2 --max-worker-restart=0 --dist=loadfile \
+ -s -v -k "Flax" \
+ --make-reports=tests_${{ matrix.config.report }} \
+ tests/
+
+ - name: Run fast ONNXRuntime CPU tests
+ if: ${{ matrix.config.framework == 'onnxruntime' }}
+ run: |
+ python -m pytest -n 2 --max-worker-restart=0 --dist=loadfile \
+ -s -v -k "Onnx" \
+ --make-reports=tests_${{ matrix.config.report }} \
+ tests/
+
+ - name: Run example PyTorch CPU tests
+ if: ${{ matrix.config.framework == 'pytorch_examples' }}
+ run: |
+ python -m pytest -n 2 --max-worker-restart=0 --dist=loadfile \
+ --make-reports=tests_${{ matrix.config.report }} \
+ examples/test_examples.py
+
+ - name: Failure short reports
+ if: ${{ failure() }}
+ run: cat reports/tests_${{ matrix.config.report }}_failures_short.txt
+
+ - name: Test suite reports artifacts
+ if: ${{ always() }}
+ uses: actions/upload-artifact@v2
+ with:
+ name: pr_${{ matrix.config.report }}_test_reports
+ path: reports
diff --git a/diffusers/diffusers/.github/workflows/push_tests_mps.yml b/diffusers/diffusers/.github/workflows/push_tests_mps.yml
new file mode 100644
index 0000000000000000000000000000000000000000..6b95815f1ea5328e0d1e15c520044a094e30ec33
--- /dev/null
+++ b/diffusers/diffusers/.github/workflows/push_tests_mps.yml
@@ -0,0 +1,68 @@
+name: Fast mps tests on main
+
+on:
+ push:
+ branches:
+ - main
+
+env:
+ DIFFUSERS_IS_CI: yes
+ HF_HOME: /mnt/cache
+ OMP_NUM_THREADS: 8
+ MKL_NUM_THREADS: 8
+ PYTEST_TIMEOUT: 600
+ RUN_SLOW: no
+
+jobs:
+ run_fast_tests_apple_m1:
+ name: Fast PyTorch MPS tests on MacOS
+ runs-on: [ self-hosted, apple-m1 ]
+
+ steps:
+ - name: Checkout diffusers
+ uses: actions/checkout@v3
+ with:
+ fetch-depth: 2
+
+ - name: Clean checkout
+ shell: arch -arch arm64 bash {0}
+ run: |
+ git clean -fxd
+
+ - name: Setup miniconda
+ uses: ./.github/actions/setup-miniconda
+ with:
+ python-version: 3.9
+
+ - name: Install dependencies
+ shell: arch -arch arm64 bash {0}
+ run: |
+ ${CONDA_RUN} python -m pip install --upgrade pip
+ ${CONDA_RUN} python -m pip install -e .[quality,test]
+ ${CONDA_RUN} python -m pip install torch torchvision torchaudio
+ ${CONDA_RUN} python -m pip install accelerate --upgrade
+ ${CONDA_RUN} python -m pip install transformers --upgrade
+
+ - name: Environment
+ shell: arch -arch arm64 bash {0}
+ run: |
+ ${CONDA_RUN} python utils/print_env.py
+
+ - name: Run fast PyTorch tests on M1 (MPS)
+ shell: arch -arch arm64 bash {0}
+ env:
+ HF_HOME: /System/Volumes/Data/mnt/cache
+ HUGGING_FACE_HUB_TOKEN: ${{ secrets.HUGGING_FACE_HUB_TOKEN }}
+ run: |
+ ${CONDA_RUN} python -m pytest -n 0 -s -v --make-reports=tests_torch_mps tests/
+
+ - name: Failure short reports
+ if: ${{ failure() }}
+ run: cat reports/tests_torch_mps_failures_short.txt
+
+ - name: Test suite reports artifacts
+ if: ${{ always() }}
+ uses: actions/upload-artifact@v2
+ with:
+ name: pr_torch_mps_test_reports
+ path: reports
diff --git a/diffusers/diffusers/.github/workflows/stale.yml b/diffusers/diffusers/.github/workflows/stale.yml
new file mode 100644
index 0000000000000000000000000000000000000000..eaca39797e1bad9b2bb851320fc0d1cb68940ba9
--- /dev/null
+++ b/diffusers/diffusers/.github/workflows/stale.yml
@@ -0,0 +1,27 @@
+name: Stale Bot
+
+on:
+ schedule:
+ - cron: "0 15 * * *"
+
+jobs:
+ close_stale_issues:
+ name: Close Stale Issues
+ if: github.repository == 'huggingface/diffusers'
+ runs-on: ubuntu-latest
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: Setup Python
+ uses: actions/setup-python@v1
+ with:
+ python-version: 3.7
+
+ - name: Install requirements
+ run: |
+ pip install PyGithub
+ - name: Close stale issues
+ run: |
+ python utils/stale.py
diff --git a/diffusers/diffusers/.github/workflows/typos.yml b/diffusers/diffusers/.github/workflows/typos.yml
new file mode 100644
index 0000000000000000000000000000000000000000..fbd051b4da0dc6c1ec9e15a3a7bad07b122d81cd
--- /dev/null
+++ b/diffusers/diffusers/.github/workflows/typos.yml
@@ -0,0 +1,14 @@
+name: Check typos
+
+on:
+ workflow_dispatch:
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v3
+
+ - name: typos-action
+ uses: crate-ci/typos@v1.12.4
diff --git a/diffusers/diffusers/.github/workflows/upload_pr_documentation.yml b/diffusers/diffusers/.github/workflows/upload_pr_documentation.yml
new file mode 100644
index 0000000000000000000000000000000000000000..fc102df8103e48fb139a8bd47be05fc257d992c5
--- /dev/null
+++ b/diffusers/diffusers/.github/workflows/upload_pr_documentation.yml
@@ -0,0 +1,16 @@
+name: Upload PR Documentation
+
+on:
+ workflow_run:
+ workflows: ["Build PR Documentation"]
+ types:
+ - completed
+
+jobs:
+ build:
+ uses: huggingface/doc-builder/.github/workflows/upload_pr_documentation.yml@main
+ with:
+ package_name: diffusers
+ secrets:
+ hf_token: ${{ secrets.HF_DOC_BUILD_PUSH }}
+ comment_bot_token: ${{ secrets.COMMENT_BOT_TOKEN }}
diff --git a/diffusers/diffusers/.gitignore b/diffusers/diffusers/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..45602a1f547e5d21d42a965df19415d8be8e2bae
--- /dev/null
+++ b/diffusers/diffusers/.gitignore
@@ -0,0 +1,176 @@
+# Initially taken from Github's Python gitignore file
+
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+*$py.class
+
+# C extensions
+*.so
+
+# tests and logs
+tests/fixtures/cached_*_text.txt
+logs/
+lightning_logs/
+lang_code_data/
+
+# Distribution / packaging
+.Python
+build/
+develop-eggs/
+dist/
+downloads/
+eggs/
+.eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+wheels/
+*.egg-info/
+.installed.cfg
+*.egg
+MANIFEST
+
+# PyInstaller
+# Usually these files are written by a python script from a template
+# before PyInstaller builds the exe, so as to inject date/other infos into it.
+*.manifest
+*.spec
+
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
+
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.nox/
+.coverage
+.coverage.*
+.cache
+nosetests.xml
+coverage.xml
+*.cover
+.hypothesis/
+.pytest_cache/
+
+# Translations
+*.mo
+*.pot
+
+# Django stuff:
+*.log
+local_settings.py
+db.sqlite3
+
+# Flask stuff:
+instance/
+.webassets-cache
+
+# Scrapy stuff:
+.scrapy
+
+# Sphinx documentation
+docs/_build/
+
+# PyBuilder
+target/
+
+# Jupyter Notebook
+.ipynb_checkpoints
+
+# IPython
+profile_default/
+ipython_config.py
+
+# pyenv
+.python-version
+
+# celery beat schedule file
+celerybeat-schedule
+
+# SageMath parsed files
+*.sage.py
+
+# Environments
+.env
+.venv
+env/
+venv/
+ENV/
+env.bak/
+venv.bak/
+
+# Spyder project settings
+.spyderproject
+.spyproject
+
+# Rope project settings
+.ropeproject
+
+# mkdocs documentation
+/site
+
+# mypy
+.mypy_cache/
+.dmypy.json
+dmypy.json
+
+# Pyre type checker
+.pyre/
+
+# vscode
+.vs
+.vscode
+
+# Pycharm
+.idea
+
+# TF code
+tensorflow_code
+
+# Models
+proc_data
+
+# examples
+runs
+/runs_old
+/wandb
+/examples/runs
+/examples/**/*.args
+/examples/rag/sweep
+
+# data
+/data
+serialization_dir
+
+# emacs
+*.*~
+debug.env
+
+# vim
+.*.swp
+
+#ctags
+tags
+
+# pre-commit
+.pre-commit*
+
+# .lock
+*.lock
+
+# DS_Store (MacOS)
+.DS_Store
+# RL pipelines may produce mp4 outputs
+*.mp4
+
+# dependencies
+/transformers
+
+# ruff
+.ruff_cache
+
+wandb
\ No newline at end of file
diff --git a/diffusers/diffusers/CITATION.cff b/diffusers/diffusers/CITATION.cff
new file mode 100644
index 0000000000000000000000000000000000000000..18c0151d10a2a4c86cbc0d35841dc328cb7298b3
--- /dev/null
+++ b/diffusers/diffusers/CITATION.cff
@@ -0,0 +1,40 @@
+cff-version: 1.2.0
+title: 'Diffusers: State-of-the-art diffusion models'
+message: >-
+ If you use this software, please cite it using the
+ metadata from this file.
+type: software
+authors:
+ - given-names: Patrick
+ family-names: von Platen
+ - given-names: Suraj
+ family-names: Patil
+ - given-names: Anton
+ family-names: Lozhkov
+ - given-names: Pedro
+ family-names: Cuenca
+ - given-names: Nathan
+ family-names: Lambert
+ - given-names: Kashif
+ family-names: Rasul
+ - given-names: Mishig
+ family-names: Davaadorj
+ - given-names: Thomas
+ family-names: Wolf
+repository-code: 'https://github.com/huggingface/diffusers'
+abstract: >-
+ 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.
+keywords:
+ - deep-learning
+ - pytorch
+ - image-generation
+ - diffusion
+ - text2image
+ - image2image
+ - score-based-generative-modeling
+ - stable-diffusion
+license: Apache-2.0
+version: 0.12.1
diff --git a/diffusers/diffusers/CODE_OF_CONDUCT.md b/diffusers/diffusers/CODE_OF_CONDUCT.md
new file mode 100644
index 0000000000000000000000000000000000000000..05954dfae2798fd0707c3c100ced94855a938eac
--- /dev/null
+++ b/diffusers/diffusers/CODE_OF_CONDUCT.md
@@ -0,0 +1,130 @@
+
+# Contributor Covenant Code of Conduct
+
+## Our Pledge
+
+We as members, contributors, and leaders pledge to make participation in our
+community a harassment-free experience for everyone, regardless of age, body
+size, visible or invisible disability, ethnicity, sex characteristics, gender
+identity and expression, level of experience, education, socio-economic status,
+nationality, personal appearance, race, religion, or sexual identity
+and orientation.
+
+We pledge to act and interact in ways that contribute to an open, welcoming,
+diverse, inclusive, and healthy community.
+
+## Our Standards
+
+Examples of behavior that contributes to a positive environment for our
+community include:
+
+* Demonstrating empathy and kindness toward other people
+* Being respectful of differing opinions, viewpoints, and experiences
+* Giving and gracefully accepting constructive feedback
+* Accepting responsibility and apologizing to those affected by our mistakes,
+ and learning from the experience
+* Focusing on what is best not just for us as individuals, but for the
+ overall diffusers community
+
+Examples of unacceptable behavior include:
+
+* The use of sexualized language or imagery, and sexual attention or
+ advances of any kind
+* Trolling, insulting or derogatory comments, and personal or political attacks
+* Public or private harassment
+* Publishing others' private information, such as a physical or email
+ address, without their explicit permission
+* Spamming issues or PRs with links to projects unrelated to this library
+* Other conduct which could reasonably be considered inappropriate in a
+ professional setting
+
+## Enforcement Responsibilities
+
+Community leaders are responsible for clarifying and enforcing our standards of
+acceptable behavior and will take appropriate and fair corrective action in
+response to any behavior that they deem inappropriate, threatening, offensive,
+or harmful.
+
+Community leaders have the right and responsibility to remove, edit, or reject
+comments, commits, code, wiki edits, issues, and other contributions that are
+not aligned to this Code of Conduct, and will communicate reasons for moderation
+decisions when appropriate.
+
+## Scope
+
+This Code of Conduct applies within all community spaces, and also applies when
+an individual is officially representing the community in public spaces.
+Examples of representing our community include using an official e-mail address,
+posting via an official social media account, or acting as an appointed
+representative at an online or offline event.
+
+## Enforcement
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be
+reported to the community leaders responsible for enforcement at
+feedback@huggingface.co.
+All complaints will be reviewed and investigated promptly and fairly.
+
+All community leaders are obligated to respect the privacy and security of the
+reporter of any incident.
+
+## Enforcement Guidelines
+
+Community leaders will follow these Community Impact Guidelines in determining
+the consequences for any action they deem in violation of this Code of Conduct:
+
+### 1. Correction
+
+**Community Impact**: Use of inappropriate language or other behavior deemed
+unprofessional or unwelcome in the community.
+
+**Consequence**: A private, written warning from community leaders, providing
+clarity around the nature of the violation and an explanation of why the
+behavior was inappropriate. A public apology may be requested.
+
+### 2. Warning
+
+**Community Impact**: A violation through a single incident or series
+of actions.
+
+**Consequence**: A warning with consequences for continued behavior. No
+interaction with the people involved, including unsolicited interaction with
+those enforcing the Code of Conduct, for a specified period of time. This
+includes avoiding interactions in community spaces as well as external channels
+like social media. Violating these terms may lead to a temporary or
+permanent ban.
+
+### 3. Temporary Ban
+
+**Community Impact**: A serious violation of community standards, including
+sustained inappropriate behavior.
+
+**Consequence**: A temporary ban from any sort of interaction or public
+communication with the community for a specified period of time. No public or
+private interaction with the people involved, including unsolicited interaction
+with those enforcing the Code of Conduct, is allowed during this period.
+Violating these terms may lead to a permanent ban.
+
+### 4. Permanent Ban
+
+**Community Impact**: Demonstrating a pattern of violation of community
+standards, including sustained inappropriate behavior, harassment of an
+individual, or aggression toward or disparagement of classes of individuals.
+
+**Consequence**: A permanent ban from any sort of public interaction within
+the community.
+
+## Attribution
+
+This Code of Conduct is adapted from the [Contributor Covenant][homepage],
+version 2.0, available at
+https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
+
+Community Impact Guidelines were inspired by [Mozilla's code of conduct
+enforcement ladder](https://github.com/mozilla/diversity).
+
+[homepage]: https://www.contributor-covenant.org
+
+For answers to common questions about this code of conduct, see the FAQ at
+https://www.contributor-covenant.org/faq. Translations are available at
+https://www.contributor-covenant.org/translations.
diff --git a/diffusers/diffusers/CONTRIBUTING.md b/diffusers/diffusers/CONTRIBUTING.md
new file mode 100644
index 0000000000000000000000000000000000000000..ae2be777aa37e956b5ff791523c20ba7b918799a
--- /dev/null
+++ b/diffusers/diffusers/CONTRIBUTING.md
@@ -0,0 +1,505 @@
+
+
+# How to contribute to Diffusers 🧨
+
+We ❤️ contributions from the open-source community! Everyone is welcome, and all types of participation –not just code– are valued and appreciated. Answering questions, helping others, reaching out, and improving the documentation are all immensely valuable to the community, so don't be afraid and get involved if you're up for it!
+
+Everyone is encouraged to start by saying 👋 in our public Discord channel. We discuss the latest trends in diffusion models, ask questions, show off personal projects, help each other with contributions, or just hang out ☕.