retrAIced / pages /Text to Image.py
JavierGon12's picture
Insert all files
d8e07ba
raw
history blame
No virus
693 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,"Image generated by your prompt {promt}")