发布时间:2024-12-20 16:01
def create_csv(txt_path, csv_path):
lists = pd.read_csv(txt_path, sep=r"\t", header=None)
lists = lists.sample(frac=1)
lists.to_csv(csv_path, index=None)
print("Finish save csv")
# 解决中文乱码问题
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
def plot_loss(train_loss, val_loss):
plt.plot(train_loss, label='train_loss')
plt.plot(val_loss, label='val_loss')
plt.legend(loc='best')
plt.ylabel('loss')
plt.xlabel('epoch')
plt.title("训练集和验证集loss值得对比图")
plt.savefig('results/loss.png')
plt.show()
def plot_acc(train_acc, val_acc):
plt.plot(train_acc, label='train_acc')
plt.plot(val_acc, label='val_acc')
plt.legend(loc='best')
plt.ylabel('acc')
plt.xlabel('epoch')
plt.title("训练集和验证集acc值得对比图")
plt.savefig('results/acc.png')
plt.show()
def plot_results(epochs, train_acc, train_loss, test_acc, test_loss):
x = np.arange(epochs)
plt.plot(x, train_acc, label='train_acc')
plt.plot(x, train_loss, label='train_loss')
plt.plot(x, test_acc, label='test_acc')
plt.plot(x, test_loss, label='test_loss')
plt.title("Results", fontsize=15)
plt.xlabel("X", fontsize=13)
plt.ylabel("Y", fontsize=13)
plt.legend()
plt.savefig('results/result.png')
plt.show()
from glob import glob
def save_txt(data_path, save_path):
files = glob(data_path + '/*.jpg')
lists = sorted(files) # 所有图片文件路径
a = open(save_path, "w", encoding='UTF-8')
for i in range(len(lists)):
a.write(lists[i])
a.write('\n')
a.close()
def ReadTxt(rootdir='test.txt'):
lines = []
with open(rootdir, 'r') as file_to_read:
while True:
line = file_to_read.readline()
if not line:
break
line = line.strip('\n')
lines.append(line)
return lines
path = '/data/'
files = []
a = open("test.txt", "w", encoding='UTF-8')
for item in os.listdir(path):
if item.split('.')[-1].lower() in ['jpg', 'jpeg', 'png']:
a.write(str(item.split('.')[:-1]) + '\n')
a.close()
在VSCode中配置代码自动 eslint 格式化(修改eslint规则、eslint忽略文件)
k8s笔记14--初次体验 开源云原生软件交付平台zadig
项目报错 TypeError: loaderContext.getOptions is not a function
JAVA中stacksize是什么意思_深入理解JS函数stack size计算方法
Windows下更新适用于Portapack的HackRF One固件
Java项目:校园宿舍管理系统(java+Springboot+Vue+maven+redis+Mysql)
C++ 基础与深度分析 Chapter11 类与面向对象编程(构造函数:缺省、单一、拷贝、移动、赋值)