|
import spaces |
|
import torch |
|
from diffusers import DiffusionPipeline |
|
import gradio as gr |
|
|
|
|
|
pipe = DiffusionPipeline.from_pretrained('ptx0/terminus-xl-velocity-v2', torch_dtype=torch.bfloat16) |
|
pipe.to('cuda') |
|
|
|
|
|
@spaces.GPU |
|
def generate(prompt, guidance_scale, guidance_rescale, num_inference_steps, negative_prompt): |
|
return pipe( |
|
prompt, |
|
negative_prompt=negative_prompt, |
|
guidance_scale=guidance_scale, |
|
guidance_rescale=guidance_rescale, |
|
num_inference_steps=num_inference_steps |
|
).images |
|
|
|
|
|
example_prompts = [ |
|
["A futuristic cityscape at night under a starry sky", 7.5, 25, "blurry, overexposed"], |
|
["A serene landscape with a flowing river and autumn trees", 8.0, 20, "crowded, noisy"], |
|
["An abstract painting of joy and energy in bright colors", 9.0, 30, "dark, dull"] |
|
] |
|
|
|
|
|
iface = gr.Interface( |
|
fn=generate, |
|
inputs=[ |
|
gr.Text(label="Enter your prompt"), |
|
gr.Slider(1, 20, step=0.1, label="Guidance Scale", value=11.5), |
|
gr.Slider(0, 1, step=0.1, label="Rescale classifier-free guidance", value=0.7), |
|
gr.Slider(1, 50, step=1, label="Number of Inference Steps", value=25), |
|
gr.Text(value="underexposed, blurry, ugly, washed-out", label="Negative Prompt") |
|
], |
|
outputs=gr.Gallery(height=1024, min_width=1024, columns=2), |
|
examples=example_prompts, |
|
title="Terminus XL Velocity v2.0 Demonstration", |
|
description="Terminus XL is a v-prediction model trained with a zero-terminal SNR noise schedule, allowing it to create very dark or very bright images. Occasionally, it will work pretty well for typography, eg. text in images." |
|
).launch() |
|
|