""" Setup script for FaceSwap AI Wig Try-On Project Ensures all models and dependencies are properly configured """ import os import sys from pathlib import Path def check_models(): """Check if all required models are accessible""" print("šŸ” Checking AI models...") models_status = {} # Check face detection model try: from detect_face import predict, _MODEL if _MODEL is not None: models_status['face_detection'] = "āœ… Ready" else: models_status['face_detection'] = "āŒ Failed to load" except Exception as e: models_status['face_detection'] = f"āŒ Error: {e}" # Check segmentation model try: from segmentation import processor, model models_status['segmentation'] = "āœ… Ready" except Exception as e: models_status['segmentation'] = f"āŒ Error: {e}" # Check baldhead model try: from baldhead import GENERATOR if GENERATOR is not None: models_status['baldhead'] = "āœ… Ready" else: models_status['baldhead'] = "āš ļø Model not loaded (may download on first use)" except Exception as e: models_status['baldhead'] = f"āŒ Error: {e}" # Check roop face swap try: import roop.core models_status['face_swap'] = "āœ… Ready" except Exception as e: models_status['face_swap'] = f"āŒ Error: {e}" return models_status def check_directories(): """Ensure required directories exist""" print("šŸ“ Checking directories...") required_dirs = [ "example_wigs/Heart", "example_wigs/Oblong", "example_wigs/Oval", "example_wigs/Round", "example_wigs/Square", "models", "temp" ] for dir_path in required_dirs: Path(dir_path).mkdir(parents=True, exist_ok=True) print(f" āœ… {dir_path}") def check_wig_samples(): """Check if wig samples exist""" print("šŸŽ­ Checking wig samples...") wig_count = {} for shape in ["Heart", "Oblong", "Oval", "Round", "Square"]: shape_dir = Path(f"example_wigs/{shape}") if shape_dir.exists(): wigs = list(shape_dir.glob("*.png")) + list(shape_dir.glob("*.jpg")) wig_count[shape] = len(wigs) print(f" {shape}: {len(wigs)} wigs") else: wig_count[shape] = 0 print(f" {shape}: 0 wigs āŒ") return wig_count def main(): """Main setup check""" print("šŸš€ FaceSwap AI Wig Try-On - Setup Check") print("=" * 50) # Check directories check_directories() print() # Check wig samples wig_count = check_wig_samples() print() # Check models models_status = check_models() print() # Summary print("šŸ“Š SETUP SUMMARY:") print("-" * 30) print("šŸ¤– AI Models:") for model_name, status in models_status.items(): print(f" {model_name}: {status}") print(f"\nšŸŽ­ Wig Samples: {sum(wig_count.values())} total") for shape, count in wig_count.items(): print(f" {shape}: {count}") # Check if ready to run critical_models = ['face_detection', 'segmentation', 'face_swap'] ready = all("āœ…" in models_status.get(model, "") for model in critical_models) if ready and sum(wig_count.values()) > 0: print("\nšŸŽ‰ Project is ready to run!") print(" Run: python app.py") else: print("\nāš ļø Some components need attention:") if not ready: print(" - AI models need fixing") if sum(wig_count.values()) == 0: print(" - Add wig samples to example_wigs/ folders") if __name__ == "__main__": main()