update 01
This commit is contained in:
@@ -76,6 +76,7 @@ model_train/*.feather
|
|||||||
model_train/*.db
|
model_train/*.db
|
||||||
model_train/*.sqlite
|
model_train/*.sqlite
|
||||||
model_train/*.log
|
model_train/*.log
|
||||||
|
cloud_removal_model/
|
||||||
|
|
||||||
# VSCode settings
|
# VSCode settings
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|||||||
+6
-6
@@ -510,12 +510,12 @@ async def get_cloud_removal_methods():
|
|||||||
@app.get("/api/cloud-removal/models")
|
@app.get("/api/cloud-removal/models")
|
||||||
async def list_cloud_removal_models():
|
async def list_cloud_removal_models():
|
||||||
"""Liệt kê các cloud removal models đã train"""
|
"""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():
|
if not model_dir.exists():
|
||||||
return {"models": [], "count": 0}
|
return {"models": [], "count": 0}
|
||||||
|
|
||||||
models = []
|
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"):
|
for model_file in model_dir.rglob("*.pth"):
|
||||||
# Skip non-cloud-removal models (keep land classification models separate)
|
# 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']):
|
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,
|
num_epochs=config.num_epochs,
|
||||||
learning_rate=config.learning_rate,
|
learning_rate=config.learning_rate,
|
||||||
device="cuda" if config.use_gpu else "cpu",
|
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}")
|
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")
|
raise HTTPException(status_code=400, detail="Invalid filename")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
model_dir = Path("model_train")
|
model_dir = Path("cloud_removal_model")
|
||||||
model_dir.mkdir(exist_ok=True)
|
model_dir.mkdir(exist_ok=True)
|
||||||
|
|
||||||
# Save uploaded file
|
# Save uploaded file
|
||||||
@@ -767,7 +767,7 @@ async def upload_cloud_removal_model(
|
|||||||
@app.delete("/api/cloud-removal/models/{filename}")
|
@app.delete("/api/cloud-removal/models/{filename}")
|
||||||
async def delete_cloud_removal_model(filename: str):
|
async def delete_cloud_removal_model(filename: str):
|
||||||
"""Xóa cloud removal model"""
|
"""Xóa cloud removal model"""
|
||||||
model_dir = Path("model_train")
|
model_dir = Path("cloud_removal_model")
|
||||||
model_path = model_dir / filename
|
model_path = model_dir / filename
|
||||||
|
|
||||||
# Security check
|
# Security check
|
||||||
@@ -1748,7 +1748,7 @@ async def run_prediction(config: PredictionConfig):
|
|||||||
s2_data, cloud_metadata = process_cloud_removal(
|
s2_data, cloud_metadata = process_cloud_removal(
|
||||||
s2_data=s2_data,
|
s2_data=s2_data,
|
||||||
method=cloud_removal_method,
|
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
|
verbose=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user