himu1780 commited on
Commit
924a225
Β·
verified Β·
1 Parent(s): 610b4ec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -7
app.py CHANGED
@@ -147,7 +147,6 @@ def prepare_dataset(tokenizer):
147
  all_examples = []
148
  for i, example in enumerate(tokenized_dataset):
149
  all_examples.append(example)
150
- # Progress every 5000 (IMPROVED)
151
  if i % 5000 == 0:
152
  training_status["message"] = f"πŸ“₯ Loaded {i:,}/{EXAMPLES_PER_SESSION:,} examples..."
153
  if i >= EXAMPLES_PER_SESSION - 1:
@@ -250,7 +249,6 @@ def run_training_session():
250
  traceback.print_exc()
251
  return False
252
  finally:
253
- # MEMORY CLEANUP (IMPROVED)
254
  del model, trainer
255
  cleanup_memory()
256
 
@@ -266,7 +264,6 @@ def start_training():
266
  training_status["start_time"] = datetime.now()
267
  stop_requested = False
268
 
269
- # CONTINUOUS TRAINING LOOP (IMPROVED)
270
  while not stop_requested:
271
  training_status["message"] = f"πŸš€ Starting session {training_status['session_count'] + 1}..."
272
 
@@ -300,13 +297,11 @@ def get_status():
300
  minutes, seconds = divmod(remainder, 60)
301
  elapsed = f"{hours}h {minutes}m {seconds}s"
302
 
303
- # Pre-compute formatted loss string to avoid f-string format specifier issues
304
  if training_status["total_loss"]:
305
  loss_str = f"{training_status['total_loss']:.4f}"
306
  else:
307
  loss_str = "N/A"
308
 
309
- # Pre-compute other conditional strings
310
  state_str = "🟒 Training" if training_status["is_training"] else "πŸ”΄ Stopped"
311
  continuous_str = "βœ… Enabled" if CONTINUOUS_TRAINING else "❌ Disabled"
312
  elapsed_str = elapsed if elapsed else "N/A"
@@ -386,7 +381,5 @@ with gr.Blocks(title="AI Python Trainer") as demo:
386
  start_btn.click(start_training_async, outputs=output)
387
  stop_btn.click(stop_training, outputs=output)
388
  refresh_btn.click(get_status, outputs=status_display)
389
-
390
- demo.load(get_status, outputs=status_display, every=30)
391
 
392
  demo.launch()
 
147
  all_examples = []
148
  for i, example in enumerate(tokenized_dataset):
149
  all_examples.append(example)
 
150
  if i % 5000 == 0:
151
  training_status["message"] = f"πŸ“₯ Loaded {i:,}/{EXAMPLES_PER_SESSION:,} examples..."
152
  if i >= EXAMPLES_PER_SESSION - 1:
 
249
  traceback.print_exc()
250
  return False
251
  finally:
 
252
  del model, trainer
253
  cleanup_memory()
254
 
 
264
  training_status["start_time"] = datetime.now()
265
  stop_requested = False
266
 
 
267
  while not stop_requested:
268
  training_status["message"] = f"πŸš€ Starting session {training_status['session_count'] + 1}..."
269
 
 
297
  minutes, seconds = divmod(remainder, 60)
298
  elapsed = f"{hours}h {minutes}m {seconds}s"
299
 
 
300
  if training_status["total_loss"]:
301
  loss_str = f"{training_status['total_loss']:.4f}"
302
  else:
303
  loss_str = "N/A"
304
 
 
305
  state_str = "🟒 Training" if training_status["is_training"] else "πŸ”΄ Stopped"
306
  continuous_str = "βœ… Enabled" if CONTINUOUS_TRAINING else "❌ Disabled"
307
  elapsed_str = elapsed if elapsed else "N/A"
 
381
  start_btn.click(start_training_async, outputs=output)
382
  stop_btn.click(stop_training, outputs=output)
383
  refresh_btn.click(get_status, outputs=status_display)
 
 
384
 
385
  demo.launch()