You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Support OVStableDiffusionPipelineBase to Load Textual Inversion in Runtime (#400)
* Enable OVStableDiffusionPipelineBase to load textual inversion embeddings in runtime
* Move OVTextualInversionLoaderMixin in loaders.py
* Reformat with black
* Fix format via make style
* Fix notebook format via make style
* Add docs for textual inversion
Here is an example of how you can load an OpenVINO Stable Diffusion model with pre-trained textual inversion embeddings and run inference using OpenVINO Runtime:
213
+
214
+
215
+
First, you can run original pipeline without textual inversion
216
+
```python
217
+
from optimum.intel import OVStableDiffusionPipeline
Then, you can load [sd-concepts-library/cat-toy](https://huggingface.co/sd-concepts-library/cat-toy) textual inversion embedding and run pipeline with same prompt again
232
+
```python
233
+
# Reset stable diffusion pipeline
234
+
pipeline.clear_requests()
235
+
236
+
# Load textual inversion into stable diffusion pipeline
The left image shows the generation result of original stable diffusion v1.5, the right image shows the generation result of stable diffusion v1.5 with textual inversion.
Here is an example of how you can load an SDXL OpenVINO model from [stabilityai/stable-diffusion-xl-base-1.0](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0) with pre-trained textual inversion embeddings and run inference using OpenVINO Runtime:
301
+
302
+
303
+
First, you can run original pipeline without textual inversion
304
+
```python
305
+
from optimum.intel import OVStableDiffusionXLPipeline
prompt ="charturnerv2, multiple views of the same character in the same outfit, a character turnaround of a beautiful woman wearing a black jacket and red shirt, best quality, intricate details."
310
+
# Set a random seed for better comparison
311
+
np.random.seed(0)
312
+
313
+
base = OVStableDiffusionXLPipeline.from_pretrained(model_id, export=False, compile=False)
Then, you can load [charturnerv2](https://civitai.com/models/3036/charturner-character-turnaround-helper-for-15-and-21) textual inversion embedding and run pipeline with same prompt again
320
+
```python
321
+
# Reset stable diffusion pipeline
322
+
base.clear_requests()
323
+
324
+
# Load textual inversion into stable diffusion pipeline
The left image shows the generation result of the original SDXL base 1.0, the right image shows the generation result of SDXL base 1.0with textual inversion.
0 commit comments