In Masterarbeit:"Anomalie-Detektion in Zellbildern zur Anwendung der Leukämieerkennung" verwendete CSI Methode.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

postprocess_data.py 1.4KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import re
  2. import matplotlib.pyplot as plt
  3. PATH = r'C:\Users\feokt\PycharmProjects\CSI\CSI\logs'
  4. def postprocess_data(log: list):
  5. for pth in log:
  6. loss_sim = []
  7. loss_shift = []
  8. with open(PATH + pth) as f:
  9. lines = f.readlines()
  10. for line in lines:
  11. # line = '[2022-01-31 20:40:23.947855] [DONE] [Time 0.179] [Data 0.583] [LossC 0.000000] [LossSim 4.024234] [LossShift 0.065126]'
  12. part = re.search('\[DONE\]', line)
  13. if part is not None:
  14. l_sim = re.search('(\[LossSim.[0-9]*.[0-9]*\])', line).group()
  15. if l_sim is not None:
  16. loss_sim.append(float(re.search('(\s[0-9].*[0-9])', l_sim).group()))
  17. l_shift = re.search('(\[LossShift.[0-9]*.[0-9]*\])', line).group()
  18. if l_shift is not None:
  19. loss_shift.append(float(re.search('(\s[0-9].*[0-9])', l_shift).group()))
  20. loss = [loss_sim[i] + loss_shift[i] for i in range(len(loss_sim))]
  21. plt.ylabel("loss")
  22. plt.xlabel("epoch")
  23. plt.title("Loss over epochs")
  24. plt.plot(list(range(1, 101)), loss)
  25. for idx in range(len(log)):
  26. log[idx] = log[idx][38:]
  27. plt.legend(log)
  28. plt.grid()
  29. #plt.plot(list(range(1, 101)), loss_sim)
  30. #plt.plot(list(range(1, 101)), loss_shift)
  31. plt.show()