Update train.py
Browse files
train.py
CHANGED
@@ -57,28 +57,15 @@ trainer = SFTTrainer(
|
|
57 |
|
58 |
trainer.train()
|
59 |
|
60 |
-
# Save
|
61 |
-
|
|
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
os.
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
fpath = os.path.join(src_dir, fname)
|
72 |
-
if os.path.isfile(fpath):
|
73 |
-
shutil.copy2(fpath, dst_dir)
|
74 |
-
print(f"β
Copied {fname} to final_model")
|
75 |
-
|
76 |
-
try:
|
77 |
-
shutil.copy2(fpath, root_dir)
|
78 |
-
print(f"β
Copied {fname} to app root for UI visibility")
|
79 |
-
except Exception as e:
|
80 |
-
print(f"β οΈ Failed to copy {fname} to root: {e}")
|
81 |
-
else:
|
82 |
-
print(f"π Skipped {fname} (not a file)")
|
83 |
-
else:
|
84 |
-
print("β Source folder does not exist")
|
|
|
57 |
|
58 |
trainer.train()
|
59 |
|
60 |
+
# β
Save to Hugging Face persistent path
|
61 |
+
output_path = "./outputs/final_model"
|
62 |
+
os.makedirs(output_path, exist_ok=True)
|
63 |
|
64 |
+
try:
|
65 |
+
model.save_pretrained(output_path)
|
66 |
+
print(f"β
Model saved to {output_path}")
|
67 |
+
print("π Contents of saved model directory:")
|
68 |
+
for file in os.listdir(output_path):
|
69 |
+
print(" -", file)
|
70 |
+
except Exception as e:
|
71 |
+
print(f"β Failed to save model: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|