Main function
()
| 418 | |
| 419 | |
| 420 | def main(): |
| 421 | """Main function""" |
| 422 | args = parse_args() |
| 423 | |
| 424 | print("=" * 50) |
| 425 | print("LoRA Extractor Started") |
| 426 | print("=" * 50) |
| 427 | print(f"Source model: {args.source_model} ({args.source_type})") |
| 428 | print(f"Target model: {args.target_model} ({args.target_type})") |
| 429 | print(f"Output path: {args.output} ({args.output_format})") |
| 430 | print(f"Output data type: {args.output_dtype}") |
| 431 | print(f"LoRA parameters: rank={args.rank}") |
| 432 | print(f"Diff only mode: {args.diff_only}") |
| 433 | print("=" * 50) |
| 434 | |
| 435 | try: |
| 436 | # Load source and target models |
| 437 | source_weights = load_model_weights(args.source_model, args.source_type) |
| 438 | target_weights = load_model_weights(args.target_model, args.target_type) |
| 439 | |
| 440 | # Extract LoRA weights |
| 441 | lora_weights = extract_lora_from_diff(source_weights, target_weights, rank=args.rank, diff_only=args.diff_only) |
| 442 | |
| 443 | # Save LoRA weights |
| 444 | save_lora_weights(lora_weights, args.output, args.output_format, args.output_dtype) |
| 445 | |
| 446 | print("=" * 50) |
| 447 | print("LoRA extraction completed!") |
| 448 | print("=" * 50) |
| 449 | |
| 450 | except Exception as e: |
| 451 | print(f"Error: {e}") |
| 452 | raise |
| 453 | |
| 454 | |
| 455 | if __name__ == "__main__": |
no test coverage detected