multimodalart HF staff commited on
Commit
ad7df92
1 Parent(s): 399fa48

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -8
app.py CHANGED
@@ -33,18 +33,15 @@ pipe = StableDiffusionPipeline.from_pretrained(
33
 
34
  ip_model = IPAdapterFaceID(pipe, ip_ckpt, device)
35
 
36
- def generate_faceid_embeddings(image):
37
- #image = cv2.imread("person.jpg")
38
- faces = app.get(image)
39
- faceid_embeds = torch.from_numpy(faces[0].normed_embedding).unsqueeze(0)
40
- return faceid_embeds
41
-
42
  @spaces.GPU
43
  def generate_image(image, prompt, negative_prompt):
 
 
44
  app = FaceAnalysis(name="buffalo_l", providers=['CUDAExecutionProvider', 'CPUExecutionProvider'])
45
  app.prepare(ctx_id=0, det_size=(640, 640))
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
50
  )
 
33
 
34
  ip_model = IPAdapterFaceID(pipe, ip_ckpt, device)
35
 
 
 
 
 
 
 
36
  @spaces.GPU
37
  def generate_image(image, prompt, negative_prompt):
38
+ pipe.to(device)
39
+
40
  app = FaceAnalysis(name="buffalo_l", providers=['CUDAExecutionProvider', 'CPUExecutionProvider'])
41
  app.prepare(ctx_id=0, det_size=(640, 640))
42
+ faces = app.get(image)
43
+ faceid_embeds = torch.from_numpy(faces[0].normed_embedding).unsqueeze(0)
44
+
45
  images = ip_model.generate(
46
  prompt=prompt, negative_prompt=negative_prompt, faceid_embeds=faceid_embeds, width=512, height=512, num_inference_steps=30
47
  )