from diffusers import AutoencoderKL, DDPMScheduler, KolorsPipeline, UNet2DConditionModel
from diffusers.pipelines.kolors.text_encoder import ChatGLMConfig, ChatGLMModel
import json
from optimum.quanto.models import QuantizedDiffusersModel
from text_encoder.quantization import quantize
from safetensors.torch import load_model
import torch
classKolorsUNet2DConditionModel(QuantizedDiffusersModel):
base_class = UNet2DConditionModel
wrapped_unet = KolorsUNet2DConditionModel.from_pretrained('./kolors-fp8')
# You can make a copy of the Kolors-diffusers/text_encoder folder.# with open('./text_encoder/config.json') as encoder_f:# encoder_config = json.load(encoder_f)# encoder_config = ChatGLMConfig.from_dict(encoder_config)# text_encoder = ChatGLMModel(encoder_config)# quantize(text_encoder.encoder, 8)# load_model(text_encoder, './chatglm3-8bit.safetensors')
pipe = KolorsPipeline.from_pretrained('Kwai-Kolors/Kolors-diffusers',
unet=wrapped_unet._wrapped.to(dtype=torch.float16),
# text_encoder=text_encoder,
torch_dtype=torch.float16).to('cuda')
image = pipe('cat playing piano', num_inference_steps=20).images[0]
image.save('cat.png')
Disclaimer
Use of this code and the copy of documentation requires citation and attribution to the author via a link to their Hugging Face profile in all resulting work.
Runs of twodgirl Kolors-unet-optimum-quant-float8 on huggingface.co
0
Total runs
0
24-hour runs
0
3-day runs
0
7-day runs
0
30-day runs
More Information About Kolors-unet-optimum-quant-float8 huggingface.co Model
More Kolors-unet-optimum-quant-float8 license Visit here:
Kolors-unet-optimum-quant-float8 huggingface.co is an AI model on huggingface.co that provides Kolors-unet-optimum-quant-float8's model effect (), which can be used instantly with this twodgirl Kolors-unet-optimum-quant-float8 model. huggingface.co supports a free trial of the Kolors-unet-optimum-quant-float8 model, and also provides paid use of the Kolors-unet-optimum-quant-float8. Support call Kolors-unet-optimum-quant-float8 model through api, including Node.js, Python, http.
Kolors-unet-optimum-quant-float8 huggingface.co is an online trial and call api platform, which integrates Kolors-unet-optimum-quant-float8's modeling effects, including api services, and provides a free online trial of Kolors-unet-optimum-quant-float8, you can try Kolors-unet-optimum-quant-float8 online for free by clicking the link below.
twodgirl Kolors-unet-optimum-quant-float8 online free url in huggingface.co:
Kolors-unet-optimum-quant-float8 is an open source model from GitHub that offers a free installation service, and any user can find Kolors-unet-optimum-quant-float8 on GitHub to install. At the same time, huggingface.co provides the effect of Kolors-unet-optimum-quant-float8 install, users can directly use Kolors-unet-optimum-quant-float8 installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
Kolors-unet-optimum-quant-float8 install url in huggingface.co: