74 lines
2.2 KiB
Python
74 lines
2.2 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
TensorBoard Launch Script
|
|
|
|
Starts TensorBoard server for monitoring training progress.
|
|
"""
|
|
|
|
import subprocess
|
|
import sys
|
|
import os
|
|
import time
|
|
import webbrowser
|
|
from pathlib import Path
|
|
|
|
def main():
|
|
"""Launch TensorBoard"""
|
|
|
|
# Check if runs directory exists
|
|
runs_dir = Path("runs")
|
|
if not runs_dir.exists():
|
|
print("❌ No 'runs' directory found.")
|
|
print(" Start training first to generate TensorBoard logs.")
|
|
return
|
|
|
|
# Check if there are any log directories
|
|
log_dirs = list(runs_dir.glob("*"))
|
|
if not log_dirs:
|
|
print("❌ No training logs found in 'runs' directory.")
|
|
print(" Start training first to generate TensorBoard logs.")
|
|
return
|
|
|
|
print("🚀 Starting TensorBoard...")
|
|
print(f"📁 Log directory: {runs_dir.absolute()}")
|
|
print(f"📊 Found {len(log_dirs)} training sessions")
|
|
|
|
# List available sessions
|
|
print("\nAvailable training sessions:")
|
|
for i, log_dir in enumerate(sorted(log_dirs), 1):
|
|
print(f" {i}. {log_dir.name}")
|
|
|
|
# Start TensorBoard
|
|
try:
|
|
port = 6006
|
|
print(f"\n🌐 Starting TensorBoard on port {port}...")
|
|
print(f"🔗 Access at: http://localhost:{port}")
|
|
|
|
# Try to open browser automatically
|
|
try:
|
|
webbrowser.open(f"http://localhost:{port}")
|
|
print("🌍 Browser opened automatically")
|
|
except:
|
|
pass
|
|
|
|
# Start TensorBoard process
|
|
cmd = [sys.executable, "-m", "tensorboard.main", "--logdir", str(runs_dir), "--port", str(port)]
|
|
|
|
print("\n" + "="*50)
|
|
print("🔥 TensorBoard is running!")
|
|
print(f"📈 View training metrics at: http://localhost:{port}")
|
|
print("⏹️ Press Ctrl+C to stop TensorBoard")
|
|
print("="*50 + "\n")
|
|
|
|
# Run TensorBoard
|
|
subprocess.run(cmd)
|
|
|
|
except KeyboardInterrupt:
|
|
print("\n🛑 TensorBoard stopped")
|
|
except FileNotFoundError:
|
|
print("❌ TensorBoard not found. Install with: pip install tensorboard")
|
|
except Exception as e:
|
|
print(f"❌ Error starting TensorBoard: {e}")
|
|
|
|
if __name__ == "__main__":
|
|
main() |