Download src/utils/live_monitor.py from thanhhuyvan/Gaze-LIPE: direct link, hf CLI and curl.
- Browser
- Download file 2.35 kB
-
https://huggingface.co/thanhhuyvan/Gaze-LIPE/resolve/main/src/utils/live_monitor.py
- Command line
-
hf download hf://thanhhuyvan/Gaze-LIPE/src/utils/live_monitor.py
-
curl -L -o live_monitor.py https://huggingface.co/thanhhuyvan/Gaze-LIPE/resolve/main/src/utils/live_monitor.py
2.35 kB
| 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() | |