from contextlib import nullcontext import gradio as gr import torch from torch import autocast from diffusers import StableDiffusionPipeline device = "cuda" if torch.cuda.is_available() else "cpu" context = autocast if device == "cuda" else nullcontext dtype = torch.float16 if device == "cuda" else torch.float32 pipe = StableDiffusionPipeline.from_pretrained("ringhyacinth/nail-set-diffuser", torch_dtype=dtype) pipe = pipe.to(device) # Disable nsfw checker disable_safety = True if disable_safety: def null_safety(images, **kwargs): return images, False pipe.safety_checker = null_safety def infer(prompt, n_samples, steps, scale): with context("cuda"): images = pipe(n_samples*[prompt], guidance_scale=scale, num_inference_steps=steps).images return images examples = [ [ 'Nail Set, hamilton nail, broadway musical theme nail.', 2, 7, ], [ 'Nail Set, chinese new year nail, super detailed', 2, 7, ], [ 'Nail Set, thanksgiving nail, super detailed', 2, 7, ], ] with block: gr.HTML( """
Generate a new Nail Set from a text description. Use the token {Nail Set} in your prompts for the effect.
Use the tokens {Nail Set} in your prompts for the effect.
Put in a text prompt and generate your own nail set!
Trained by Weekend and Hyacinth