Skip to content

Commit

Permalink
C++ text to image pipeline (openvinotoolkit#881)
Browse files Browse the repository at this point in the history
TODO:
- Python API and sample
- Update doc strings
- Update main README.md
- Add sample with custom device mapping
- Experiment with reshape + compile as part of Ctor
- Add LoRA
- Update
https://github.com/openvinotoolkit/openvino.genai/blob/master/src/docs/SUPPORTED_MODELS.md
with text 2 image generation models
  • Loading branch information
ilya-lavrenov authored Sep 19, 2024
1 parent 20238a5 commit 40f962d
Show file tree
Hide file tree
Showing 70 changed files with 2,090 additions and 71,757 deletions.
32 changes: 11 additions & 21 deletions .github/workflows/lcm_dreamshaper_cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ on:
permissions: read-all # Required by https://github.com/ossf/scorecard/blob/e23b8ad91fd6a64a0a971ca4fc0a4d1650725615/docs/checks.md#token-permissions

env:
WORKING_DIRECTORY: "./image_generation/lcm_dreamshaper_v7/cpp/"
PYTHON_VERSION: '3.9'
LINUX_OV_ARCHIVE_URL: https://storage.openvinotoolkit.org/repositories/openvino/packages/nightly/2024.5.0-16570-19eb02fe60b/l_openvino_toolkit_ubuntu20_2024.5.0.dev20240830_x86_64.tgz
WINDOWS_OV_ARCHIVE_URL: https://storage.openvinotoolkit.org/repositories/openvino/packages/nightly/2024.5.0-16570-19eb02fe60b/w_openvino_toolkit_windows_2024.5.0.dev20240830_x86_64.zip
Expand Down Expand Up @@ -40,7 +39,6 @@ jobs:
tar -xzf openvino_package.tar.gz -C ${{ env.OV_INSTALL_DIR }} --strip-components=1
- name: Build app
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
source ${{ env.OV_INSTALL_DIR }}/setupvars.sh
cmake -DCMAKE_BUILD_TYPE=Release -S ./ -B ./build/
Expand All @@ -53,30 +51,27 @@ jobs:
cache: 'pip'

- name: Create virtual environment
working-directory: ${{ env.WORKING_DIRECTORY }}
run: python3 -m venv openvino_lcm_cpp

- name: Install python dependencies
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
source openvino_lcm_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 ../../requirements.txt --pre --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/nightly
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 --pre --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/nightly
- name: Download and convert model and tokenizer
working-directory: ${{ env.WORKING_DIRECTORY }}
- name: Download and convert models and tokenizer
run: |
source openvino_lcm_cpp/bin/activate
optimum-cli export openvino --model SimianLuo/LCM_Dreamshaper_v7 models/lcm_dreamshaper_v7/FP16
optimum-cli export openvino --model SimianLuo/LCM_Dreamshaper_v7 --task stable-diffusion --weight-format fp16 models/lcm_dreamshaper_v7/FP16
- name: Run app
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
source ${{ env.OV_INSTALL_DIR }}/setupvars.sh
./build/lcm_dreamshaper
./build/samples/cpp/stable_diffusion/stable_diffusion ./models/lcm_dreamshaper_v7/FP16 "cyberpunk cityscape like Tokyo New York with tall buildings at dusk golden hour cinematic lighting"
lcm_dreamshaper_v7_cpp-windows:
runs-on: windows-latest
if: ${{ false }} # TODO: fix Windows
defaults:
run:
shell: pwsh
Expand All @@ -95,7 +90,6 @@ jobs:
popd
- name: Build app
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
. "${{ env.OV_INSTALL_DIR }}/setupvars.ps1"
cmake -DCMAKE_BUILD_TYPE=Release -S ./ -B ./build/
Expand All @@ -108,27 +102,23 @@ jobs:
cache: 'pip'

- name: Create virtual environment
working-directory: ${{ env.WORKING_DIRECTORY }}
run: python -m venv openvino_lcm_cpp

- name: Install python dependencies
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
. "./openvino_lcm_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 ../../requirements.txt --pre --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/nightly
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 --pre --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/nightly
- name: Download and convert model and tokenizer
working-directory: ${{ env.WORKING_DIRECTORY }}
- name: Download and convert models and tokenizer
run: |
. "./openvino_lcm_cpp/Scripts/Activate.ps1"
optimum-cli export openvino --model SimianLuo/LCM_Dreamshaper_v7 models/lcm_dreamshaper_v7/FP16
optimum-cli export openvino --model SimianLuo/LCM_Dreamshaper_v7 --task stable-diffusion --weight-format fp16 models/lcm_dreamshaper_v7/FP16
- name: Run app
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
. "${{ env.OV_INSTALL_DIR }}/setupvars.ps1"
./build/Release/lcm_dreamshaper.exe -r --dynamic
./build/samples/cpp/stable_diffusion/Release/lcm_dreamshaper.exe ./models/lcm_dreamshaper_v7/FP16 "cyberpunk cityscape like Tokyo New York with tall buildings at dusk golden hour cinematic lighting"
Overall_Status:
name: ci/gha_overall_status_lcm
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ jobs:
Overall_Status:
name: ci/gha_overall_status_linux
needs: [openvino_download, openvino_build, genai_python_lib, genai_package]
needs: [openvino_download, openvino_build, genai_python_lib, genai_package, genai_python_lib_whisper]
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,8 @@ jobs:
timeout 25s ${OV_INSTALL_DIR}/samples/python/multinomial_causal_lm/multinomial_causal_lm.py ./TinyLlama-1.1B-Chat-v1.0/ 0
Overall_Status:
name: ci/gha_overall_status_linux
needs: [openvino_download, openvino_build, genai_python_lib, genai_package]
name: ci/gha_overall_status_macos
needs: [openvino_download, openvino_build, genai_python_lib, genai_package, genai_python_lib_whisper]
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
Expand Down
32 changes: 11 additions & 21 deletions .github/workflows/stable_diffusion_1_5_cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ on:
permissions: read-all # Required by https://github.com/ossf/scorecard/blob/e23b8ad91fd6a64a0a971ca4fc0a4d1650725615/docs/checks.md#token-permissions

env:
WORKING_DIRECTORY: "./image_generation/stable_diffusion_1_5/cpp/"
PYTHON_VERSION: '3.10'
LINUX_OV_ARCHIVE_URL: https://storage.openvinotoolkit.org/repositories/openvino/packages/nightly/2024.5.0-16570-19eb02fe60b/l_openvino_toolkit_ubuntu20_2024.5.0.dev20240830_x86_64.tgz
WINDOWS_OV_ARCHIVE_URL: https://storage.openvinotoolkit.org/repositories/openvino/packages/nightly/2024.5.0-16570-19eb02fe60b/w_openvino_toolkit_windows_2024.5.0.dev20240830_x86_64.zip
Expand Down Expand Up @@ -40,7 +39,6 @@ jobs:
tar -xzf openvino_package.tar.gz -C ${{ env.OV_INSTALL_DIR }} --strip-components=1
- name: Build app
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
source ${{ env.OV_INSTALL_DIR }}/setupvars.sh
cmake -DCMAKE_BUILD_TYPE=Release -S ./ -B ./build/
Expand All @@ -53,30 +51,27 @@ jobs:
cache: 'pip'

- name: Create virtual environment
working-directory: ${{ env.WORKING_DIRECTORY }}
run: python3 -m venv openvino_sd_cpp

- name: Install python dependencies
working-directory: ${{ env.WORKING_DIRECTORY }}
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 ../../requirements.txt --pre --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/nightly
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 --pre --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/nightly
- name: Download and convert model and tokenizer
working-directory: ${{ env.WORKING_DIRECTORY }}
- name: Download and convert models and tokenizer
run: |
source openvino_sd_cpp/bin/activate
optimum-cli export openvino --model botp/stable-diffusion-v1-5 --task stable-diffusion models/stable_diffusion_v1_5_ov/FP16
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
- name: Run app
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
source ${{ env.OV_INSTALL_DIR }}/setupvars.sh
./build/stable_diffusion -m ./models/stable_diffusion_v1_5_ov -t FP16
./build/samples/cpp/stable_diffusion/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"
stable_diffusion_1_5_cpp-windows:
runs-on: windows-latest
if: ${{ false }} # TODO: fix Windows
defaults:
run:
shell: pwsh
Expand All @@ -95,7 +90,6 @@ jobs:
popd
- name: Build app
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
. "${{ env.OV_INSTALL_DIR }}/setupvars.ps1"
cmake -DCMAKE_BUILD_TYPE=Release -S ./ -B ./build/
Expand All @@ -108,27 +102,23 @@ jobs:
cache: 'pip'

- name: Create virtual environment
working-directory: ${{ env.WORKING_DIRECTORY }}
run: python -m venv openvino_sd_cpp

- name: Install python dependencies
working-directory: ${{ env.WORKING_DIRECTORY }}
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 ../../requirements.txt --pre --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/nightly
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 --pre --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/nightly
- name: Download and convert model and tokenizer
working-directory: ${{ env.WORKING_DIRECTORY }}
- name: Download and convert models and tokenizer
run: |
. "./openvino_sd_cpp/Scripts/Activate.ps1"
optimum-cli export openvino --model botp/stable-diffusion-v1-5 --task stable-diffusion models/stable_diffusion_v1_5_ov/FP16
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
- name: Run app
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
. "${{ env.OV_INSTALL_DIR }}/setupvars.ps1"
./build/Release/stable_diffusion.exe -m ./models/stable_diffusion_v1_5_ov -t FP16 --dynamic
./build/samples/cpp/stable_diffusion/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"
Overall_Status:
name: ci/gha_overall_status_stable_diffusion
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,8 @@ jobs:
python ${{ env.OV_INSTALL_DIR }}\samples\python\multinomial_causal_lm\multinomial_causal_lm.py TinyLlama-1.1B-Chat-v1.0 0
Overall_Status:
name: ci/gha_overall_status_linux
needs: [openvino_download, openvino_build, genai_python_lib, genai_package]
name: ci/gha_overall_status_windows
needs: [openvino_download, openvino_build, genai_python_lib, genai_package, genai_python_lib_whisper]
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
Expand Down
9 changes: 0 additions & 9 deletions image_generation/README.md

This file was deleted.

43 changes: 0 additions & 43 deletions image_generation/common/diffusers/CMakeLists.txt

This file was deleted.

12 changes: 0 additions & 12 deletions image_generation/common/diffusers/README.md

This file was deleted.

25 changes: 0 additions & 25 deletions image_generation/common/diffusers/include/lora.hpp

This file was deleted.

57 changes: 0 additions & 57 deletions image_generation/common/diffusers/include/scheduler_lcm.hpp

This file was deleted.

Loading

0 comments on commit 40f962d

Please sign in to comment.