Update app.py
Browse files
app.py
CHANGED
|
@@ -76,7 +76,7 @@ class CustomTrainerCallback(TrainerCallback):
|
|
| 76 |
job.progress = 0.1 + (prog * 0.8)
|
| 77 |
if state.global_step % 1 == 0:
|
| 78 |
loss = state.log_history[-1].get('loss', 'N/A') if state.log_history else '...'
|
| 79 |
-
job.add_log(f"Step {state.global_step}/{state.max_steps} | Loss: {loss}")
|
| 80 |
return control
|
| 81 |
|
| 82 |
def on_save(self, args, state, control, **kwargs):
|
|
@@ -281,7 +281,14 @@ def background_train_task(job_id, hf_token, model_name, new_repo_name, lora_r, l
|
|
| 281 |
if content and content.strip():
|
| 282 |
try:
|
| 283 |
data = json.loads(content)
|
| 284 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 285 |
json.dump(data, f, indent=2)
|
| 286 |
except:
|
| 287 |
pass
|
|
|
|
| 76 |
job.progress = 0.1 + (prog * 0.8)
|
| 77 |
if state.global_step % 1 == 0:
|
| 78 |
loss = state.log_history[-1].get('loss', 'N/A') if state.log_history else '...'
|
| 79 |
+
job.add_log(f"Training Step {state.global_step}/{state.max_steps} | Loss: {loss}")
|
| 80 |
return control
|
| 81 |
|
| 82 |
def on_save(self, args, state, control, **kwargs):
|
|
|
|
| 281 |
if content and content.strip():
|
| 282 |
try:
|
| 283 |
data = json.loads(content)
|
| 284 |
+
file_path = os.path.join(final_path, fname)
|
| 285 |
+
if os.path.exists(file_path):
|
| 286 |
+
with open(file_path, 'r', encoding='utf-8') as f:
|
| 287 |
+
existing_data = json.load(f)
|
| 288 |
+
existing_data.update(data)
|
| 289 |
+
data = existing_data
|
| 290 |
+
|
| 291 |
+
with open(file_path, 'w', encoding='utf-8') as f:
|
| 292 |
json.dump(data, f, indent=2)
|
| 293 |
except:
|
| 294 |
pass
|