Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,37 +4,27 @@ import numpy as np
|
|
4 |
import modin.pandas as pd
|
5 |
from PIL import Image
|
6 |
from huggingface_hub import hf_hub_download
|
7 |
-
from diffusers import
|
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 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
decoder.enable_xformers_memory_efficient_attention()
|
17 |
-
decoder.enable_model_cpu_offload()
|
18 |
-
torch.cuda.empty_cache()
|
19 |
|
20 |
def genie (Prompt, negative_prompt, height, width, scale, steps, d_steps, seed):
|
21 |
generator = np.random.seed(0) if seed == 0 else torch.manual_seed(seed)
|
22 |
torch.cuda.empty_cache()
|
23 |
-
|
24 |
prompt=Prompt,
|
25 |
height=height,
|
26 |
width=width,
|
27 |
negative_prompt=negative_prompt,
|
28 |
guidance_scale=scale,
|
29 |
num_images_per_prompt=1,
|
30 |
-
num_inference_steps=steps)
|
31 |
-
image=decoder(
|
32 |
-
image_embeddings=prior_image.image_embeddings.to(torch.float16),
|
33 |
-
prompt=Prompt,
|
34 |
-
negative_prompt=negative_prompt,
|
35 |
-
guidance_scale=0.0,
|
36 |
-
output_type="pil",
|
37 |
-
num_inference_steps=d_steps).images[0]
|
38 |
return image
|
39 |
|
40 |
gr.Interface(fn=genie, inputs=[gr.Textbox(label='What you want the AI to generate. 77 Token Limit.'),
|
|
|
4 |
import modin.pandas as pd
|
5 |
from PIL import Image
|
6 |
from huggingface_hub import hf_hub_download
|
7 |
+
from diffusers import StableDiffusion3Pipeline
|
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 |
+
SD3 = StableCascadePriorPipeline.from_pretrained("stabilityai/stable-diffusion-3-medium-diffusers", torch_dtype=torch.float16)
|
13 |
+
SD3.enable_xformers_memory_efficient_attention()
|
14 |
+
SD3 = SD3.to(device)
|
15 |
+
|
|
|
|
|
|
|
16 |
|
17 |
def genie (Prompt, negative_prompt, height, width, scale, steps, d_steps, seed):
|
18 |
generator = np.random.seed(0) if seed == 0 else torch.manual_seed(seed)
|
19 |
torch.cuda.empty_cache()
|
20 |
+
image=SD3(
|
21 |
prompt=Prompt,
|
22 |
height=height,
|
23 |
width=width,
|
24 |
negative_prompt=negative_prompt,
|
25 |
guidance_scale=scale,
|
26 |
num_images_per_prompt=1,
|
27 |
+
num_inference_steps=steps).images[0]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
return image
|
29 |
|
30 |
gr.Interface(fn=genie, inputs=[gr.Textbox(label='What you want the AI to generate. 77 Token Limit.'),
|