-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
108 lines (92 loc) · 3.82 KB
/
setup.py
File metadata and controls
108 lines (92 loc) · 3.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
"""
Setup and Installation Script
Automates the setup process for the Celebrity Look-Alike Finder
"""
import subprocess
import sys
import os
def print_header(text):
print("\n" + "="*70)
print(f" {text}")
print("="*70)
def run_command(command, description):
"""Run a command and handle errors"""
print(f"\n{description}...")
try:
subprocess.run(command, check=True, shell=True)
print(f"✓ {description} completed successfully!")
return True
except subprocess.CalledProcessError as e:
print(f"❌ Error: {description} failed!")
print(f"Error details: {e}")
return False
def main():
print("""
╔════════════════════════════════════════════════════════╗
║ 🎬 Celebrity Look-Alike Finder Setup 🎬 ║
╚════════════════════════════════════════════════════════╝
""")
# Step 1: Install dependencies
print_header("Step 1: Installing Dependencies")
if not run_command(
f"{sys.executable} -m pip install -r requirements.txt",
"Installing required Python packages"
):
print("\n⚠️ Please install dependencies manually:")
print(" pip install -r requirements.txt")
return
# Step 2: Check for celebrity images
print_header("Step 2: Checking Celebrity Images")
has_images = False
# Check new structure
if os.path.exists('celebrity_images') and os.listdir('celebrity_images'):
has_images = True
print("✓ Found celebrity images in celebrity_images/")
# Check old structure
if os.path.exists('Bollywood_celeb_face_localized'):
has_images = True
print("✓ Found celebrity images in Bollywood_celeb_face_localized/")
if not has_images:
print("\n⚠️ No celebrity images found!")
print("\nTo download images:")
print("1. Run: python download_celebrity_images.py")
print("2. Or manually download from Kaggle and place in celebrity_images/")
response = input("\nDo you want to run the download setup now? (y/n): ")
if response.lower() == 'y':
run_command(
f"{sys.executable} download_celebrity_images.py",
"Running image download setup"
)
# Step 3: Generate embeddings
print_header("Step 3: Generating Face Embeddings")
if os.path.exists('embedding.pkl') and os.path.exists('filenames.pkl'):
print("✓ Embeddings already exist!")
response = input("Do you want to regenerate embeddings? (y/n): ")
if response.lower() != 'y':
print("Skipping embedding generation...")
else:
run_command(
f"{sys.executable} extract_features.py",
"Extracting facial features"
)
else:
print("⚠️ Embeddings not found. Generating now...")
if has_images:
run_command(
f"{sys.executable} extract_features.py",
"Extracting facial features"
)
else:
print("❌ Cannot generate embeddings without celebrity images!")
return
# Step 4: Final checks
print_header("Setup Complete!")
if os.path.exists('embedding.pkl') and os.path.exists('filenames.pkl'):
print("\n✅ All set! You can now run the application:")
print("\n streamlit run celebrity_finder.py")
print("\nOr use the old app:")
print("\n streamlit run app.py")
else:
print("\n⚠️ Setup incomplete. Please check the errors above.")
if __name__ == '__main__':
main()