deinferno commited on
Commit
f99d5f3
0 Parent(s):

Initial commit

Browse files
.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,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ pipeline_tag: text-to-image
4
+ tags:
5
+ - onnx
6
+ - text-to-image
7
+ inference: false
8
+ ---
9
+
10
+ ## Model Descriptions:
11
+
12
+ This repo contains ONNX 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["onnxruntime"].
17
+
18
+ ```python
19
+ from optimum.onnxruntime import ORTStableDiffusionPipeline
20
+
21
+ model_id = "CompVis/stable-diffusion-v1-4"
22
+ pipeline = ORTStableDiffusionPipeline.from_pretrained(model_id, revision="onnx")
23
+
24
+ # Inject TAESD
25
+
26
+ taesd_id = "deinferno/taesd-onnx"
27
+ pipeline.vae_decoder = OnnxRuntimeModel.from_pretrained(taesd_id, subfolder = "vae_decoder")
28
+ pipeline.vae_encoder = OnnxRuntimeModel.from_pretrained(taesd_id, subfolder = "vae_encoder")
29
+
30
+ prompt = "sailing ship in storm by Leonardo da Vinci"
31
+ image = pipeline(prompt).images[0]
32
+ output.save("result.png")
33
+ ```
convert_to_onnx.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from diffusers import AutoencoderTiny
2
+
3
+ from pathlib import Path
4
+
5
+ from optimum.exporters.onnx import export
6
+ from optimum.exporters.onnx.model_configs import VaeDecoderOnnxConfig, VaeEncoderOnnxConfig
7
+ taesd = AutoencoderTiny.from_pretrained("madebyollin/taesd")
8
+
9
+ # TAESD Decoder
10
+
11
+ taesd.forward = lambda latent_sample: taesd.decode(x=latent_sample)
12
+ export(model = taesd, config = VaeDecoderOnnxConfig( config = taesd.config, task = "semantic-segmentation"), output = Path("./vae_decoder/model.onnx"))
13
+
14
+ # TAESD Encoder
15
+
16
+ taesd.forward = lambda sample: {"latent_sample": taesd.encode(x=sample)["latents"]}
17
+ export(model = taesd, config = VaeEncoderOnnxConfig( config = taesd.config, task = "semantic-segmentation"), output = Path("./vae_encoder/model.onnx"))
vae_decoder/model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2f82beecbb0dce16ccf7c327f096eed54c39d91d0cab20416ffa1fcd39f6928f
3
+ size 4912246
vae_encoder/model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:79f10fc3d9272ae1be42c594b9d1f8f235b2a69ece524ccb2e315d394c873a2e
3
+ size 4910073