Upload folder using huggingface_hub
Browse files- webserver/train_service.py +20 -0
webserver/train_service.py
CHANGED
|
@@ -302,6 +302,26 @@ def run_finetune_job(job_id: str, input_paths: dict, run_dir: str, config: Train
|
|
| 302 |
|
| 303 |
_update_job(jobs, job_id, message="Loading model and fine-tuning...", progress=30, phase="loading_model")
|
| 304 |
progress_reporter = lambda **kwargs: _training_progress_update(jobs, job_id, **kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 305 |
classifier, _, _, mae_model = load_mae_model_for_classification(
|
| 306 |
input_paths["model"],
|
| 307 |
input_length=3500,
|
|
|
|
| 302 |
|
| 303 |
_update_job(jobs, job_id, message="Loading model and fine-tuning...", progress=30, phase="loading_model")
|
| 304 |
progress_reporter = lambda **kwargs: _training_progress_update(jobs, job_id, **kwargs)
|
| 305 |
+
|
| 306 |
+
model_path = input_paths.get("model")
|
| 307 |
+
BASE_DIR = os.path.join(ROOT_DIR, "webserver")
|
| 308 |
+
default_model_path = os.path.join(BASE_DIR, "weights", "Fine_tuned.pth")
|
| 309 |
+
if not model_path or not os.path.exists(model_path):
|
| 310 |
+
print(f"[JOB {job_id}] No valid user model uploaded. Falling back to built-in model: {default_model_path}")
|
| 311 |
+
model_path = default_model_path
|
| 312 |
+
else:
|
| 313 |
+
print(f"[JOB {job_id}] Using user-uploaded model from: {model_path}")
|
| 314 |
+
if not os.path.exists(model_path):
|
| 315 |
+
raise FileNotFoundError(f"Model file missing completely at: {model_path}")
|
| 316 |
+
|
| 317 |
+
file_size = os.path.getsize(model_path)
|
| 318 |
+
if file_size < 1000000:
|
| 319 |
+
raise ValueError(
|
| 320 |
+
f"🚨 LFS POINTER ERROR: The model file is only {file_size} bytes! "
|
| 321 |
+
f"It is a broken Git LFS pointer, not the real weight. "
|
| 322 |
+
f"Please go to the Hugging Face website and drag-and-drop upload the 300MB Fine_tuned.pth to the 'weights' folder."
|
| 323 |
+
)
|
| 324 |
+
|
| 325 |
classifier, _, _, mae_model = load_mae_model_for_classification(
|
| 326 |
input_paths["model"],
|
| 327 |
input_length=3500,
|