sdxl-bigasp2 / app.py
bobber's picture
Update app.py
7488de9 verified
raw
history blame
3.63 kB
import gradio as gr
import spaces
import torch
from diffusers import StableDiffusionXLPipeline
from diffusers import AutoencoderTiny, AutoencoderKL
#taef1 = AutoencoderTiny.from_pretrained("madebyollin/taef1", torch_dtype=dtype).to(device)
good_vae = AutoencoderKL.from_pretrained("black-forest-labs/FLUX.1-dev", subfolder="vae", torch_dtype=dtype).to(device)
dtype = torch.bfloat16
pipeline = StableDiffusionXLPipeline.from_pretrained("bobber/bigasp2", torch_dtype=dtype, vae=good_vae).to("cuda")
@spaces.GPU
def generate(prompt, negative_prompt, width, height, sample_steps, guidance_scale):
return pipeline(prompt=prompt, negative_prompt=negative_prompt, width=width, height=height, guidance_scale=guidance_scale, num_inference_steps=sample_steps).images[0]
with gr.Blocks() as interface:
with gr.Column():
with gr.Row():
with gr.Column():
prompt = gr.Textbox(label="Prompt", info="What do you want?", value="score_6_up, A high-resolution photograph of a young, nude woman with fair skin and long, wavy red hair cascading down her back. She is standing in a lush, tropical jungle setting, surrounded by dense greenery and various types of plants. Her physique is slender with small, perky breasts and a flat stomach. She has a relaxed, confident expression on her face, looking directly at the camera. The woman has a pair of translucent, fairy-like wings attached to her back, with a light, almost golden hue. The wings have a delicate, almost ethereal quality, contrasting with her natural skin tone. She is standing on a moss-covered rock in a small, shallow pond, with her left hand resting on the rock for support and her right arm hanging loosely by her side. The background is a dense, vibrant jungle, with large leaves and ferns in various shades of green, creating a lush, tropical atmosphere. The lighting is soft and natural, with sunlight filtering through the foliage, casting a gentle glow on her skin and the surrounding environment. The overall mood of the image is serene and magical, blending elements of fantasy and nature.", lines=4, interactive=True)
negative_prompt = gr.Textbox(label="Negative Prompt", info="What do you want to exclude from the image?", value="score_1, score_2, score_3", lines=4, interactive=True)
with gr.Column():
generate_button = gr.Button("Generate")
output = gr.Image()
with gr.Row():
with gr.Accordion(label="Advanced Settings", open=False):
with gr.Row():
with gr.Column():
width = gr.Slider(label="Width", info="The width in pixels of the generated image.", value=1024, minimum=128, maximum=4096, step=64, interactive=True)
height = gr.Slider(label="Height", info="The height in pixels of the generated image.", value=1024, minimum=128, maximum=4096, step=64, interactive=True)
with gr.Column():
sampling_steps = gr.Slider(label="Sampling Steps", info="The number of denoising steps.", value=40, minimum=4, maximum=50, step=1, interactive=True)
with gr.Column():
guidance_scale = gr.Slider(label="Guidance Scale", info="Guidance scale.", value=2.5, minimum=1, maximum=10, step=0.1, interactive=True)
generate_button.click(fn=generate, inputs=[prompt, negative_prompt, width, height, sampling_steps, guidance_scale], outputs=[output])
if __name__ == "__main__":
interface.launch()