[Prompt lookup] (#1245) #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: stable_diffusion_1_5_cpp | |
on: | |
workflow_dispatch: | |
pull_request: | |
merge_group: | |
push: | |
branches: | |
- master | |
- 'releases/**' | |
permissions: read-all # Required by https://github.com/ossf/scorecard/blob/e23b8ad91fd6a64a0a971ca4fc0a4d1650725615/docs/checks.md#token-permissions | |
concurrency: | |
# github.ref is not unique in post-commit | |
group: ${{ github.event_name == 'push' && github.run_id || github.ref }}-stable-diffusion-1-5-cpp | |
cancel-in-progress: true | |
env: | |
PYTHON_VERSION: '3.11' | |
OV_INSTALL_DIR: ${{ github.workspace }}/ov | |
jobs: | |
openvino_download_linux: | |
name: Download OpenVINO for Linux | |
outputs: | |
status: ${{ steps.openvino_download.outcome }} | |
ov_artifact_name: ${{ steps.openvino_download.outputs.ov_artifact_name }} | |
ov_wheel_source: ${{ steps.openvino_download.outputs.ov_wheel_source }} | |
ov_version: ${{ steps.openvino_download.outputs.ov_version }} | |
timeout-minutes: 10 | |
defaults: | |
run: | |
shell: bash | |
runs-on: aks-linux-2-cores-8gb | |
container: | |
image: 'openvinogithubactions.azurecr.io/openvino_provider:0.1.0' | |
volumes: | |
- /mount:/mount | |
- ${{ github.workspace }}:${{ github.workspace }} | |
steps: | |
- uses: openvinotoolkit/openvino/.github/actions/openvino_provider@master | |
id: openvino_download | |
with: | |
platform: ubuntu22 | |
commit_packages_to_provide: wheels | |
revision: latest_available_commit | |
openvino_download_windows: | |
name: Download OpenVINO for Windows | |
outputs: | |
status: ${{ steps.openvino_download.outcome }} | |
ov_artifact_name: ${{ steps.openvino_download.outputs.ov_artifact_name }} | |
ov_wheel_source: ${{ steps.openvino_download.outputs.ov_wheel_source }} | |
ov_version: ${{ steps.openvino_download.outputs.ov_version }} | |
timeout-minutes: 10 | |
defaults: | |
run: | |
shell: bash | |
runs-on: aks-linux-2-cores-8gb | |
container: | |
image: 'openvinogithubactions.azurecr.io/openvino_provider:0.1.0' | |
volumes: | |
- /mount:/mount | |
- ${{ github.workspace }}:${{ github.workspace }} | |
steps: | |
- uses: openvinotoolkit/openvino/.github/actions/openvino_provider@master | |
id: openvino_download | |
with: | |
platform: windows | |
commit_packages_to_provide: wheels | |
revision: latest_available_commit | |
stable_diffusion_1_5_cpp-linux: | |
runs-on: ubuntu-22.04-8-cores | |
needs: [ openvino_download_linux ] | |
defaults: | |
run: | |
shell: bash -l {0} | |
env: | |
build_dir: ${{ github.workspace }}//build | |
SRC_DIR: ${{ github.workspace }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Download OpenVINO package | |
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 | |
with: | |
name: ${{ needs.openvino_download_linux.outputs.ov_artifact_name }} | |
path: ${{ env.OV_INSTALL_DIR }} | |
merge-multiple: true | |
- name: Setup Python ${{ env.PYTHON_VERSION }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
cache: 'pip' | |
- name: Build app | |
run: | | |
source ${{ env.OV_INSTALL_DIR }}/setupvars.sh | |
cmake -DCMAKE_BUILD_TYPE=Release -S ./ -B ${{ env.build_dir }} | |
cmake --build ${{ env.build_dir }} --config Release --target text2image image2image inpainting heterogeneous_stable_diffusion lora_text2image py_openvino_genai --parallel | |
- name: Create virtual environment | |
run: python3 -m venv openvino_sd_cpp | |
- name: Install python dependencies | |
run: | | |
source ${{ github.workspace }}/openvino_sd_cpp/bin/activate | |
python -m pip install ${{ env.SRC_DIR }}/thirdparty/openvino_tokenizers/[transformers] ${{ needs.openvino_download_linux.outputs.ov_wheel_source }} | |
python -m pip install -r ${{ env.SRC_DIR }}/samples/requirements.txt | |
working-directory: ${{ env.OV_INSTALL_DIR }} | |
- name: Download and convert models and tokenizer | |
run: | | |
source openvino_sd_cpp/bin/activate | |
optimum-cli export openvino --model dreamlike-art/dreamlike-anime-1.0 --weight-format fp16 --task stable-diffusion models/dreamlike-art-dreamlike-anime-1.0/FP16 | |
wget -O ./models/soulcard.safetensors https://civitai.com/api/download/models/72591 | |
- name: Run text2image app | |
run: | | |
source ${{ env.OV_INSTALL_DIR }}/setupvars.sh | |
${{ env.build_dir }}/samples/cpp/image_generation/text2image ./models/dreamlike-art-dreamlike-anime-1.0/FP16 "cyberpunk cityscape like Tokyo New York with tall buildings at dusk golden hour cinematic lighting" | |
- name: Run lora_text2image app | |
run: | | |
source ${{ env.OV_INSTALL_DIR }}/setupvars.sh | |
${{ env.build_dir }}/samples/cpp/image_generation/lora_text2image ./models/dreamlike-art-dreamlike-anime-1.0/FP16 "curly-haired unicorn in the forest, anime, line" ./models/soulcard.safetensors 0.7 | |
- name: Run text2image.py app | |
run: | | |
source openvino_sd_cpp/bin/activate | |
source ./ov/setupvars.sh | |
python ./samples/python/image_generation/text2image.py ./models/dreamlike-art-dreamlike-anime-1.0/FP16 "cyberpunk cityscape like Tokyo New York with tall buildings at dusk golden hour cinematic lighting" | |
env: | |
PYTHONPATH: ${{ env.build_dir }} | |
- name: Run lora_text2image.py app | |
run: | | |
source openvino_sd_cpp/bin/activate | |
source ./ov/setupvars.sh | |
python ./samples/python/image_generation/lora_text2image.py ./models/dreamlike-art-dreamlike-anime-1.0/FP16 "curly-haired unicorn in the forest, anime, line" ./models/soulcard.safetensors 0.7 | |
env: | |
PYTHONPATH: ${{ env.build_dir }} | |
stable_diffusion_1_5_cpp-windows: | |
needs: [ openvino_download_windows ] | |
runs-on: windows-2019 | |
defaults: | |
run: | |
shell: pwsh | |
env: | |
build_dir: ${{ github.workspace }}\build | |
SRC_DIR: ${{ github.workspace }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Download OpenVINO package | |
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 | |
with: | |
name: ${{ needs.openvino_download_windows.outputs.ov_artifact_name }} | |
path: ${{ env.OV_INSTALL_DIR }} | |
merge-multiple: true | |
- name: Setup Python ${{ env.PYTHON_VERSION }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
cache: 'pip' | |
- name: Build app | |
run: | | |
. "${{ env.OV_INSTALL_DIR }}/setupvars.ps1" | |
cmake -DCMAKE_BUILD_TYPE=Release -S ./ -B ${{ env.build_dir }} | |
cmake --build ${{ env.build_dir }} --config Release --target text2image image2image inpainting heterogeneous_stable_diffusion lora_text2image py_openvino_genai --parallel | |
- name: Create virtual environment | |
run: python -m venv openvino_sd_cpp | |
- name: Install python dependencies | |
run: | | |
. "${{ github.workspace }}/openvino_sd_cpp/Scripts/Activate.ps1" | |
python -m pip install ${{ env.SRC_DIR }}/thirdparty/openvino_tokenizers/[transformers] ${{ needs.openvino_download_windows.outputs.ov_wheel_source }} | |
python -m pip install -r ${{ env.SRC_DIR }}/samples/requirements.txt | |
working-directory: ${{ env.OV_INSTALL_DIR }} | |
- name: Download and convert models and tokenizer | |
run: | | |
. "./openvino_sd_cpp/Scripts/Activate.ps1" | |
optimum-cli export openvino --model dreamlike-art/dreamlike-anime-1.0 --task stable-diffusion --weight-format fp16 models/dreamlike-art-dreamlike-anime-1.0/FP16 | |
Invoke-WebRequest -Uri 'https://civitai.com/api/download/models/72591' -OutFile 'models/soulcard.safetensors' | |
- name: Run text2image app | |
run: | | |
. "${{ env.OV_INSTALL_DIR }}/setupvars.ps1" | |
"${{ env.build_dir }}/samples/cpp/image_generation/Release/text2image.exe ./models/dreamlike-art-dreamlike-anime-1.0/FP16 'cyberpunk cityscape like Tokyo New York with tall buildings at dusk golden hour cinematic lighting'" | |
env: | |
PATH: ${{ env.build_dir }}\openvino_genai | |
- name: Run lora_text2image app | |
run: | | |
. "${{ env.OV_INSTALL_DIR }}/setupvars.ps1" | |
"${{ env.build_dir }}/samples/cpp/image_generation/Release/lora_text2image.exe ./models/dreamlike-art-dreamlike-anime-1.0/FP16 'curly-haired unicorn in the forest, anime, line' ./models/soulcard.safetensors 0.7" | |
env: | |
PATH: ${{ env.build_dir }}\openvino_genai | |
- name: Run text2image.py app | |
run: | | |
. "./openvino_sd_cpp/Scripts/Activate.ps1" | |
. "${{ env.OV_INSTALL_DIR }}/setupvars.ps1" | |
$env:Path += "${{ env.build_dir }}\openvino_genai" | |
python .\samples\python\image_generation\text2image.py .\models\dreamlike-art-dreamlike-anime-1.0\FP16 "cyberpunk cityscape like Tokyo New York with tall buildings at dusk golden hour cinematic lighting" | |
env: | |
PYTHONPATH: ${{ env.build_dir }} | |
- name: Run lora_text2image.py app | |
run: | | |
. "./openvino_sd_cpp/Scripts/Activate.ps1" | |
. "${{ env.OV_INSTALL_DIR }}/setupvars.ps1" | |
$env:Path += "${{ env.build_dir }}\openvino_genai" | |
python .\samples\python\image_generation\lora_text2image.py .\models\dreamlike-art-dreamlike-anime-1.0\FP16 "curly-haired unicorn in the forest, anime, line" .\models\soulcard.safetensors 0.7 | |
env: | |
PYTHONPATH: ${{ env.build_dir }} | |
Overall_Status: | |
name: ci/gha_overall_status_stable_diffusion | |
needs: [stable_diffusion_1_5_cpp-linux, stable_diffusion_1_5_cpp-windows] | |
if: ${{ always() }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check status of all jobs | |
if: >- | |
${{ | |
contains(needs.*.result, 'failure') || | |
contains(needs.*.result, 'cancelled') | |
}} | |
run: exit 1 |