update 01
This commit is contained in:
+6
-6
@@ -510,12 +510,12 @@ async def get_cloud_removal_methods():
|
||||
@app.get("/api/cloud-removal/models")
|
||||
async def list_cloud_removal_models():
|
||||
"""Liệt kê các cloud removal models đã train"""
|
||||
model_dir = Path("model_train")
|
||||
model_dir = Path("cloud_removal_model")
|
||||
if not model_dir.exists():
|
||||
return {"models": [], "count": 0}
|
||||
|
||||
models = []
|
||||
# Search for ALL .pth files in model_train and subdirectories
|
||||
# Search for ALL .pth files in cloud_removal_model and subdirectories
|
||||
for model_file in model_dir.rglob("*.pth"):
|
||||
# Skip non-cloud-removal models (keep land classification models separate)
|
||||
if any(x in model_file.name.lower() for x in ['mobilenet', 'cnn_', 'swin', 'xgboost', 'random_forest']):
|
||||
@@ -635,7 +635,7 @@ async def train_cloud_removal(config: CloudRemovalTrainingConfig, background_tas
|
||||
num_epochs=config.num_epochs,
|
||||
learning_rate=config.learning_rate,
|
||||
device="cuda" if config.use_gpu else "cpu",
|
||||
save_dir="model_train"
|
||||
save_dir="cloud_removal_model"
|
||||
)
|
||||
|
||||
print(f"[CLOUD REMOVAL TRAINING] Completed {training_id}")
|
||||
@@ -708,7 +708,7 @@ async def upload_cloud_removal_model(
|
||||
raise HTTPException(status_code=400, detail="Invalid filename")
|
||||
|
||||
try:
|
||||
model_dir = Path("model_train")
|
||||
model_dir = Path("cloud_removal_model")
|
||||
model_dir.mkdir(exist_ok=True)
|
||||
|
||||
# Save uploaded file
|
||||
@@ -767,7 +767,7 @@ async def upload_cloud_removal_model(
|
||||
@app.delete("/api/cloud-removal/models/{filename}")
|
||||
async def delete_cloud_removal_model(filename: str):
|
||||
"""Xóa cloud removal model"""
|
||||
model_dir = Path("model_train")
|
||||
model_dir = Path("cloud_removal_model")
|
||||
model_path = model_dir / filename
|
||||
|
||||
# Security check
|
||||
@@ -1748,7 +1748,7 @@ async def run_prediction(config: PredictionConfig):
|
||||
s2_data, cloud_metadata = process_cloud_removal(
|
||||
s2_data=s2_data,
|
||||
method=cloud_removal_method,
|
||||
model_path=f"model_train/{cloud_removal_model}" if cloud_removal_model else None,
|
||||
model_path=f"cloud_removal_model/{cloud_removal_model}" if cloud_removal_model else None,
|
||||
verbose=True
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user