punimtag/scripts/start_gui.py
2025-08-15 00:57:39 -08:00

224 lines
7.0 KiB
Python

#!/usr/bin/env python3
"""
PunimTag GUI Starter
Simple script to demonstrate the system and guide next steps
"""
import os
import subprocess
import sys
def check_requirements():
"""Check if all requirements are met"""
print("🔍 Checking requirements...")
# Check if photos directory exists
if not os.path.exists('photos'):
print("❌ Photos directory not found")
print(" Creating photos/ directory...")
os.makedirs('photos', exist_ok=True)
print(" ✅ Created photos/ directory")
else:
print("✅ Photos directory exists")
# Check if database exists
if os.path.exists('punimtag_simple.db'):
print("✅ Database exists")
# Get basic stats
try:
import sqlite3
conn = sqlite3.connect('punimtag_simple.db')
c = conn.cursor()
c.execute("SELECT COUNT(*) FROM images")
image_count = c.fetchone()[0]
c.execute("SELECT COUNT(*) FROM faces")
face_count = c.fetchone()[0]
c.execute("SELECT COUNT(*) FROM faces WHERE person_id IS NULL")
unidentified_count = c.fetchone()[0]
conn.close()
print(f" 📊 {image_count} images, {face_count} faces, {unidentified_count} unidentified")
return image_count, face_count, unidentified_count
except Exception as e:
print(f" ⚠️ Error reading database: {e}")
return 0, 0, 0
else:
print("❌ Database not found")
print(" Run 'python punimtag_simple.py' first to process images")
return 0, 0, 0
def show_menu(image_count, face_count, unidentified_count):
"""Show main menu"""
print("\n" + "="*60)
print("🏷️ PUNIMTAG - NEXT STEPS")
print("="*60)
if image_count == 0:
print("📝 GETTING STARTED:")
print(" 1. Add photos to the 'photos/' directory")
print(" 2. Run: python punimtag_simple.py")
print(" 3. Come back here for face identification")
print("\n💡 TIP: Start with 10-20 photos for testing")
return
print(f"📊 CURRENT STATUS:")
print(f" Images processed: {image_count}")
print(f" Faces detected: {face_count}")
print(f" Unidentified faces: {unidentified_count}")
print(f"\n🎯 AVAILABLE ACTIONS:")
print(f" 1. Process more images")
print(f" 2. Identify unknown faces (CLI)")
print(f" 3. Manage database")
print(f" 4. View statistics")
if unidentified_count > 0:
print(f" 5. Start simple web interface (coming soon)")
print(f" 6. Exit")
def process_images():
"""Process images"""
print("\n📷 Processing images...")
try:
result = subprocess.run([sys.executable, 'punimtag_simple.py'],
capture_output=True, text=True)
print(result.stdout)
if result.stderr:
print("Errors:", result.stderr)
except Exception as e:
print(f"Error: {e}")
def identify_faces():
"""Identify faces using CLI tool"""
print("\n👥 Starting face identification...")
try:
subprocess.run([sys.executable, 'interactive_identifier.py'])
except Exception as e:
print(f"Error: {e}")
def manage_database():
"""Manage database"""
print("\n🗄️ Starting database manager...")
try:
subprocess.run([sys.executable, 'db_manager.py'])
except Exception as e:
print(f"Error: {e}")
def show_statistics():
"""Show detailed statistics"""
print("\n📊 DETAILED STATISTICS")
print("="*40)
try:
from db_manager import DatabaseManager
manager = DatabaseManager('punimtag_simple.db')
manager.inspect_database()
except Exception as e:
print(f"Error: {e}")
def show_next_gui_steps():
"""Show what's coming next for GUI development"""
print("\n🚀 NEXT GUI DEVELOPMENT STEPS")
print("="*50)
print("We have a working backend! Next steps for GUI:")
print()
print("✅ COMPLETED:")
print(" • Face recognition and clustering")
print(" • Database management")
print(" • Jewish organization features")
print(" • Search functionality")
print(" • CLI tools for identification")
print()
print("🔄 IN PROGRESS:")
print(" • Web-based GUI with Flask")
print(" • Face clustering visualization")
print(" • Interactive face identification")
print()
print("📋 PLANNED:")
print(" • Advanced search interface")
print(" • Tag management GUI")
print(" • Statistics dashboard")
print(" • Photo gallery with face highlights")
print()
print("💡 TO TEST THE WEB GUI:")
print(" 1. Make sure you have processed some images")
print(" 2. Run: python web_gui.py (when ready)")
print(" 3. Open http://localhost:5000 in browser")
def main():
"""Main function"""
print("🏷️ PunimTag GUI Starter")
print("Welcome to the face recognition and photo tagging system!")
# Check requirements
image_count, face_count, unidentified_count = check_requirements()
while True:
show_menu(image_count, face_count, unidentified_count)
try:
choice = input(f"\n➤ Select option: ").strip()
if choice == '1':
process_images()
# Refresh stats
image_count, face_count, unidentified_count = check_requirements()
elif choice == '2':
if face_count == 0:
print("❌ No faces to identify. Process images first.")
else:
identify_faces()
# Refresh stats
image_count, face_count, unidentified_count = check_requirements()
elif choice == '3':
manage_database()
# Refresh stats
image_count, face_count, unidentified_count = check_requirements()
elif choice == '4':
show_statistics()
elif choice == '5':
if unidentified_count > 0:
print("🌐 Web interface is in development!")
print("For now, use option 2 for CLI identification.")
else:
print("✅ All faces are identified!")
elif choice == '6':
break
else:
print("❌ Invalid option")
input("\nPress Enter to continue...")
except KeyboardInterrupt:
print("\n\n👋 Goodbye!")
break
except Exception as e:
print(f"Error: {e}")
input("Press Enter to continue...")
print("\n🎉 Thank you for using PunimTag!")
show_next_gui_steps()
if __name__ == "__main__":
main()