Spaces:
Running
Running
Commit
·
870c253
1
Parent(s):
975d352
Add TensorBoard log visualization and update training section
Browse files
app.py
CHANGED
@@ -15,6 +15,8 @@ from openai import OpenAI
|
|
15 |
import os
|
16 |
from dotenv import load_dotenv
|
17 |
from chatbot_utils import ask_receipt_chatbot
|
|
|
|
|
18 |
|
19 |
# Configure logging
|
20 |
logging.basicConfig(level=logging.INFO)
|
@@ -198,5 +200,34 @@ def main():
|
|
198 |
answer = ask_receipt_chatbot(user_question)
|
199 |
st.success(answer)
|
200 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
if __name__ == "__main__":
|
202 |
main()
|
|
|
15 |
import os
|
16 |
from dotenv import load_dotenv
|
17 |
from chatbot_utils import ask_receipt_chatbot
|
18 |
+
import time
|
19 |
+
from tensorboard.backend.event_processing import event_accumulator
|
20 |
|
21 |
# Configure logging
|
22 |
logging.basicConfig(level=logging.INFO)
|
|
|
200 |
answer = ask_receipt_chatbot(user_question)
|
201 |
st.success(answer)
|
202 |
|
203 |
+
st.header("Model Training & Evaluation Demo")
|
204 |
+
|
205 |
+
if st.button("Start Training"):
|
206 |
+
epochs = 10
|
207 |
+
losses = []
|
208 |
+
accuracies = []
|
209 |
+
progress = st.progress(0)
|
210 |
+
chart = st.line_chart({"Loss": [], "Accuracy": []})
|
211 |
+
|
212 |
+
for epoch in range(epochs):
|
213 |
+
# Simulate training
|
214 |
+
loss = np.exp(-epoch/5) + np.random.rand() * 0.05
|
215 |
+
acc = 1 - loss + np.random.rand() * 0.02
|
216 |
+
losses.append(loss)
|
217 |
+
accuracies.append(acc)
|
218 |
+
chart.add_rows({"Loss": [loss], "Accuracy": [acc]})
|
219 |
+
progress.progress((epoch+1)/epochs)
|
220 |
+
st.write(f"Epoch {epoch+1}: Loss={loss:.4f}, Accuracy={acc:.4f}")
|
221 |
+
time.sleep(0.5)
|
222 |
+
|
223 |
+
st.success("Training complete!")
|
224 |
+
st.line_chart({"Loss": losses, "Accuracy": accuracies})
|
225 |
+
|
226 |
+
logdir = "path/to/your/logdir"
|
227 |
+
ea = event_accumulator.EventAccumulator(logdir)
|
228 |
+
ea.Reload()
|
229 |
+
losses = [s.value for s in ea.Scalars('loss')]
|
230 |
+
st.line_chart(losses)
|
231 |
+
|
232 |
if __name__ == "__main__":
|
233 |
main()
|