eeshaAI commited on
Commit
3a0f51d
Β·
verified Β·
1 Parent(s): 912aed1

Update app.py: better error handling, show_error=True

Browse files
Files changed (1) hide show
  1. app.py +30 -17
app.py CHANGED
@@ -6,24 +6,40 @@ Provides a web UI to trigger LoRA fine-tuning of OLMo 2 1B Instruct
6
  on tokenized video data, then push the trained model to EeshaAI/zeeb.
7
  """
8
 
 
 
 
9
  import gradio as gr
10
- from train_on_hf_spaces import train
11
 
12
 
13
  def run_training():
14
- """Run the training pipeline and stream logs to the UI."""
15
- for log_msg in train("tokenized_dataset.json"):
16
- yield log_msg
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
 
19
  with gr.Blocks(
20
  title="Zeeb β€” Video-LLM Trainer",
21
  theme=gr.themes.Soft(),
22
- css="""
23
- #logbox { font-family: 'Courier New', monospace; font-size: 13px; line-height: 1.5; }
24
- #title { text-align: center; }
25
- .contain { max-width: 800px; margin: auto; }
26
- """
27
  ) as demo:
28
 
29
  gr.Markdown(
@@ -31,18 +47,15 @@ with gr.Blocks(
31
  # 🎬 Zeeb β€” Video-LLM Trainer
32
  Fine-tune **OLMo 2 1B Instruct** with **LoRA (r=4)** to generate video tokens.
33
  Trained model is automatically pushed to [EeshaAI/zeeb](https://huggingface.co/EeshaAI/zeeb).
34
- """,
35
- elem_id="title",
36
  )
37
 
38
- with gr.Row():
39
- train_btn = gr.Button("πŸš€ Start Training", variant="primary", size="lg")
40
 
41
  logbox = gr.Textbox(
42
  label="Training Log",
43
- elem_id="logbox",
44
- lines=25,
45
- max_lines=100,
46
  interactive=False,
47
  show_copy_button=True,
48
  )
@@ -65,4 +78,4 @@ with gr.Blocks(
65
 
66
 
67
  if __name__ == "__main__":
68
- demo.launch(server_name="0.0.0.0", server_port=7860)
 
6
  on tokenized video data, then push the trained model to EeshaAI/zeeb.
7
  """
8
 
9
+ import os
10
+ import sys
11
+ import io
12
  import gradio as gr
 
13
 
14
 
15
  def run_training():
16
+ """Run the training pipeline, capturing all output."""
17
+ # Capture all prints and logs
18
+ old_stdout = sys.stdout
19
+ old_stderr = sys.stderr
20
+ sys.stdout = buffer = io.StringIO()
21
+ sys.stderr = buffer
22
+
23
+ log_output = ""
24
+
25
+ try:
26
+ from train_on_hf_spaces import train
27
+ for log_msg in train("tokenized_dataset.json"):
28
+ log_output += log_msg
29
+ except Exception as e:
30
+ import traceback
31
+ log_output += f"\n❌ ERROR: {e}\n"
32
+ log_output += traceback.format_exc()
33
+ finally:
34
+ sys.stdout = old_stdout
35
+ sys.stderr = old_stderr
36
+
37
+ return log_output
38
 
39
 
40
  with gr.Blocks(
41
  title="Zeeb β€” Video-LLM Trainer",
42
  theme=gr.themes.Soft(),
 
 
 
 
 
43
  ) as demo:
44
 
45
  gr.Markdown(
 
47
  # 🎬 Zeeb β€” Video-LLM Trainer
48
  Fine-tune **OLMo 2 1B Instruct** with **LoRA (r=4)** to generate video tokens.
49
  Trained model is automatically pushed to [EeshaAI/zeeb](https://huggingface.co/EeshaAI/zeeb).
50
+ """
 
51
  )
52
 
53
+ train_btn = gr.Button("πŸš€ Start Training", variant="primary", size="lg")
 
54
 
55
  logbox = gr.Textbox(
56
  label="Training Log",
57
+ lines=30,
58
+ max_lines=200,
 
59
  interactive=False,
60
  show_copy_button=True,
61
  )
 
78
 
79
 
80
  if __name__ == "__main__":
81
+ demo.launch(server_name="0.0.0.0", server_port=7860, show_error=True)