chandini2595 commited on
Commit
e8dbc8c
·
1 Parent(s): 6fa72c7

Remove post-training TensorBoard log charts

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -237,7 +237,6 @@ def main():
237
  # Simulate predictions and labels for confusion matrix
238
  y_true = np.random.randint(0, num_classes, 100)
239
  y_pred = y_true.copy()
240
- # Add some noise to predictions
241
  y_pred[np.random.choice(100, 10, replace=False)] = np.random.randint(0, num_classes, 10)
242
  cm = confusion_matrix(y_true, y_pred, labels=range(num_classes))
243
 
@@ -249,13 +248,15 @@ def main():
249
  plt.close(fig)
250
  writer.add_figure("confusion_matrix", fig, epoch)
251
 
252
- time.sleep(0.5)
253
-
254
  writer.close()
255
  st.success("Training complete!")
256
 
257
- # Wait a moment to ensure logs are written
258
- time.sleep(1)
 
 
 
 
259
 
260
  if __name__ == "__main__":
261
  main()
 
237
  # Simulate predictions and labels for confusion matrix
238
  y_true = np.random.randint(0, num_classes, 100)
239
  y_pred = y_true.copy()
 
240
  y_pred[np.random.choice(100, 10, replace=False)] = np.random.randint(0, num_classes, 10)
241
  cm = confusion_matrix(y_true, y_pred, labels=range(num_classes))
242
 
 
248
  plt.close(fig)
249
  writer.add_figure("confusion_matrix", fig, epoch)
250
 
 
 
251
  writer.close()
252
  st.success("Training complete!")
253
 
254
+ # Show last confusion matrix in Streamlit
255
+ st.subheader("Confusion Matrix (Last Epoch)")
256
+ fig, ax = plt.subplots()
257
+ disp = ConfusionMatrixDisplay(confusion_matrix=cm, display_labels=[f"Class {i}" for i in range(num_classes)])
258
+ disp.plot(ax=ax)
259
+ st.pyplot(fig)
260
 
261
  if __name__ == "__main__":
262
  main()