Spaces:
Running
on
Zero
Running
on
Zero
Commit
•
a2bce81
1
Parent(s):
bff574e
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ from diffusers import StableDiffusionPipeline, DDIMScheduler, AutoencoderKL
|
|
3 |
from ip_adapter.ip_adapter_faceid import IPAdapterFaceID
|
4 |
from huggingface_hub import hf_hub_download
|
5 |
from insightface.app import FaceAnalysis
|
|
|
6 |
|
7 |
app = FaceAnalysis(name="buffalo_l", providers=['CUDAExecutionProvider', 'CPUExecutionProvider'])
|
8 |
app.prepare(ctx_id=0, det_size=(640, 640))
|
@@ -40,7 +41,9 @@ def generate_faceid_embeddings(image):
|
|
40 |
faceid_embeds = torch.from_numpy(faces[0].normed_embedding).unsqueeze(0)
|
41 |
return faceid_embeds
|
42 |
|
|
|
43 |
def generate_image(image, prompt, negative_prompt):
|
|
|
44 |
faceid_embeds = generate_faceid_embeddings(image)
|
45 |
images = ip_model.generate(
|
46 |
prompt=prompt, negative_prompt=negative_prompt, faceid_embeds=faceid_embeds, width=512, height=512, num_inference_steps=30
|
|
|
3 |
from ip_adapter.ip_adapter_faceid import IPAdapterFaceID
|
4 |
from huggingface_hub import hf_hub_download
|
5 |
from insightface.app import FaceAnalysis
|
6 |
+
import spaces
|
7 |
|
8 |
app = FaceAnalysis(name="buffalo_l", providers=['CUDAExecutionProvider', 'CPUExecutionProvider'])
|
9 |
app.prepare(ctx_id=0, det_size=(640, 640))
|
|
|
41 |
faceid_embeds = torch.from_numpy(faces[0].normed_embedding).unsqueeze(0)
|
42 |
return faceid_embeds
|
43 |
|
44 |
+
@spaces.GPU
|
45 |
def generate_image(image, prompt, negative_prompt):
|
46 |
+
pipe.to(device)
|
47 |
faceid_embeds = generate_faceid_embeddings(image)
|
48 |
images = ip_model.generate(
|
49 |
prompt=prompt, negative_prompt=negative_prompt, faceid_embeds=faceid_embeds, width=512, height=512, num_inference_steps=30
|