1from diffusers import StableDiffusionPipeline, LMSDiscreteScheduler
2import torch
3
4# this will substitute the default PNDM scheduler for K-LMS
5lms = LMSDiscreteScheduler(
6 beta_start=0.00085,
7 beta_end=0.012,
8 beta_schedule="scaled_linear"
9)
10
11guidance_scale=8.5
12steps=50
13
14cartoon_model_path = "Norod78/sd2-cartoon-blip"
15cartoon_pipe = StableDiffusionPipeline.from_pretrained(cartoon_model_path, scheduler=lms, torch_dtype=torch.float16)
16cartoon_pipe.to("cuda")
17
18def generate(prompt, file_prefix ,samples, seed=42):
19 torch.manual_seed(seed)
20 prompt += ", Very detailed, clean, high quality, sharp image"
21 cartoon_images = cartoon_pipe([prompt] * samples, num_inference_steps=steps, guidance_scale=guidance_scale)["images"]
22 for idx, image in enumerate(cartoon_images):
23 image.save(f"{file_prefix}-{idx}-{seed}-sd2-cartoon-blip.jpg")
24
25generate("An oil on canvas portrait of Snoop Dogg, Mark Ryden", "01_SnoopDog", 2, 777)
26generate("A flemish baroque painting of Kermit from the muppet show", "02_KermitFlemishBaroque", 2, 42)
27generate("Gal Gadot in Avatar", "03_GalGadotAvatar", 2, 777)
28generate("Ninja turtles, Naoto Hattori", "04_TMNT", 2, 312)
29generate("An anime town", "05_AnimeTown", 2, 777)
30generate("Family guy taking selfies at the beach", "06_FamilyGuy", 2, 555)
31generate("Pikachu as Rick and morty, Eric Wallis", "07_PikachuRnM", 2, 777)
32generate("Pikachu as Spongebob, Eric Wallis", "08_PikachuSpongeBob", 2, 42)
33generate("An oil painting of Miss. Piggy from the muppets as the Mona Lisa", "09_MsPiggyMonaLisa", 2, 42)
34generate("Rick Sanchez in star wars, Dave Dorman", "10_RickStarWars", 2, 42)
35generate("An paiting of Southpark with rainbow", "11_Southpark", 2, 777)
36generate("An oil painting of Phineas and Pherb hamering on a new machine, Eric Wallis", "12_PhineasPherb", 2, 777)
37generate("Bender, Saturno Butto", "13_Bender", 2, 777)
38generate("A psychedelic image of Bojack Horseman", "14_Bojack", 2, 777)
39generate("A movie poster for Gravity Falls Cthulhu stories", "15_GravityFalls", 2, 777)
40generate("A vibrant oil painting portrait of She-Ra", "16_Shira", 2, 512)
41#