File size: 2,351 Bytes
a10ba7f | 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 | import os
import glob
import re
def monitor_live():
# 1. Tìm file log mới nhất trong thư mục temp
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:
# Tìm participant hiện tại
if "Starting Training for Participant:" in line:
current_participant = line.split("Participant:")[1].strip()
# Tìm epoch hiện tại
if "Epoch " in line and ":" in line:
match = re.search(r'Epoch (\d+):', line)
if match:
current_epoch = match.group(1)
# Tìm kết quả tốt nhất đã lưu
if "New best model saved at epoch" in line:
# Format: New best model saved at epoch 41! (MAE: 4.5678)
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)
# Tính toán mức độ cải thiện nếu có MAE
if best_mae != "N/A":
# Giả sử baseline cũ của p00 là 4.8003
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()
|