Download Plt.py from jie1/jie_test4: direct link, hf CLI and curl.
- Browser
- Download file 854 Bytes
-
https://huggingface.co/spaces/jie1/jie_test4/resolve/main/Plt.py
- Command line
-
hf download hf://spaces/jie1/jie_test4/Plt.py
-
curl -L -o Plt.py https://huggingface.co/spaces/jie1/jie_test4/resolve/main/Plt.py
854 Bytes
| from matplotlib import pyplot as plt | |
| def Plt(file): | |
| filereader = open(file.name, 'r') | |
| # 可视化 | |
| Loss_list = [] | |
| Accuracy_list = [] | |
| for line in filereader.readlines(): | |
| if line[0:4] == "loss": | |
| list = line.split() | |
| # print(list[1]) | |
| Loss_list.append(float(list[1])) | |
| Accuracy_list.append(float(list[3])) | |
| print(Loss_list) | |
| length = len(Loss_list) | |
| x1 = range(0, length) | |
| x2 = range(0, length) | |
| y1 = Accuracy_list | |
| # y2 = Loss_list[4:] | |
| y2 = Loss_list | |
| plt.subplot(2, 1, 1) | |
| plt.plot(x1, y1) | |
| plt.title('Test accuracy vs. epoches') | |
| plt.ylabel('Test accuracy') | |
| plt.subplot(2, 1, 2) | |
| plt.plot(x2, y2) | |
| plt.xlabel('Test loss vs. epoches') | |
| plt.ylabel('Test loss') | |
| plt.savefig("result.jpg") | |
| # plt.show() | |
| return "result.jpg" | |