Keeby-smilyai commited on
Commit
4e5a9fb
·
verified ·
1 Parent(s): 4f09d68

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -8
app.py CHANGED
@@ -101,11 +101,23 @@ def auto_train_pipeline():
101
  def initialize_autonomous_trainer():
102
  training_thread = threading.Thread(target=auto_train_pipeline, daemon=True)
103
  training_thread.start()
 
 
 
 
 
 
 
 
 
104
 
105
  # --- Gradio UI (Chat-Only) ---
106
  with gr.Blocks(title="🥥 COCONUT-VLM Autonomous Trainer") as demo:
107
  gr.Markdown("# 🥥 COCONUT-VLM: Autonomous Vision-Language Trainer")
108
  gr.Markdown("Model is training itself in 3 stages automatically. **You can only chat.** Training is backend-only.")
 
 
 
109
 
110
  with gr.Row():
111
  with gr.Column(scale=1):
@@ -126,14 +138,24 @@ with gr.Blocks(title="🥥 COCONUT-VLM Autonomous Trainer") as demo:
126
  msg = gr.Textbox(label="Ask a question about the image")
127
  clear = gr.Button("Clear Chat")
128
 
129
- # Chat logic - FIXED: Changed output to chatbot instead of chat_history
130
  msg.submit(chat_with_image, [image_input, msg, chatbot], [msg, chatbot])
131
- clear.click(lambda: None, None, chatbot, queue=False)
132
-
133
- # ✅ FIXED: Use Gradio 4.x compatible .load()
134
- demo.load(initialize_autonomous_trainer, inputs=None, outputs=None)
135
-
136
- # ✅ Updated: Use the correct syntax for Timer
137
- gr.Timer(3, lambda: training_status, outputs=status)
 
 
 
 
 
 
 
 
 
 
138
 
139
  demo.queue(max_size=20).launch()
 
101
  def initialize_autonomous_trainer():
102
  training_thread = threading.Thread(target=auto_train_pipeline, daemon=True)
103
  training_thread.start()
104
+
105
+ # Start the status update process
106
+ return training_status
107
+
108
+ # --- Status update function ---
109
+ def update_status():
110
+ # Return the current status and trigger the next update
111
+ time.sleep(0.5) # Small delay to prevent CPU overload
112
+ return training_status, gr.update(autoscroll=True) # Also autoscroll chat window
113
 
114
  # --- Gradio UI (Chat-Only) ---
115
  with gr.Blocks(title="🥥 COCONUT-VLM Autonomous Trainer") as demo:
116
  gr.Markdown("# 🥥 COCONUT-VLM: Autonomous Vision-Language Trainer")
117
  gr.Markdown("Model is training itself in 3 stages automatically. **You can only chat.** Training is backend-only.")
118
+
119
+ # We'll create a hidden component to trigger status updates
120
+ hidden_dummy = gr.State()
121
 
122
  with gr.Row():
123
  with gr.Column(scale=1):
 
138
  msg = gr.Textbox(label="Ask a question about the image")
139
  clear = gr.Button("Clear Chat")
140
 
141
+ # Chat logic - FIXED: Changed output to chatbot
142
  msg.submit(chat_with_image, [image_input, msg, chatbot], [msg, chatbot])
143
+ clear.click(lambda: None, inputs=None, outputs=chatbot, queue=False)
144
+
145
+ # ✅ FIXED: Combined initialization and status updates
146
+ demo.load(
147
+ fn=initialize_autonomous_trainer,
148
+ inputs=None,
149
+ outputs=status,
150
+ then=[
151
+ fn=update_status,
152
+ outputs=[status, chatbot],
153
+ every=1.5, # Update every 1.5 seconds
154
+ # We'll chain updates to create a continuous loop:
155
+ then=update_status,
156
+ outputs=[status, chatbot],
157
+ every=1.5
158
+ ]
159
+ )
160
 
161
  demo.queue(max_size=20).launch()