ehristoforu commited on
Commit
fafd12c
1 Parent(s): 794e5dc

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -0
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import gradio as gr
3
+ from PIL import image
4
+ import spaces
5
+ from diffusers import StableCascadeDecoderPipeline, StableCascadePriorPipeline
6
+
7
+ device = "cuda"
8
+ num_images_per_prompt = 1
9
+
10
+ prior = StableCascadePriorPipeline.from_pretrained("stabilityai/stable-cascade-prior", torch_dtype=torch.bfloat16).to(device)
11
+ decoder = StableCascadeDecoderPipeline.from_pretrained("stabilityai/stable-cascade", torch_dtype=torch.float16).to(device)
12
+
13
+ prompt = "Anthropomorphic cat dressed as a pilot"
14
+ negative_prompt = ""
15
+
16
+ @spaces.GPU
17
+ def gen(prompt, negative, width, height):
18
+ prior_output = prior(
19
+ prompt=prompt,
20
+ height=height,
21
+ width=width,
22
+ negative_prompt=negative,
23
+ guidance_scale=4.0,
24
+ num_images_per_prompt=num_images_per_prompt,
25
+ num_inference_steps=20
26
+ )
27
+ decoder_output = decoder(
28
+ image_embeddings=prior_output.image_embeddings.half(),
29
+ prompt=prompt,
30
+ negative_prompt=negative,
31
+ guidance_scale=0.0,
32
+ output_type="pil",
33
+ num_inference_steps=10
34
+ ).images
35
+ return decoder_output
36
+
37
+ i