diff --git a/01.train_ODC.ipynb b/01.train_ODC.ipynb index 6a5d2a2..d1b0187 100644 --- a/01.train_ODC.ipynb +++ b/01.train_ODC.ipynb @@ -854,8 +854,8 @@ "TRAINING DATA SETUP\n", "======================================================================\n", "\n", - "[1] Loading training data: train/ST_training data_updated_1130points_new.shp\n", - " ❌ Error: train/ST_training data_updated_1130points_new.shp: No such file or directory\n", + "[1] Loading training data: train/ST_training_data_updated_1130points_new.shp\n", + " ❌ Error: train/ST_training_data_updated_1130points_new.shp: No such file or directory\n", "\n", "[2] Label mapping:\n", " 0: Lua tom\n", @@ -878,7 +878,7 @@ "print(\"=\"*70)\n", "\n", "# Load training points\n", - "train_path = \"train/ST_training data_updated_1130points_new.shp\"\n", + "train_path = \"train/ST_training_data_updated_1130points_new.shp\"\n", "print(f\"\\n[1] Loading training data: {train_path}\")\n", "\n", "try:\n", diff --git a/01.train_ODC.py b/01.train_ODC.py index 3192290..115efb7 100755 --- a/01.train_ODC.py +++ b/01.train_ODC.py @@ -33,7 +33,7 @@ CACHE_DIR = "dataset_cache" CACHE_FILE = f"{CACHE_DIR}/sentinel2_timeseries_40scenes.nc" # --- Training data --- -TRAIN_PATH = "train/ST_training data_updated_1130points_new.shp" +TRAIN_PATH = "train/ST_training_data_updated_1130points_new.shp" # --- Features sử dụng để train --- AVAILABLE_FEATURES = [ diff --git a/01.train_ODC_CNN.ipynb b/01.train_ODC_CNN.ipynb index a4dd503..d8ac4dc 100644 --- a/01.train_ODC_CNN.ipynb +++ b/01.train_ODC_CNN.ipynb @@ -2854,7 +2854,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "id": "d2585562-88aa-4c7d-bf70-1f6affcf65d4", "metadata": { "tags": [] @@ -2862,7 +2862,7 @@ "outputs": [], "source": [ "## cấu hình bộ dữ liệu điểm huấn luyện mô hình (train file)\n", - "train_path = \"train/ST_training data_updated_1130points_new.shp\" # đường dẫn shp file train\n", + "train_path = \"train/ST_training_data_updated_1130points_new.shp\" # đường dẫn shp file train\n", "\n", "## load dữ liệu điểm huấn luyện mô hình (train file)\n", "train = load_train_data(train_path)\n", diff --git a/01.train_ODC_MobileNet.ipynb b/01.train_ODC_MobileNet.ipynb index 93b03fe..e3232d8 100644 --- a/01.train_ODC_MobileNet.ipynb +++ b/01.train_ODC_MobileNet.ipynb @@ -428,55 +428,6 @@ "plt.tight_layout()\n", "plt.show()\n" ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "28f87d0e", - "metadata": {}, - "outputs": [], - "source": [ - "import json\n", - "from datetime import datetime\n", - "\n", - "# ── Lưu mô hình PyTorch ────────────────────────────────────────────────────────\n", - "model_path = \"model_mobilenet_land_use.pth\"\n", - "torch.save(model.state_dict(), model_path)\n", - "print(f\"✅ Model saved → {model_path}\")\n", - "\n", - "# ── Lưu thông tin mô hình ──────────────────────────────────────────────────────\n", - "info = {\n", - " \"model_type\": \"MobileNetV3_LR-ASPP\",\n", - " \"n_features\": n_features,\n", - " \"n_classes\": n_classes,\n", - " \"learning_rate\": LEARNING_RATE,\n", - " \"batch_size\": BATCH_SIZE,\n", - " \"max_epochs\": N_EPOCHS,\n", - " \"early_stopping_patience\": PATIENCE,\n", - " \"optimizer\": \"Adam\",\n", - " \"scheduler\": \"ReduceLROnPlateau(factor=0.5, patience=5)\",\n", - " \"class_weight\": \"balanced\",\n", - " \"label_mapping\": label_mapping,\n", - " \"test_accuracy\": float(acc),\n", - " \"train_samples\": len(X_train_np),\n", - " \"val_samples\": len(X_val_np),\n", - " \"test_samples\": len(X_test_np),\n", - " \"saved_at\": datetime.now().isoformat(),\n", - "}\n", - "info_path = \"model_mobilenet_land_use_info.json\"\n", - "with open(info_path, \"w\") as f:\n", - " json.dump(info, f, indent=2, ensure_ascii=False)\n", - "print(f\"✅ Info saved → {info_path}\")\n", - "print(json.dumps(info, indent=2, ensure_ascii=False))\n", - "\n", - "# ── Đóng kết nối Dask ──────────────────────────────────────────────────────────\n", - "try:\n", - " client.close()\n", - " cluster.close()\n", - " print(\"✅ Dask cluster closed.\")\n", - "except Exception:\n", - " pass\n" - ] } ], "metadata": { diff --git a/01.train_ODC_RandomForest.ipynb b/01.train_ODC_RandomForest.ipynb index 31d2012..9798256 100644 --- a/01.train_ODC_RandomForest.ipynb +++ b/01.train_ODC_RandomForest.ipynb @@ -103,7 +103,7 @@ "outputs": [], "source": [ "## Chuẩn bị dữ liệu train\n", - "train_path = \"train/ST_training data_updated_1130points_new.shp\"\n", + "train_path = \"train/ST_training_data_updated_1130points_new.shp\"\n", "train = load_train_data(train_path)\n", "train.head()\n", "\n", diff --git a/01.train_ODC_SwinUNet.ipynb b/01.train_ODC_SwinUNet.ipynb index 21c2825..130aa0c 100644 --- a/01.train_ODC_SwinUNet.ipynb +++ b/01.train_ODC_SwinUNet.ipynb @@ -140,7 +140,7 @@ "outputs": [], "source": [ "## ── Chuẩn bị dữ liệu train ───────────────────────────────────────────────────\n", - "train_path = \"train/ST_training data_updated_1130points_new.shp\"\n", + "train_path = \"train/ST_training_data_updated_1130points_new.shp\"\n", "\n", "train = load_train_data(train_path)\n", "train.head()\n", diff --git a/01.train_ODC_XGBoost.ipynb b/01.train_ODC_XGBoost.ipynb index e938a06..ffafa21 100755 --- a/01.train_ODC_XGBoost.ipynb +++ b/01.train_ODC_XGBoost.ipynb @@ -2854,7 +2854,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "id": "d2585562-88aa-4c7d-bf70-1f6affcf65d4", "metadata": { "tags": [] @@ -2862,7 +2862,7 @@ "outputs": [], "source": [ "## cấu hình bộ dữ liệu điểm huấn luyện mô hình (train file)\n", - "train_path = \"train/ST_training data_updated_1130points_new.shp\" # đường dẫn shp file train\n", + "train_path = \"train/ST_training_data_updated_1130points_new.shp\" # đường dẫn shp file train\n", "\n", "## load dữ liệu điểm huấn luyện mô hình (train file)\n", "train = load_train_data(train_path)\n", diff --git a/01.train_ODC_local_with_Mic_supplyer.ipynb b/01.train_ODC_local_with_Mic_supplyer.ipynb index 4ddb4b2..a777f77 100755 --- a/01.train_ODC_local_with_Mic_supplyer.ipynb +++ b/01.train_ODC_local_with_Mic_supplyer.ipynb @@ -1727,7 +1727,7 @@ "FEATURE EXTRACTION\n", "======================================================================\n", "\n", - "[1] Loading training data from: train/ST_training data_updated_1130points_new.shp\n", + "[1] Loading training data from: train/ST_training_data_updated_1130points_new.shp\n", "✅ Loaded 1130 training points\n", " Available columns: ['No', 'X', 'Y', 'LU2022', 'Hientrang', 'HT_code', 'geometry']\n", " Using label column: 'HT_code'\n", @@ -1769,7 +1769,7 @@ "# Load training shapefile\n", "import geopandas as gpd\n", "\n", - "train_path = 'train/ST_training data_updated_1130points_new.shp'\n", + "train_path = 'train/ST_training_data_updated_1130points_new.shp'\n", "print(f\"\\n[1] Loading training data from: {train_path}\")\n", "train_gdf = gpd.read_file(train_path)\n", "\n", diff --git a/TRAINING_UPDATE_SUMMARY.md b/TRAINING_UPDATE_SUMMARY.md index 494ad11..e9f7fbc 100755 --- a/TRAINING_UPDATE_SUMMARY.md +++ b/TRAINING_UPDATE_SUMMARY.md @@ -44,7 +44,7 @@ DEFAULT_LABEL_MAPPING = { { "files": [ { - "filename": "ST_training data_updated_1130points_new.shp", + "filename": "ST_training_data_updated_1130points_new.shp", "path": "train/...", "size_mb": 0.15, "point_count": 1130, @@ -110,7 +110,7 @@ DEFAULT_LABEL_MAPPING = { Features: - Dropdown chọn shapefile từ thư mục `/train` -- Tự động load default: `ST_training data_updated_1130points_new.shp` +- Tự động load default: `ST_training_data_updated_1130points_new.shp` - Hiển thị thông tin: số điểm, label column, số lớp, bbox #### ✅ Thêm phần hiển thị thông tin Shapefile: @@ -149,7 +149,7 @@ Features: #### ✅ Cập nhật form submission: - Thêm `training_shapefile` vào config -- Default: `train/ST_training data_updated_1130points_new.shp` +- Default: `train/ST_training_data_updated_1130points_new.shp` #### ✅ Event listeners: ```javascript @@ -252,7 +252,7 @@ curl http://localhost:8000/api/training/files curl http://localhost:8000/api/training/labels # Get shapefile labels -curl "http://localhost:8000/api/training/shapefile/ST_training data_updated_1130points_new.shp/labels" +curl "http://localhost:8000/api/training/shapefile/ST_training_data_updated_1130points_new.shp/labels" ``` ### Check Browser Console: @@ -265,8 +265,8 @@ curl "http://localhost:8000/api/training/shapefile/ST_training data_updated_1130 ## 📝 Notes 1. **Training shapefile path format**: - - Frontend select value: `ST_training data_updated_1130points_new.shp` - - Backend receives: `train/ST_training data_updated_1130points_new.shp` + - Frontend select value: `ST_training_data_updated_1130points_new.shp` + - Backend receives: `train/ST_training_data_updated_1130points_new.shp` - Auto-prepend `train/` prefix in form submission 2. **Label mapping**: diff --git a/api_server.py b/api_server.py index ae7f0a8..ae39871 100755 --- a/api_server.py +++ b/api_server.py @@ -3807,7 +3807,7 @@ async def change_detection_predict_workflow( # --- STEP 6: COMPARE WITH GROUND TRUTH --- print("[CHANGE DETECTION] Comparing with ground truth...") - gt_shapefile = "train/ST_training data_updated_1130points_new.shp" + gt_shapefile = "train/ST_training_data_updated_1130points_new.shp" gt_raster = rasterize_ground_truth(gt_shapefile, (height, width), bbox, class_column="class") # Calculate changes @@ -3912,7 +3912,7 @@ async def change_detection_workflow(request: ChangeDetectionWorkflowRequest): pred_transform = pred_ds.transform # Rasterize ground truth training data - gt_shapefile = "train/ST_training data_updated_1130points_new.shp" + gt_shapefile = "train/ST_training_data_updated_1130points_new.shp" gt_raster = rasterize_ground_truth(gt_shapefile, pred_arr.shape, bbox, class_column="class") # Calculate change detection @@ -4700,7 +4700,7 @@ async def predict_with_ndvi(config: PredictionWithNDVIConfig, background_tasks: change_map = None try: # Use training shapefile as ground truth - gt_shapefile = "train/ST_training data_updated_1130points_new.shp" + gt_shapefile = "train/ST_training_data_updated_1130points_new.shp" gt_raster = rasterize_ground_truth(gt_shapefile, (height, width), bbox, class_column="class") # Compare prediction and ground truth mask_valid = (gt_raster >= 0) & (prediction_raster >= 0) diff --git a/document/giai_thich_quy_trinh_phan_loai_dat.md b/document/giai_thich_quy_trinh_phan_loai_dat.md index 297ed3b..6b09cf5 100755 --- a/document/giai_thich_quy_trinh_phan_loai_dat.md +++ b/document/giai_thich_quy_trinh_phan_loai_dat.md @@ -135,7 +135,7 @@ File .tif (mỗi pixel = 1 mã loại đất) - **Tổng cộng**: ~39 features cho mỗi pixel ### Labels (Nhãn): -- Được lấy từ shapefile training: `train/ST_training data_updated_1130points_new.shp` +- Được lấy từ shapefile training: `train/ST_training_data_updated_1130points_new.shp` - 1130 điểm mẫu đã được gắn nhãn thủ công bởi chuyên gia --- diff --git a/test_training_api.py b/test_training_api.py index cdbbd3a..269608e 100755 --- a/test_training_api.py +++ b/test_training_api.py @@ -45,7 +45,7 @@ def test_training_files(): print(f"❌ Error: {response.status_code}") print() -def test_shapefile_labels(filename="ST_training data_updated_1130points_new.shp"): +def test_shapefile_labels(filename="ST_training_data_updated_1130points_new.shp"): """Test /api/training/shapefile/{filename}/labels endpoint""" print("=" * 70) print(f"TEST 3: Getting labels from shapefile: {filename}") diff --git a/train_module.py b/train_module.py index 83aeac5..7eaea33 100755 --- a/train_module.py +++ b/train_module.py @@ -359,7 +359,7 @@ def train_model( max_scenes=12, cloud_cover=30, resolution=20, - training_shapefile='train/ST_training data_updated_1130points_new.shp', + training_shapefile='train/ST_training_data_updated_1130points_new.shp', model_type='xgboost', n_estimators=100, max_depth=20, diff --git a/training_interface.html b/training_interface.html index b54d5e2..982279e 100755 --- a/training_interface.html +++ b/training_interface.html @@ -804,7 +804,7 @@ }); // Select default shapefile - const defaultFile = 'ST_training data_updated_1130points_new.shp'; + const defaultFile = 'ST_training_data_updated_1130points_new.shp'; const defaultOption = Array.from(select.options).find(opt => opt.value === defaultFile); if (defaultOption) { select.value = defaultFile; @@ -1074,7 +1074,7 @@ // Get selected training shapefile const selectedShapefile = document.getElementById('trainingShapefile').value; - const trainingShapefile = selectedShapefile || 'train/ST_training data_updated_1130points_new.shp'; + const trainingShapefile = selectedShapefile || 'train/ST_training_data_updated_1130points_new.shp'; const config = { min_lon: parseFloat(document.getElementById('minLon').value),