Yash goyal commited on
Commit
cddf60d
·
verified ·
1 Parent(s): 6daeb4b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -42,6 +42,9 @@ else:
42
  # Plot accuracy history
43
  if "accuracy" in history_dict and "val_accuracy" in history_dict:
44
  try:
 
 
 
45
  plt.plot(history_dict['accuracy'], label='Train Accuracy')
46
  plt.plot(history_dict['val_accuracy'], label='Val Accuracy')
47
  plt.xlabel('Epochs')
@@ -49,10 +52,10 @@ if "accuracy" in history_dict and "val_accuracy" in history_dict:
49
  plt.title('Training History')
50
  plt.legend()
51
  plt.grid(True)
52
- os.makedirs("static", exist_ok=True)
53
- plt.savefig("static/training_plot.png")
54
  plt.close()
55
- logger.info("Generated training history plot at static/training_plot.png")
56
  except Exception as e:
57
  logger.error("Failed to generate training plot: %s", str(e))
58
 
 
42
  # Plot accuracy history
43
  if "accuracy" in history_dict and "val_accuracy" in history_dict:
44
  try:
45
+ plot_dir = os.path.join(os.getcwd(), "static")
46
+ os.makedirs(plot_dir, exist_ok=True) # ✅ ensure directory is writable
47
+
48
  plt.plot(history_dict['accuracy'], label='Train Accuracy')
49
  plt.plot(history_dict['val_accuracy'], label='Val Accuracy')
50
  plt.xlabel('Epochs')
 
52
  plt.title('Training History')
53
  plt.legend()
54
  plt.grid(True)
55
+ plot_path = os.path.join(plot_dir, "training_plot.png")
56
+ plt.savefig(plot_path) # ✅ safe full path
57
  plt.close()
58
+ logger.info("Generated training history plot at %s", plot_path)
59
  except Exception as e:
60
  logger.error("Failed to generate training plot: %s", str(e))
61