| import os |
| import glob |
| import re |
|
|
| def monitor_live(): |
| |
| temp_dir = r'C:\Users\A\.gemini\tmp\gaze-estimation' |
| log_files = glob.glob(os.path.join(temp_dir, 'background_*.log')) |
| |
| if not log_files: |
| print("Không tìm thấy file log nào đang chạy.") |
| return |
|
|
| latest_log = max(log_files, key=os.path.getmtime) |
| print(f"Đang đọc log: {os.path.basename(latest_log)}") |
| print("-" * 50) |
|
|
| current_participant = "Unknown" |
| best_mae = "N/A" |
| best_epoch = "N/A" |
| current_epoch = "0" |
|
|
| with open(latest_log, 'r', encoding='utf-8', errors='ignore') as f: |
| lines = f.readlines() |
| |
| for line in lines: |
| |
| if "Starting Training for Participant:" in line: |
| current_participant = line.split("Participant:")[1].strip() |
| |
| |
| if "Epoch " in line and ":" in line: |
| match = re.search(r'Epoch (\d+):', line) |
| if match: |
| current_epoch = match.group(1) |
|
|
| |
| if "New best model saved at epoch" in line: |
| |
| try: |
| parts = line.split("epoch ")[1].split("!") |
| best_epoch = parts[0].strip() |
| best_mae = parts[1].split("MAE: ")[1].replace(")", "").strip() |
| except: |
| pass |
|
|
| print(f"Subject đang chạy: {current_participant}") |
| print(f"Epoch hiện tại: {current_epoch}") |
| print(f"--- KẾT QUẢ TỐT NHẤT TẠM THỜI ---") |
| print(f"MAE thấp nhất: {best_mae} (độ)") |
| print(f"Tại Epoch: {best_epoch}") |
| print("-" * 50) |
| |
| |
| if best_mae != "N/A": |
| |
| baseline = 4.8003 |
| improvement = baseline - float(best_mae) |
| if improvement > 0: |
| print(f"Đã cải thiện: +{improvement:.4f} độ so với Baseline") |
| else: |
| print(f"Trạng thái: Đang hội tụ...") |
|
|
| if __name__ == "__main__": |
| monitor_live() |
|
|