mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
a6a766dfa2
In non-interactive mode too, as long as you're logged in.
143 lines
5.4 KiB
YAML
143 lines
5.4 KiB
YAML
name: Test invoke.py
|
|
on: [push, pull_request]
|
|
|
|
jobs:
|
|
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:
|
|
matrix:
|
|
stable-diffusion-model:
|
|
- 'stable-diffusion-1.5'
|
|
environment-yaml:
|
|
- environment-lin-amd.yml
|
|
- environment-lin-cuda.yml
|
|
- environment-mac.yml
|
|
include:
|
|
- environment-yaml: environment-lin-amd.yml
|
|
os: ubuntu-latest
|
|
default-shell: bash -l {0}
|
|
- environment-yaml: environment-lin-cuda.yml
|
|
os: ubuntu-latest
|
|
default-shell: bash -l {0}
|
|
- environment-yaml: environment-mac.yml
|
|
os: macos-12
|
|
default-shell: bash -l {0}
|
|
# - stable-diffusion-model: https://huggingface.co/CompVis/stable-diffusion-v-1-4-original/resolve/main/sd-v1-4.ckpt
|
|
# stable-diffusion-model-dl-path: models/ldm/stable-diffusion-v1/sd-v1-4.ckpt
|
|
# stable-diffusion-model-switch: stable-diffusion-1.4
|
|
- stable-diffusion-model: 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/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 }}
|
|
env:
|
|
CONDA_ENV_NAME: invokeai
|
|
INVOKEAI_ROOT: '${{ github.workspace }}/invokeai'
|
|
PYTHONUNBUFFERED: 1
|
|
HAVE_SECRETS: ${{ secrets.HUGGINGFACE_TOKEN != '' }}
|
|
defaults:
|
|
run:
|
|
shell: ${{ matrix.default-shell }}
|
|
steps:
|
|
- name: Checkout sources
|
|
id: checkout-sources
|
|
uses: actions/checkout@v3
|
|
|
|
- name: create models.yaml from example
|
|
run: |
|
|
mkdir -p ${{ env.INVOKEAI_ROOT }}/configs
|
|
cp configs/models.yaml.example ${{ env.INVOKEAI_ROOT }}/configs/models.yaml
|
|
|
|
- name: create 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
|
|
id: use-cached-conda-packages
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ~/conda_pkgs_dir
|
|
key: conda-pkgs-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles(matrix.environment-yaml) }}
|
|
|
|
- name: Activate Conda Env
|
|
id: activate-conda-env
|
|
uses: conda-incubator/setup-miniconda@v2
|
|
with:
|
|
activate-environment: ${{ env.CONDA_ENV_NAME }}
|
|
environment-file: environment.yml
|
|
miniconda-version: latest
|
|
|
|
- name: set test prompt to main branch validation
|
|
if: ${{ github.ref == 'refs/heads/main' }}
|
|
run: echo "TEST_PROMPTS=tests/preflight_prompts.txt" >> $GITHUB_ENV
|
|
|
|
- name: set test prompt to development branch validation
|
|
if: ${{ github.ref == 'refs/heads/development' }}
|
|
run: echo "TEST_PROMPTS=tests/dev_prompts.txt" >> $GITHUB_ENV
|
|
|
|
- name: set test prompt to Pull Request validation
|
|
if: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/development' }}
|
|
run: echo "TEST_PROMPTS=tests/validate_pr_prompt.txt" >> $GITHUB_ENV
|
|
|
|
- name: run preload_models.py
|
|
id: run-preload-models
|
|
run: |
|
|
if [ "${HAVE_SECRETS}" == true ] ; then
|
|
mkdir -p ~/.huggingface
|
|
echo -n '${{ secrets.HUGGINGFACE_TOKEN }}' > ~/.huggingface/token
|
|
fi
|
|
python scripts/preload_models.py \
|
|
--no-interactive \
|
|
--full-precision # can't use fp16 weights without a GPU
|
|
|
|
- name: cat ~/.invokeai
|
|
id: cat-invokeai
|
|
run: cat ~/.invokeai
|
|
|
|
- name: Run the tests
|
|
id: run-tests
|
|
env:
|
|
HF_HUB_OFFLINE: 1
|
|
HF_DATASETS_OFFLINE: 1
|
|
TRANSFORMERS_OFFLINE: 1
|
|
run: |
|
|
time python scripts/invoke.py \
|
|
--no-patchmatch \
|
|
--no-nsfw_checker \
|
|
--model ${{ matrix.stable-diffusion-model }} \
|
|
--from_file ${{ env.TEST_PROMPTS }} \
|
|
--root="${{ env.INVOKEAI_ROOT }}" \
|
|
--outdir="${{ env.INVOKEAI_ROOT }}/outputs"
|
|
|
|
- name: export conda env
|
|
id: export-conda-env
|
|
run: |
|
|
mkdir -p outputs/img-samples
|
|
conda env export --name ${{ env.CONDA_ENV_NAME }} > outputs/img-samples/environment-${{ runner.os }}-${{ runner.arch }}.yml
|
|
|
|
- name: Archive results
|
|
id: archive-results
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: results_${{ matrix.requirements-file }}_${{ matrix.python-version }}
|
|
path: ${{ env.INVOKEAI_ROOT }}/outputs
|