Spaces:
Running
on
A10G
Running
on
A10G
Update app.py
Browse filesRetesting Cascade
app.py
CHANGED
@@ -3,28 +3,36 @@ import torch
|
|
3 |
import numpy as np
|
4 |
import modin.pandas as pd
|
5 |
from PIL import Image
|
6 |
-
from diffusers import DiffusionPipeline
|
7 |
from huggingface_hub import hf_hub_download
|
8 |
|
|
|
|
|
|
|
9 |
device = 'cuda' #if torch.cuda.is_available() else 'cpu'
|
10 |
torch.cuda.max_memory_allocated(device=device)
|
11 |
torch.cuda.empty_cache()
|
12 |
-
pipe =
|
|
|
13 |
pipe.enable_xformers_memory_efficient_attention()
|
14 |
pipe = pipe.to(device)
|
15 |
torch.cuda.empty_cache()
|
16 |
|
17 |
-
|
18 |
-
refiner.enable_xformers_memory_efficient_attention()
|
19 |
-
refiner = refiner.to(device)
|
20 |
-
torch.cuda.empty_cache()
|
21 |
-
|
22 |
def genie (Prompt, negative_prompt, height, width, scale, steps, seed, upscale):
|
23 |
generator = np.random.seed(0) if seed == 0 else torch.manual_seed(seed)
|
24 |
torch.cuda.empty_cache()
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
torch.cuda.empty_cache()
|
29 |
return image
|
30 |
|
@@ -32,7 +40,7 @@ gr.Interface(fn=genie, inputs=[gr.Textbox(label='What you want the AI to generat
|
|
32 |
gr.Textbox(label='What you Do Not want the AI to generate. 77 Token Limit'),
|
33 |
gr.Slider(512, 1408, 1024, step=128, label='Height'),
|
34 |
gr.Slider(512, 1408, 1024, step=128, label='Width'),
|
35 |
-
gr.Slider(
|
36 |
gr.Slider(10, maximum=50, value=25, step=5, label='Number of Iterations'),
|
37 |
gr.Slider(minimum=0, step=1, maximum=9999999999999999, randomize=True, label='Seed: 0 is Random')],
|
38 |
outputs=gr.Image(label='Generated Image'),
|
|
|
3 |
import numpy as np
|
4 |
import modin.pandas as pd
|
5 |
from PIL import Image
|
6 |
+
#from diffusers import DiffusionPipeline
|
7 |
from huggingface_hub import hf_hub_download
|
8 |
|
9 |
+
from diffusers import StableCascadeCombinedPipeline
|
10 |
+
|
11 |
+
|
12 |
device = 'cuda' #if torch.cuda.is_available() else 'cpu'
|
13 |
torch.cuda.max_memory_allocated(device=device)
|
14 |
torch.cuda.empty_cache()
|
15 |
+
pipe = StableCascadeCombinedPipeline.from_pretrained("stabilityai/stable-cascade", variant="bf16", torch_dtype=torch.bfloat16)
|
16 |
+
|
17 |
pipe.enable_xformers_memory_efficient_attention()
|
18 |
pipe = pipe.to(device)
|
19 |
torch.cuda.empty_cache()
|
20 |
|
21 |
+
|
|
|
|
|
|
|
|
|
22 |
def genie (Prompt, negative_prompt, height, width, scale, steps, seed, upscale):
|
23 |
generator = np.random.seed(0) if seed == 0 else torch.manual_seed(seed)
|
24 |
torch.cuda.empty_cache()
|
25 |
+
image=pipe(prompt=Prompt,
|
26 |
+
negative_prompt="",
|
27 |
+
num_inference_steps=20,
|
28 |
+
prior_num_inference_steps=steps,
|
29 |
+
prior_guidance_scale=scale,
|
30 |
+
width=width,
|
31 |
+
height=height,).images[0]
|
32 |
+
|
33 |
+
#int_image = pipe(prompt=Prompt, negative_prompt=negative_prompt, num_inference_steps=steps, guidance_scale=scale, width=width, height=height, output_type="latent").images #
|
34 |
+
#torch.cuda.empty_cache()
|
35 |
+
#image = refiner(Prompt, negative_prompt=negative_prompt, image=int_image, denoising_start=.99).images[0]
|
36 |
torch.cuda.empty_cache()
|
37 |
return image
|
38 |
|
|
|
40 |
gr.Textbox(label='What you Do Not want the AI to generate. 77 Token Limit'),
|
41 |
gr.Slider(512, 1408, 1024, step=128, label='Height'),
|
42 |
gr.Slider(512, 1408, 1024, step=128, label='Width'),
|
43 |
+
gr.Slider(.5, maximum=15, value=3, step=.25, label='Guidance Scale'),
|
44 |
gr.Slider(10, maximum=50, value=25, step=5, label='Number of Iterations'),
|
45 |
gr.Slider(minimum=0, step=1, maximum=9999999999999999, randomize=True, label='Seed: 0 is Random')],
|
46 |
outputs=gr.Image(label='Generated Image'),
|