6.2 KiB
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
- Web interface: http://localhost:8000/
- Hoặc truy cập trực tiếp: http://localhost:8000/api/reports/view/{filename}
🔄 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
- Truy cập: http://localhost:8000/dashboard
- Chọn tab "🔄 Batch Processing"
- Upload CSV file
- Chọn model để predict
- 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
- Training Interface: http://localhost:8000/
- Dashboard: http://localhost:8000/dashboard
- API Docs: http://localhost:8000/docs
- Redoc: http://localhost:8000/redoc
🔧 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
- Train nhiều models với configs khác nhau
- Mở Dashboard → Tab "📊 Accuracy Trends"
- So sánh accuracy/F1-score qua thời gian
- Export charts để báo cáo
Use Case 2: Batch Prediction cho nhiều khu vực
- Chuẩn bị CSV với danh sách khu vực
- Upload vào Dashboard → Tab "🔄 Batch Processing"
- Chọn model tốt nhất
- Start batch và theo dõi progress
- Download results khi hoàn thành
Use Case 3: Tạo Reports tự động
- Chạy training/prediction
- Report tự động được tạo
- Xem qua Dashboard hoặc
/api/reports/list - Download để chia sẻ
⚠️ Lưu ý
- Batch Processing: Hiện tại chỉ xử lý tuần tự (từng job một)
- Auto-retry: Chỉ retry khi lỗi kỹ thuật, không retry nếu config sai
- Charts Export: Cần browser hỗ trợ Canvas API
- 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:
- API logs:
python api_server.py - Browser console: F12 → Console
- Network tab: F12 → Network
🎉 Tất cả chức năng đã được phục hồi và nâng cấp!