Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,13 +5,17 @@ import modin.pandas as pd
|
|
5 |
from PIL import Image
|
6 |
#from diffusers import DiffusionPipeline
|
7 |
from huggingface_hub import hf_hub_download
|
8 |
-
from diffusers import
|
9 |
|
10 |
device = 'cuda' #if torch.cuda.is_available() else 'cpu'
|
11 |
torch.cuda.max_memory_allocated(device=device)
|
12 |
torch.cuda.empty_cache()
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
15 |
#pipe = pipe.to(device)
|
16 |
torch.cuda.empty_cache()
|
17 |
|
@@ -20,13 +24,21 @@ def genie (Prompt, negative_prompt, height, width, scale, steps, seed, upscale):
|
|
20 |
generator = np.random.seed(0) if seed == 0 else torch.manual_seed(seed)
|
21 |
torch.cuda.empty_cache()
|
22 |
pipe.enable_model_cpu_offload()
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
prior_num_inference_steps=steps,
|
27 |
-
prior_guidance_scale=scale,
|
28 |
width=width,
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
#int_image = pipe(prompt=Prompt, negative_prompt=negative_prompt, num_inference_steps=steps, guidance_scale=scale, width=width, height=height, output_type="latent").images #
|
31 |
#torch.cuda.empty_cache()
|
32 |
#image = refiner(Prompt, negative_prompt=negative_prompt, image=int_image, denoising_start=.99).images[0]
|
|
|
5 |
from PIL import Image
|
6 |
#from diffusers import DiffusionPipeline
|
7 |
from huggingface_hub import hf_hub_download
|
8 |
+
from diffusers import StableCascadeDecoderPipeline, StableCascadePriorPipeline
|
9 |
|
10 |
device = 'cuda' #if torch.cuda.is_available() else 'cpu'
|
11 |
torch.cuda.max_memory_allocated(device=device)
|
12 |
torch.cuda.empty_cache()
|
13 |
+
prior = StableCascadePriorPipeline.from_pretrained("stabilityai/stable-cascade-prior", variant="bf16", torch_dtype=torch.bfloat16)
|
14 |
+
prior.enable_model_cpu_offload()
|
15 |
+
decoder = StableCascadeDecoderPipeline.from_pretrained("stabilityai/stable-cascade", variant="bf16", torch_dtype=torch.float16)
|
16 |
+
decoder = StableCascadeDecoderPipeline.from_pretrained("stabilityai/stable-cascade", variant="bf16", torch_dtype=torch.float16)
|
17 |
+
|
18 |
+
#pipe.enable_xformers_memory_efficient_attention()
|
19 |
#pipe = pipe.to(device)
|
20 |
torch.cuda.empty_cache()
|
21 |
|
|
|
24 |
generator = np.random.seed(0) if seed == 0 else torch.manual_seed(seed)
|
25 |
torch.cuda.empty_cache()
|
26 |
pipe.enable_model_cpu_offload()
|
27 |
+
prior_image=prior(
|
28 |
+
prompt=Prompt,
|
29 |
+
height=height,
|
|
|
|
|
30 |
width=width,
|
31 |
+
negative_prompt=negative_prompt,
|
32 |
+
guidance_scale=scale,
|
33 |
+
num_images_per_prompt=1,
|
34 |
+
num_inference_steps=steps)
|
35 |
+
image=decoder(
|
36 |
+
image_embeddings=prior_output.image_embeddings.to(torch.float16),
|
37 |
+
prompt=Prompt,
|
38 |
+
negative_prompt=negative_prompt,
|
39 |
+
guidance_scale=0.0,
|
40 |
+
output_type="pil",
|
41 |
+
num_inference_steps=10).images[0]
|
42 |
#int_image = pipe(prompt=Prompt, negative_prompt=negative_prompt, num_inference_steps=steps, guidance_scale=scale, width=width, height=height, output_type="latent").images #
|
43 |
#torch.cuda.empty_cache()
|
44 |
#image = refiner(Prompt, negative_prompt=negative_prompt, image=int_image, denoising_start=.99).images[0]
|