Spaces:
Runtime error
Runtime error
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") | |