Spaces:
Build error
Build error
Update generate.py
Browse files123456789101112131473 unmodified lines8889909192939432 unmodified lines127128129130131132133134135136137138139140141142# generate.py# --- VERSION 7 ---print("--- RUNNING GENERATE.PY VERSION 7 (WITH TRACEBACK) ---")import torchimport cv2import osimport loggingimport uuidimport traceback # <-- ADDED FOR DETAILED ERROR LOGGINGfrom diffusers import StableDiffusionPipeline, DDIMScheduler, AutoencoderKLfrom diffusers.pipelines.stable_diffusion.pipeline_output import StableDiffusionPipelineOutputfrom transformers import CLIPVisionModelWithProjection73 unmodified lineslogger.info("Calling the generation pipeline...")try:final_embedding = average_embedding.unsqueeze(0)output = self.pipe(prompt=full_prompt,32 unmodified linesreturn public_urlexcept StorageException as e:logger.error(f"Supabase Storage Error: {e}")return Noneexcept Exception as e:# --- THIS IS THE IMPORTANT PART ---# It will print the full error details to the log.logger.error("An unexpected error occurred. Full traceback below:")traceback.print_exc()# ---logger.error(f"Error summary: {e}")if 'local_path' in locals() and os.path.exists(local_path):os.remove(local_path)123456789101112131473 unmodified lines88899091929394959697989910010132 unmodified lines134135136137138139140141142# generate.py# --- VERSION 8 (FINAL) ---print("--- RUNNING GENERATE.PY VERSION 8 (FINAL) ---")import torchimport cv2import osimport loggingimport uuidimport tracebackfrom diffusers import StableDiffusionPipeline, DDIMScheduler, AutoencoderKLfrom diffusers.pipelines.stable_diffusion.pipeline_output import StableDiffusionPipelineOutputfrom transformers import CLIPVisionModelWithProjection73 unmodified lineslogger.info("Calling the generation pipeline...")try:# --- FINAL FIX: Create negative embeddings ---# The IP-Adapter expects both positive and negative image embeddings.# We create a zeroed-out tensor for the negative part.positive_embedding = average_embedding.unsqueeze(0)negative_embedding = torch.zeros_like(positive_embedding)# Combine them for the pipelinefinal_embedding = torch.cat([negative_embedding, positive_embedding], dim=0)output = self.pipe(prompt=full_prompt,32 unmodified linesreturn public_urlexcept Exception as e:logger.error("An unexpected error occurred. Full traceback below:")traceback.print_exc()logger.error(f"Error summary: {e}")if 'local_path' in locals() and os.path.exists(local_path):os.remove(local_path)
generate.py+11-11