Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,35 +1,21 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
import tensorflow as tf
|
4 |
-
import os
|
5 |
import torch
|
6 |
-
|
|
|
7 |
from torch import autocast
|
|
|
8 |
|
|
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
pipe.vae.enable_tiling()
|
14 |
-
|
15 |
-
prompt = "A train track with a sky background , realistic, highly detailed, high quality" #@param {type:"string"}
|
16 |
-
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"}
|
17 |
-
n_samples = 4 #@param {type:"number"}
|
18 |
-
scale = 7.5 #@param {type:"number"}
|
19 |
-
timesteps = 50
|
20 |
-
|
21 |
-
|
22 |
-
# Sometimes the nsfw checker is confused by the images, you can disable
|
23 |
-
# it at your own risk here
|
24 |
-
disable_safety = True
|
25 |
|
26 |
-
|
27 |
-
def null_safety(images, **kwargs):
|
28 |
-
return images, False
|
29 |
-
pipe.safety_checker = null_safety
|
30 |
|
31 |
-
|
32 |
-
|
|
|
33 |
|
34 |
-
|
35 |
-
im.save(f"{idx:06}.png")
|
|
|
1 |
+
import random
|
2 |
+
import re
|
|
|
|
|
3 |
import torch
|
4 |
+
import requests
|
5 |
+
from diffusers import StableDiffusionPipeline, EulerDiscreteScheduler
|
6 |
from torch import autocast
|
7 |
+
import gradio as gr
|
8 |
|
9 |
+
def txt2img(prompt):
|
10 |
|
11 |
+
image = pipe(prompt +",γrealistic, highly detailed, high quality", height=512, width=512, 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", guidance_scale = 7.5,num_inference_steps = 50).images[0]
|
12 |
+
|
13 |
+
image.save("sd_image.png")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
+
return image
|
|
|
|
|
|
|
16 |
|
17 |
+
pipe = StableDiffusionPipeline.from_pretrained("Fung804/makoto-shinkai-v2", torch_dtype=torch.float16)
|
18 |
+
pipe = pipe.to("cuda")
|
19 |
+
generate = gr.Interface(fn = txt2img, inputs="text",outputs="image",allow_flagging="never")
|
20 |
|
21 |
+
generate.launch()
|
|