Julian Bilcke commited on
Commit ·
47564c9
1
Parent(s): 05b5081
fix lora detection issues
Browse filesFiles changed (2)
34 unmodified lines3536373839404142434445464748495051525354555634 unmodified linesdef find_latest_lora_weights(self) -> Optional[str]:"""Find the latest LoRA weights file"""try:lora_path = self.app.output_path / "pytorch_lora_weights.safetensors"if lora_path.exists():return str(lora_path)# If not found in the expected location, try to find in checkpointscheckpoints = list(self.app.output_path.glob("finetrainers_step_*"))has_checkpoints = len(checkpoints) > 0if not checkpoints:return Nonelatest_checkpoint = max(checkpoints, key=lambda x: int(x.name.split("_")[-1]))lora_path = latest_checkpoint / "pytorch_lora_weights.safetensors"if lora_path.exists():return str(lora_path)return Noneexcept Exception as e:34 unmodified lines353637383940414243444546474849505152535455565758596061626364656667686970717273747576777834 unmodified linesdef find_latest_lora_weights(self) -> Optional[str]:"""Find the latest LoRA weights file"""try:# Check if the root level file exists (this should be the primary location)lora_path = self.app.output_path / "pytorch_lora_weights.safetensors"if lora_path.exists():return str(lora_path)# Check in lora_weights directorylora_weights_dir = self.app.output_path / "lora_weights"if lora_weights_dir.exists():# Look for the latest checkpoint directory in lora_weightslora_checkpoints = [d for d in lora_weights_dir.glob("*") if d.is_dir() and d.name.isdigit()]if lora_checkpoints:latest_lora_checkpoint = max(lora_checkpoints, key=lambda x: int(x.name))# Check for weights in the latest LoRA checkpointpossible_weight_files = ["pytorch_lora_weights.safetensors","adapter_model.safetensors","pytorch_model.safetensors","model.safetensors"]for weight_file in possible_weight_files:weight_path = latest_lora_checkpoint / weight_fileif weight_path.exists():return str(weight_path)# Check if any .safetensors files existsafetensors_files = list(latest_lora_checkpoint.glob("*.safetensors"))if safetensors_files:return str(safetensors_files[0])# If not found in lora_weights, try to find in finetrainers checkpointscheckpoints = list(self.app.output_path.glob("finetrainers_step_*"))if checkpoints:latest_checkpoint = max(checkpoints, key=lambda x: int(x.name.split("_")[-1]))lora_path = latest_checkpoint / "pytorch_lora_weights.safetensors"if lora_path.exists():return str(lora_path)return Noneexcept Exception as e:
224 unmodified lines225226227228229230231232233234235236224 unmodified linesif lora_path.exists():return True# If not found in the expected location, try to find in checkpointscheckpoints = list(self.app.output_path.glob("finetrainers_step_*"))has_checkpoints = len(checkpoints) > 0if not checkpoints:return Falsefor checkpoint in checkpoints:lora_path = checkpoint / "pytorch_lora_weights.safetensors"if lora_path.exists():224 unmodified lines225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258224 unmodified linesif lora_path.exists():return True# Check in lora_weights directorylora_weights_dir = self.app.output_path / "lora_weights"if lora_weights_dir.exists():# Look for the latest checkpoint directory in lora_weightslora_checkpoints = [d for d in lora_weights_dir.glob("*") if d.is_dir() and d.name.isdigit()]if lora_checkpoints:latest_lora_checkpoint = max(lora_checkpoints, key=lambda x: int(x.name))# Check for weights in the latest LoRA checkpointpossible_weight_files = ["pytorch_lora_weights.safetensors","adapter_model.safetensors","pytorch_model.safetensors","model.safetensors"]for weight_file in possible_weight_files:weight_path = latest_lora_checkpoint / weight_fileif weight_path.exists():return True# Check if any .safetensors files existsafetensors_files = list(latest_lora_checkpoint.glob("*.safetensors"))if safetensors_files:return True# If not found in lora_weights, try to find in finetrainers checkpointscheckpoints = list(self.app.output_path.glob("finetrainers_step_*"))for checkpoint in checkpoints:lora_path = checkpoint / "pytorch_lora_weights.safetensors"if lora_path.exists():
vms/ui/project/services/previewing.py+33-11
vms/ui/project/tabs/preview_tab.py+27-5