Spaces:
Build error
Build error
Update generate.py
Browse files76 unmodified lines777879808081823 unmodified lines868788909192899091929798999394102959697981059910010110210311010410510610710876 unmodified lines faces = self.face_app.get(face) if faces: # Shape of normed_embedding is (512,). .unsqueeze(0) makes it (1, 512) faceid_embed = torch.from_numpy(faces[0].normed_embedding).unsqueeze(0) faceid_all_embeds.append(faceid_embed) except Exception as e:3 unmodified lines logger.error("No faces were detected in any of the provided images.") return None # Stack embeds into a single tensor and calculate the average # Shape of stacked tensor: (num_images, 1, 512) # Shape of average_embedding: (1, 512) average_embedding = torch.mean(torch.stack(faceid_all_embeds, dim=0), dim=0)
logger.info("Calling the generation pipeline...") try: # FIX: The pipeline expects a 3D or 4D tensor. # We add a "sequence length" dimension of 1. # Shape becomes: (1, 1, 512) final_embedding = average_embedding.unsqueeze(0)
image = self.pipe( # FIX: The pipeline returns an object, not a tuple. Access the .images attribute. pipeline_output = self.pipe( prompt=full_prompt, negative_prompt=negative_prompt, ip_adapter_image_embeds=[final_embedding], # Pass the correctly shaped tensor ip_adapter_image_embeds=[final_embedding], num_inference_steps=40, guidance_scale=7.5, width=512, height=768, ).images[0] ) image = pipeline_output.images[0]
# --- Save image locally first --- temp_dir = "temp_images"generate.py+5-10