Upload 10 files
Browse files- .gitattributes +35 -0
- README.md +51 -0
- config.json +38 -0
- convert_to_openvino.py +22 -0
- vae_decoder/config.json +38 -0
- vae_decoder/openvino_model.bin +3 -0
- vae_decoder/openvino_model.xml +0 -0
- vae_encoder/config.json +38 -0
- vae_encoder/openvino_model.bin +3 -0
- vae_encoder/openvino_model.xml +0 -0
.gitattributes
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: mit
|
3 |
+
pipeline_tag: text-to-image
|
4 |
+
tags:
|
5 |
+
- openvino
|
6 |
+
- text-to-image
|
7 |
+
inference: false
|
8 |
+
---
|
9 |
+
|
10 |
+
## Model Descriptions:
|
11 |
+
|
12 |
+
This repo contains OpenVino model files for [madebyollin's Tiny AutoEncoder for Stable Diffusion](https://huggingface.co/madebyollin/taesd).
|
13 |
+
|
14 |
+
## Using in 🧨 diffusers:
|
15 |
+
|
16 |
+
To install the requirements for this demo, do pip install "optimum-intel[openvino, diffusers]".
|
17 |
+
|
18 |
+
```python
|
19 |
+
from huggingface_hub import snapshot_download
|
20 |
+
from optimum.intel.openvino import OVStableDiffusionPipeline
|
21 |
+
from optimum.intel.openvino.modeling_diffusion import OVModelVaeDecoder, OVModelVaeEncoder, OVBaseModel
|
22 |
+
|
23 |
+
# Create class wrappers which allow us to specify model_dir of TAESD instead of original pipeline dir
|
24 |
+
|
25 |
+
class CustomOVModelVaeDecoder(OVModelVaeDecoder):
|
26 |
+
def __init__(
|
27 |
+
self, model, parent_model, ov_config = None, model_dir = None,
|
28 |
+
):
|
29 |
+
super(OVModelVaeDecoder, self).__init__(model, parent_model, ov_config, "vae_decoder", model_dir)
|
30 |
+
|
31 |
+
class CustomOVModelVaeEncoder(OVModelVaeEncoder):
|
32 |
+
def __init__(
|
33 |
+
self, model, parent_model, ov_config = None, model_dir = None,
|
34 |
+
):
|
35 |
+
super(OVModelVaeEncoder, self).__init__(model, parent_model, ov_config, "vae_encoder", model_dir)
|
36 |
+
|
37 |
+
pipe = OVStableDiffusionPipeline.from_pretrained("OpenVINO/stable-diffusion-1-5-fp32", compile=False)
|
38 |
+
|
39 |
+
# Inject TAESD
|
40 |
+
|
41 |
+
taesd_dir = snapshot_download(repo_id="deinferno/taesd-openvino")
|
42 |
+
pipe.vae_decoder = CustomOVModelVaeDecoder(model = OVBaseModel.load_model(f"{taesd_dir}/vae_decoder/openvino_model.xml"), parent_model = pipe, model_dir = taesd_dir)
|
43 |
+
pipe.vae_encoder = CustomOVModelVaeEncoder(model = OVBaseModel.load_model(f"{taesd_dir}/vae_encoder/openvino_model.xml"), parent_model = pipe, model_dir = taesd_dir)
|
44 |
+
|
45 |
+
pipe.reshape(batch_size=1, height=512, width=512, num_images_per_prompt=1)
|
46 |
+
pipe.compile()
|
47 |
+
|
48 |
+
prompt = "plant pokemon in jungle"
|
49 |
+
output = pipe(prompt, num_inference_steps=50, output_type="pil")
|
50 |
+
output.images[0].save("result.png")
|
51 |
+
```
|
config.json
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_class_name": "AutoencoderTiny",
|
3 |
+
"_diffusers_version": "0.20.2",
|
4 |
+
"_name_or_path": "madebyollin/taesd",
|
5 |
+
"act_fn": "relu",
|
6 |
+
"decoder_block_out_channels": [
|
7 |
+
64,
|
8 |
+
64,
|
9 |
+
64,
|
10 |
+
64
|
11 |
+
],
|
12 |
+
"encoder_block_out_channels": [
|
13 |
+
64,
|
14 |
+
64,
|
15 |
+
64,
|
16 |
+
64
|
17 |
+
],
|
18 |
+
"force_upcast": false,
|
19 |
+
"in_channels": 3,
|
20 |
+
"latent_channels": 4,
|
21 |
+
"latent_magnitude": 3,
|
22 |
+
"latent_shift": 0.5,
|
23 |
+
"num_decoder_blocks": [
|
24 |
+
3,
|
25 |
+
3,
|
26 |
+
3,
|
27 |
+
1
|
28 |
+
],
|
29 |
+
"num_encoder_blocks": [
|
30 |
+
1,
|
31 |
+
3,
|
32 |
+
3,
|
33 |
+
3
|
34 |
+
],
|
35 |
+
"out_channels": 3,
|
36 |
+
"scaling_factor": 1.0,
|
37 |
+
"upsampling_scaling_factor": 2
|
38 |
+
}
|
convert_to_openvino.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from diffusers import AutoencoderTiny
|
2 |
+
|
3 |
+
from optimum.exporters.openvino import export
|
4 |
+
from optimum.exporters.onnx.model_configs import VaeDecoderOnnxConfig, VaeEncoderOnnxConfig
|
5 |
+
|
6 |
+
taesd = AutoencoderTiny.from_pretrained("madebyollin/taesd")
|
7 |
+
|
8 |
+
# Config in root of repo
|
9 |
+
|
10 |
+
taesd.save_config("./")
|
11 |
+
|
12 |
+
# TAESD Decoder
|
13 |
+
|
14 |
+
taesd.forward = lambda latent_sample: taesd.decode(x=latent_sample)
|
15 |
+
export(model = taesd, config = VaeDecoderOnnxConfig( config = taesd.config, task = "semantic-segmentation"), output = "./vae_decoder/openvino_model.xml")
|
16 |
+
taesd.save_config("./vae_decoder")
|
17 |
+
|
18 |
+
# TAESD Encoder
|
19 |
+
|
20 |
+
taesd.forward = lambda sample: {"latent_sample": taesd.encode(x=sample)["latents"]}
|
21 |
+
export(model = taesd, config = VaeEncoderOnnxConfig( config = taesd.config, task = "semantic-segmentation"), output = "./vae_encoder/openvino_model.xml")
|
22 |
+
taesd.save_config("./vae_encoder")
|
vae_decoder/config.json
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_class_name": "AutoencoderTiny",
|
3 |
+
"_diffusers_version": "0.20.2",
|
4 |
+
"_name_or_path": "madebyollin/taesd",
|
5 |
+
"act_fn": "relu",
|
6 |
+
"decoder_block_out_channels": [
|
7 |
+
64,
|
8 |
+
64,
|
9 |
+
64,
|
10 |
+
64
|
11 |
+
],
|
12 |
+
"encoder_block_out_channels": [
|
13 |
+
64,
|
14 |
+
64,
|
15 |
+
64,
|
16 |
+
64
|
17 |
+
],
|
18 |
+
"force_upcast": false,
|
19 |
+
"in_channels": 3,
|
20 |
+
"latent_channels": 4,
|
21 |
+
"latent_magnitude": 3,
|
22 |
+
"latent_shift": 0.5,
|
23 |
+
"num_decoder_blocks": [
|
24 |
+
3,
|
25 |
+
3,
|
26 |
+
3,
|
27 |
+
1
|
28 |
+
],
|
29 |
+
"num_encoder_blocks": [
|
30 |
+
1,
|
31 |
+
3,
|
32 |
+
3,
|
33 |
+
3
|
34 |
+
],
|
35 |
+
"out_channels": 3,
|
36 |
+
"scaling_factor": 1.0,
|
37 |
+
"upsampling_scaling_factor": 2
|
38 |
+
}
|
vae_decoder/openvino_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c60ba3ef7ecb6e6a0f02b454ba94e15d73c962ee7667adf547e3a253c9722922
|
3 |
+
size 4890144
|
vae_decoder/openvino_model.xml
ADDED
The diff for this file is too large to render.
See raw diff
|
|
vae_encoder/config.json
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_class_name": "AutoencoderTiny",
|
3 |
+
"_diffusers_version": "0.20.2",
|
4 |
+
"_name_or_path": "madebyollin/taesd",
|
5 |
+
"act_fn": "relu",
|
6 |
+
"decoder_block_out_channels": [
|
7 |
+
64,
|
8 |
+
64,
|
9 |
+
64,
|
10 |
+
64
|
11 |
+
],
|
12 |
+
"encoder_block_out_channels": [
|
13 |
+
64,
|
14 |
+
64,
|
15 |
+
64,
|
16 |
+
64
|
17 |
+
],
|
18 |
+
"force_upcast": false,
|
19 |
+
"in_channels": 3,
|
20 |
+
"latent_channels": 4,
|
21 |
+
"latent_magnitude": 3,
|
22 |
+
"latent_shift": 0.5,
|
23 |
+
"num_decoder_blocks": [
|
24 |
+
3,
|
25 |
+
3,
|
26 |
+
3,
|
27 |
+
1
|
28 |
+
],
|
29 |
+
"num_encoder_blocks": [
|
30 |
+
1,
|
31 |
+
3,
|
32 |
+
3,
|
33 |
+
3
|
34 |
+
],
|
35 |
+
"out_channels": 3,
|
36 |
+
"scaling_factor": 1.0,
|
37 |
+
"upsampling_scaling_factor": 2
|
38 |
+
}
|
vae_encoder/openvino_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d034adf798d6d0f18216c8cd3de5c534af44dbb967ba37c555a5f9879af4b7cf
|
3 |
+
size 4890128
|
vae_encoder/openvino_model.xml
ADDED
The diff for this file is too large to render.
See raw diff
|
|