retrAIced / pages /Text to Image.py
JavierGon12's picture
Wrong library causing an error
c982d4a
raw
history blame contribute delete
695 Bytes
import torch
from diffusers import LCMScheduler, AutoPipelineForText2Image
import streamlit as st
model_id = "stabilityai/stable-diffusion-xl-base-1.0"
adapter_id = "latent-consistency/lcm-lora-sdxl"
pipe = AutoPipelineForText2Image.from_pretrained(model_id, torch_dtype=torch.float32, variant="fp16")
pipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)
#pipe.to("cuda")
# load and fuse lcm lora
pipe.load_lora_weights(adapter_id)
pipe.fuse_lora()
prompt = st.text_input(str("Insert here you prompt?"))
# disable guidance_scale by passing 0
image = pipe(prompt=prompt, num_inference_steps=4, guidance_scale=0).images[0]
st.image(image,f"Image generated by your prompt {prompt}")