Files
remote-sensing/NEW_FEATURES.md
T
2026-03-07 17:13:59 +07:00

6.2 KiB

🎉 Chức năng mới đã được phục hồi

📊 1. Dashboard Tổng Quan & Visualization

Dashboard cung cấp giao diện trực quan để theo dõi hiệu suất hệ thống.

Truy cập Dashboard

http://localhost:8000/dashboard

Tính năng

  • 📈 Tổng Quan: Hiển thị thống kê tổng hợp

    • Số models đã train
    • Số predictions đã tạo
    • Số reports đã generate
    • Accuracy của model mới nhất
  • 📊 Accuracy Trends: Biểu đồ theo dõi accuracy qua thời gian

    • Line chart: Accuracy, Precision, Recall
    • Bar chart: F1-Score comparison
    • Export PNG/PDF
  • 📊 Class Distribution: Phân bố các lớp đất

    • Bar chart: Số lượng mẫu mỗi lớp
    • Chọn model để xem
    • Export PNG/PDF

API Endpoints

# Lấy accuracy trends
GET /api/dashboard/accuracy-trends

# Lấy thống kê tổng quan
GET /api/dashboard/statistics

# Lấy phân bố lớp của model
GET /api/dashboard/class-distribution/{model_filename}

Export Charts

  • PNG: Click nút "💾 Export PNG"
  • PDF: Click nút "📄 Export PDF"

📝 2. Auto Report Generator

Report tự động được tạo sau khi training và prediction hoàn thành.

Reports đã có

  • Training Report: Tự động tạo sau khi train xong

    • Metrics, confusion matrix, class distribution
    • Lưu trong folder reports/
  • Prediction Report: Tự động tạo sau khi predict xong

    • Thông tin về output file, bbox, features
    • Lưu trong folder reports/

API Endpoints

# Liệt kê reports
GET /api/reports/list

# Xem report
GET /api/reports/view/{filename}

# Download report
GET /api/reports/download/{filename}

Xem Reports


🔄 3. Batch Processing

Predict nhiều khu vực cùng lúc với queue management.

Cách sử dụng

Bước 1: Tạo CSV file

Tạo file CSV với format:

name,min_lon,min_lat,max_lon,max_lat,start_date,end_date,max_scenes,cloud_cover,resolution
Region_1,105.6,9.3,105.8,9.5,2023-03-01,2023-05-31,12,30,20
Region_2,105.8,9.3,106.0,9.5,2023-03-01,2023-05-31,12,30,20

File mẫu: batch_regions_example.csv

Bước 2: Upload và Start Batch

  1. Truy cập: http://localhost:8000/dashboard
  2. Chọn tab "🔄 Batch Processing"
  3. Upload CSV file
  4. Chọn model để predict
  5. Click "🚀 Start Batch Prediction"

Bước 3: Theo dõi Progress

Dashboard sẽ tự động refresh mỗi 3 giây và hiển thị:

  • Queued: Đang chờ
  • ▶️ Running: Đang chạy
  • Completed: Hoàn thành
  • Failed: Lỗi

API Endpoints

# Bắt đầu batch prediction
POST /api/batch/start
{
    "model_filename": "model_20231221.joblib",
    "items": [
        {
            "name": "Region_1",
            "min_lon": 105.6,
            "min_lat": 9.3,
            "max_lon": 105.8,
            "max_lat": 9.5,
            "start_date": "2023-03-01",
            "end_date": "2023-05-31",
            "max_scenes": 12,
            "cloud_cover": 30,
            "resolution": 20
        }
    ],
    "auto_retry": true,
    "max_retries": 3
}

# Kiểm tra queue status
GET /api/batch/status

# Lấy kết quả batch
GET /api/batch/results/{batch_id}

# Hủy batch
POST /api/batch/cancel/{batch_id}

Auto-Retry

  • Tự động retry khi failed (default: max 3 lần)
  • Có thể tắt bằng cách set auto_retry: false

Progress Tracking

  • Mỗi job có progress bar riêng
  • Real-time update status
  • Hiển thị error message nếu failed

🚀 Khởi động Server

# Activate môi trường
conda activate env_01

# Chạy API server
python api_server.py

Server sẽ chạy tại: http://localhost:8000

📍 Các URL quan trọng


🔧 Cấu trúc Folders

remote-sensing/
├── api_server.py              # API server với các chức năng mới
├── dashboard.html             # Dashboard UI (MỚI)
├── training_interface.html    # Training UI
├── report_generator.py        # Auto report generator
├── batch_regions_example.csv  # CSV mẫu cho batch (MỚI)
├── model_train/               # Models đã train
├── predictions/               # Prediction outputs
└── reports/                   # Auto-generated reports

🎯 Use Cases

Use Case 1: Theo dõi Model Performance

  1. Train nhiều models với configs khác nhau
  2. Mở Dashboard → Tab "📊 Accuracy Trends"
  3. So sánh accuracy/F1-score qua thời gian
  4. Export charts để báo cáo

Use Case 2: Batch Prediction cho nhiều khu vực

  1. Chuẩn bị CSV với danh sách khu vực
  2. Upload vào Dashboard → Tab "🔄 Batch Processing"
  3. Chọn model tốt nhất
  4. Start batch và theo dõi progress
  5. Download results khi hoàn thành

Use Case 3: Tạo Reports tự động

  1. Chạy training/prediction
  2. Report tự động được tạo
  3. Xem qua Dashboard hoặc /api/reports/list
  4. Download để chia sẻ

⚠️ Lưu ý

  1. Batch Processing: Hiện tại chỉ xử lý tuần tự (từng job một)
  2. Auto-retry: Chỉ retry khi lỗi kỹ thuật, không retry nếu config sai
  3. Charts Export: Cần browser hỗ trợ Canvas API
  4. Memory: Batch lớn có thể tốn RAM, nên chia nhỏ

🐛 Troubleshooting

Dashboard không hiển thị data

  • Kiểm tra có models/predictions trong folders chưa
  • Refresh lại trang
  • Check console log (F12)

Batch processing không chạy

  • Kiểm tra format CSV đúng chưa
  • Kiểm tra model đã chọn có tồn tại không
  • Xem API logs để debug

Charts không export được

  • Browser phải hỗ trợ Canvas.toDataURL()
  • Thử browser khác (Chrome/Firefox)

📞 Support

Nếu gặp vấn đề, check:

  1. API logs: python api_server.py
  2. Browser console: F12 → Console
  3. Network tab: F12 → Network

🎉 Tất cả chức năng đã được phục hồi và nâng cấp!