-
Notifications
You must be signed in to change notification settings - Fork 197
189 lines (162 loc) · 8.04 KB
/
stable_diffusion_1_5_cpp.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
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.10'
LINUX_OV_ARCHIVE_URL: https://storage.openvinotoolkit.org/repositories/openvino/packages/nightly/2025.0.0-17289-7cf2bbb8391/l_openvino_toolkit_ubuntu20_2025.0.0.dev20241105_x86_64.tgz
WINDOWS_OV_ARCHIVE_URL: https://storage.openvinotoolkit.org/repositories/openvino/packages/nightly/2025.0.0-17289-7cf2bbb8391/w_openvino_toolkit_windows_2025.0.0.dev20241105_x86_64.zip
OV_INSTALL_DIR: ${{ github.workspace }}/ov
jobs:
stable_diffusion_1_5_cpp-linux:
runs-on: ubuntu-20.04-8-cores
defaults:
run:
shell: bash -l {0}
env:
build_dir: ${{ github.workspace }}//build
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Download OpenVINO archive
run: |
wget ${{ env.LINUX_OV_ARCHIVE_URL}} --progress=bar:force:noscroll -O openvino_package.tar.gz
mkdir ${{ env.OV_INSTALL_DIR }}
tar -xzf openvino_package.tar.gz -C ${{ env.OV_INSTALL_DIR }} --strip-components=1
- 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 stable_diffusion lora_stable_diffusion py_openvino_genai --parallel
- name: Create virtual environment
run: python3 -m venv openvino_sd_cpp
- name: Install python dependencies
run: |
source openvino_sd_cpp/bin/activate
python -m pip install ./thirdparty/openvino_tokenizers/[transformers] --pre --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/nightly
python -m pip install -r ./samples/requirements.txt
- 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 main app
run: |
source ${{ env.OV_INSTALL_DIR }}/setupvars.sh
${{ env.build_dir }}/samples/cpp/text2image/stable_diffusion ./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 app
run: |
source ${{ env.OV_INSTALL_DIR }}/setupvars.sh
${{ env.build_dir }}/samples/cpp/text2image/lora_stable_diffusion ./models/dreamlike-art-dreamlike-anime-1.0/FP16 "curly-haired unicorn in the forest, anime, line" ./models/soulcard.safetensors 0.7
- name: Run Python main app
run: |
source openvino_sd_cpp/bin/activate
source ./ov/setupvars.sh
python ./samples/python/text2image/main.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 Python LoRA app
run: |
source openvino_sd_cpp/bin/activate
source ./ov/setupvars.sh
python ./samples/python/text2image/lora.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:
runs-on: windows-2019
defaults:
run:
shell: pwsh
env:
build_dir: ${{ github.workspace }}\build
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Download OpenVINO archive
run: |
mkdir ${{ env.OV_INSTALL_DIR }}
pushd ${{ env.OV_INSTALL_DIR }}
Invoke-WebRequest "${{ env.WINDOWS_OV_ARCHIVE_URL}}" -OutFile "openvino_package.zip"
Expand-Archive openvino_package.zip -DestinationPath ./tmp
mv ./tmp/*/* .
popd
- 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 stable_diffusion lora_stable_diffusion py_openvino_genai --parallel
- name: Create virtual environment
run: python -m venv openvino_sd_cpp
- name: Install python dependencies
run: |
. "./openvino_sd_cpp/Scripts/Activate.ps1"
python -m pip install ./thirdparty/openvino_tokenizers/[transformers] --pre --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/nightly
python -m pip install -r ./samples/requirements.txt
- 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 main app
run: |
. "${{ env.OV_INSTALL_DIR }}/setupvars.ps1"
"${{ env.build_dir }}/samples/cpp/text2image/Release/stable_diffusion.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 app
run: |
. "${{ env.OV_INSTALL_DIR }}/setupvars.ps1"
"${{ env.build_dir }}/samples/cpp/text2image/Release/lora_stable_diffusion.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 Python main app
run: |
. "./openvino_sd_cpp/Scripts/Activate.ps1"
. "${{ env.OV_INSTALL_DIR }}/setupvars.ps1"
$env:Path += "${{ env.build_dir }}\openvino_genai"
python .\samples\python\text2image\main.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 Python LoRA app
run: |
. "./openvino_sd_cpp/Scripts/Activate.ps1"
. "${{ env.OV_INSTALL_DIR }}/setupvars.ps1"
$env:Path += "${{ env.build_dir }}\openvino_genai"
python .\samples\python\text2image\lora.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