test-invoke-conda: use diffusers-format model

test-invoke-conda: put huggingface-token where the library can use it
This commit is contained in:
Kevin Turner 2022-11-13 15:36:51 -08:00
parent aca6d213d7
commit c5274e6e50

View File

@ -1,17 +1,16 @@
name: Test invoke.py name: Test invoke.py
on: on: [push, pull_request]
push:
branches:
- 'main'
- 'development'
- 'fix-gh-actions-fork'
pull_request:
branches:
- 'main'
- 'development'
jobs: jobs:
matrix: matrix:
# Run on:
# - pull requests
# - pushes to forks (will run in the forked project with that fork's secrets)
# - pushes to branches that are *not* pull requests
if: |
github.event_name == 'pull_request'
|| github.repository != 'invoke-ai/InvokeAI'
|| github.ref_protected
strategy: strategy:
matrix: matrix:
stable-diffusion-model: stable-diffusion-model:
@ -30,15 +29,19 @@ jobs:
- environment-yaml: environment-mac.yml - environment-yaml: environment-mac.yml
os: macos-12 os: macos-12
default-shell: bash -l {0} default-shell: bash -l {0}
- stable-diffusion-model: stable-diffusion-1.5 # - stable-diffusion-model: https://huggingface.co/CompVis/stable-diffusion-v-1-4-original/resolve/main/sd-v1-4.ckpt
stable-diffusion-model-url: https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.ckpt # stable-diffusion-model-dl-path: models/ldm/stable-diffusion-v1/sd-v1-4.ckpt
stable-diffusion-model-dl-path: models/ldm/stable-diffusion-v1 # stable-diffusion-model-switch: stable-diffusion-1.4
stable-diffusion-model-dl-name: v1-5-pruned-emaonly.ckpt - stable-diffusion-model: https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.ckpt
name: ${{ matrix.environment-yaml }} on ${{ matrix.os }} stable-diffusion-model-dl-path: models/ldm/stable-diffusion-v1/v1-5-pruned-emaonly.ckpt
stable-diffusion-model-switch: diffusers-1.5
name: ${{ matrix.os }} with ${{ matrix.stable-diffusion-model-switch }}
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
env: env:
CONDA_ENV_NAME: invokeai CONDA_ENV_NAME: invokeai
INVOKEAI_ROOT: '${{ github.workspace }}/invokeai' INVOKEAI_ROOT: '${{ github.workspace }}/invokeai'
PYTHONUNBUFFERED: 1
HAVE_SECRETS: ${{ secrets.HUGGINGFACE_TOKEN != '' }}
defaults: defaults:
run: run:
shell: ${{ matrix.default-shell }} shell: ${{ matrix.default-shell }}
@ -55,6 +58,19 @@ jobs:
- name: create environment.yml - name: create environment.yml
run: cp "environments-and-requirements/${{ matrix.environment-yaml }}" environment.yml run: cp "environments-and-requirements/${{ matrix.environment-yaml }}" environment.yml
- name: Use Cached Stable Diffusion Model
id: cache-sd-model
uses: actions/cache@v3
env:
cache-name: huggingface-${{ matrix.stable-diffusion-model-switch }}
with:
path: ~/.cache/huggingface
key: ${{ env.cache-name }}
- name: Check model availability
if: steps.cache-sd-model.outputs.cache-hit != true && env.HAVE_SECRETS != 'true'
run: echo -e '\a ⛔ GitHub model cache not found, and no HUGGINGFACE_TOKEN is available. Will not be able to load Stable Diffusion.' ; exit 1
- name: Use cached conda packages - name: Use cached conda packages
id: use-cached-conda-packages id: use-cached-conda-packages
uses: actions/cache@v3 uses: actions/cache@v3
@ -82,28 +98,13 @@ jobs:
if: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/development' }} if: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/development' }}
run: echo "TEST_PROMPTS=tests/validate_pr_prompt.txt" >> $GITHUB_ENV run: echo "TEST_PROMPTS=tests/validate_pr_prompt.txt" >> $GITHUB_ENV
- name: Use Cached Stable Diffusion Model - name: run preload_models.py
id: cache-sd-model
uses: actions/cache@v3
env:
cache-name: cache-${{ matrix.stable-diffusion-model }}
with:
path: ${{ env.INVOKEAI_ROOT }}/${{ matrix.stable-diffusion-model-dl-path }}
key: ${{ env.cache-name }}
- name: Download ${{ matrix.stable-diffusion-model }}
id: download-stable-diffusion-model
if: ${{ steps.cache-sd-model.outputs.cache-hit != 'true' }}
run: |
mkdir -p "${{ env.INVOKEAI_ROOT }}/${{ matrix.stable-diffusion-model-dl-path }}"
curl \
-H "Authorization: Bearer ${{ secrets.HUGGINGFACE_TOKEN }}" \
-o "${{ env.INVOKEAI_ROOT }}/${{ matrix.stable-diffusion-model-dl-path }}/${{ matrix.stable-diffusion-model-dl-name }}" \
-L ${{ matrix.stable-diffusion-model-url }}
- name: run configure_invokeai.py
id: run-preload-models id: run-preload-models
run: | run: |
if [ "${HAVE_SECRETS}" == true ] ; then
mkdir -p ~/.huggingface
echo -n '${{ secrets.HUGGINGFACE_TOKEN }}' > ~/.huggingface/token
fi
python scripts/configure_invokeai.py --no-interactive --yes python scripts/configure_invokeai.py --no-interactive --yes
- name: cat ~/.invokeai - name: cat ~/.invokeai