Spaces:
Running
on
A10G
Running
on
A10G
Commit
·
d78324f
1
Parent(s):
1c90643
Update app.py
Browse files
app.py
CHANGED
@@ -117,27 +117,10 @@ pipe.to(device=DEVICE)
|
|
117 |
pipe.unet = torch.compile(pipe.unet)
|
118 |
pipe.vae = torch.compile(pipe.vae)
|
119 |
|
120 |
-
|
121 |
-
im_embs = torch.zeros(1, 1, 1, 1280, device=DEVICE, dtype=dtype)
|
122 |
-
output = pipe(prompt='a person', guidance_scale=0, added_cond_kwargs={}, ip_adapter_image_embeds=[im_embs], num_inference_steps=STEPS)
|
123 |
-
leave_im_emb, _ = pipe.encode_image(
|
124 |
-
output.frames[0][len(output.frames[0])//2], DEVICE, 1, output_hidden_state
|
125 |
-
)
|
126 |
-
assert len(output.frames[0]) == 16
|
127 |
-
|
128 |
-
im_embs = torch.zeros(1, 1, 1, 1280, device=DEVICE, dtype=dtype)
|
129 |
-
output = pipe(prompt='a person', guidance_scale=0, added_cond_kwargs={}, ip_adapter_image_embeds=[im_embs], num_inference_steps=STEPS)
|
130 |
-
leave_im_emb, _ = pipe.encode_image(
|
131 |
-
output.frames[0][len(output.frames[0])//2], DEVICE, 1, output_hidden_state
|
132 |
-
)
|
133 |
-
|
134 |
-
#leave_im_emb.detach().to('cpu')
|
135 |
-
|
136 |
@spaces.GPU(duration=20)
|
137 |
def generate_gpu(in_im_embs):
|
138 |
print('start gen')
|
139 |
in_im_embs = in_im_embs.to('cuda').unsqueeze(0).unsqueeze(0)
|
140 |
-
#im_embs = torch.cat((torch.zeros(1, 1280, device=DEVICE, dtype=dtype), in_im_embs), 0)
|
141 |
|
142 |
output = pipe(prompt='a scene', guidance_scale=0, added_cond_kwargs={}, ip_adapter_image_embeds=[in_im_embs], num_inference_steps=STEPS)
|
143 |
print('image is made')
|
@@ -148,6 +131,10 @@ def generate_gpu(in_im_embs):
|
|
148 |
im_emb = im_emb.detach().to('cpu').to(torch.float32)
|
149 |
return output, im_emb
|
150 |
|
|
|
|
|
|
|
|
|
151 |
def generate(in_im_embs):
|
152 |
|
153 |
output, im_emb = generate_gpu(in_im_embs)
|
|
|
117 |
pipe.unet = torch.compile(pipe.unet)
|
118 |
pipe.vae = torch.compile(pipe.vae)
|
119 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
@spaces.GPU(duration=20)
|
121 |
def generate_gpu(in_im_embs):
|
122 |
print('start gen')
|
123 |
in_im_embs = in_im_embs.to('cuda').unsqueeze(0).unsqueeze(0)
|
|
|
124 |
|
125 |
output = pipe(prompt='a scene', guidance_scale=0, added_cond_kwargs={}, ip_adapter_image_embeds=[in_im_embs], num_inference_steps=STEPS)
|
126 |
print('image is made')
|
|
|
131 |
im_emb = im_emb.detach().to('cpu').to(torch.float32)
|
132 |
return output, im_emb
|
133 |
|
134 |
+
im_embs = torch.zeros(1, 1, 1, 1280, device=DEVICE, dtype=dtype)
|
135 |
+
generate_gpu(im_embs)
|
136 |
+
generate_gpu(im_embs)
|
137 |
+
|
138 |
def generate(in_im_embs):
|
139 |
|
140 |
output, im_emb = generate_gpu(in_im_embs)
|