File size: 2,089 Bytes
f46ba2f
802f5e1
 
 
af8341a
802f5e1
af8341a
f46ba2f
af8341a
802f5e1
 
 
 
af8341a
802f5e1
 
 
 
 
af8341a
 
802f5e1
 
 
af8341a
802f5e1
 
 
 
af8341a
802f5e1
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

from tensorflow.keras.models import load_model
import tensorflow as tf
import os
import torch
from diffusers import StableDiffusionPipeline
from torch import autocast


model_path = "Fung804/makoto-shinkai-v2"
pipe = StableDiffusionPipeline.from_pretrained(model_path, torch_dtype=torch.float16)
pipe.to("cuda")
pipe.vae.enable_tiling()

prompt = "A train track with a sky background , realistic, highly detailed, high quality" #@param {type:"string"}
negative_prompt = "((low quality)),((poor quality)),((clone)),retro style, bad anatomy,((lowres)), blurry, (worst quality), ((low quality)), normal quality,bad anatomy, disfigured, deformed, mutation, mutilated, ugly, totem pole,(poorly drawn face), cloned face, several faces, long neck, mutated hands, bad hands, poorly drawn hands,extra limbs, malformed limbs, missing arms, missing fingers, extra fingers, fused fingers, too many fingers,missing legs, extra legs, malformed legs, extra digit, fewer digits, glitchy, cropped, jpeg artifacts, signature, watermark, username, text, errorretro style ,bad anatomy,((lowres)), blurry, (worst quality), normal quality,bad anatomy, disfigured, deformed, mutation, mutilated, ugly, totem pole,(poorly drawn face), cloned face, several faces, long neck, mutated hands, bad hands, poorly drawn hands,extra limbs, malformed limbs, missing arms, missing fingers, extra fingers, fused fingers, too many fingers,missing legs, extra legs, malformed legs, extra digit, fewer digits, glitchy, cropped, jpeg artifacts, signature, watermark, username, text, error" #@param {type:"string"}
n_samples = 4 #@param {type:"number"}
scale = 7.5 #@param {type:"number"}
timesteps = 50


# Sometimes the nsfw checker is confused by the images, you can disable
# it at your own risk here
disable_safety = True

if disable_safety:
  def null_safety(images, **kwargs):
      return images, False
  pipe.safety_checker = null_safety

with autocast("cuda"):
  images = pipe(n_samples*[prompt], guidance_scale=scale,num_inference_steps=timesteps).images

for idx, im in enumerate(images):
  im.save(f"{idx:06}.png")