Small Stable Diffusion V0
Demo for Small Stable Diffusion V0 Stable Diffusion model.
from diffusers import StableDiffusionPipeline, StableDiffusionImg2ImgPipeline, DPMSolverMultistepScheduler import gradio as gr import cpuinfo import torch from PIL import Image from diffusers import OnnxStableDiffusionPipeline import pipeline_openvino_stable_diffusion model_id = 'OFA-Sys/small-stable-diffusion-v0' prefix = '' scheduler = DPMSolverMultistepScheduler.from_pretrained(model_id, subfolder="scheduler") onnx_pipe = OnnxStableDiffusionPipeline.from_pretrained( "OFA-Sys/small-stable-diffusion-v0", revision="onnx", provider="CPUExecutionProvider", ) pipe = pipeline_openvino_stable_diffusion.OpenVINOStableDiffusionPipeline.from_onnx_pipeline(onnx_pipe) def error_str(error, title="Error"): return f"""#### {title} {error}""" if error else "" def inference(prompt, guidance, steps, width=512, height=512, seed=0, neg_prompt=""): generator = torch.Generator('cuda').manual_seed(seed) if seed != 0 else None try: return txt_to_img(prompt, neg_prompt, guidance, steps, width, height, generator), None except Exception as e: return None, error_str(e) def txt_to_img(prompt, neg_prompt, guidance, steps, width, height, generator): result = pipe( prompt, negative_prompt = neg_prompt, num_inference_steps = int(steps), guidance_scale = guidance, width = width, height = height, generator = generator) return result.images[0] css = """.main-div div{display:inline-flex;align-items:center;gap:.8rem;font-size:1.75rem}.main-div div h1{font-weight:900;margin-bottom:7px}.main-div p{margin-bottom:10px;font-size:94%}a{text-decoration:underline}.tabs{margin-top:0;margin-bottom:0}#gallery{min-height:20rem} """ with gr.Blocks(css=css) as demo: gr.HTML( f"""
Demo for Small Stable Diffusion V0 Stable Diffusion model.
This space was created using SD Space Creator.