Matlab读取yolov3训练的多个txt文件数据并绘图
最近用yolov3训练自己的数据,使用三种预训练权重,生成了三个txt文件数据,数据格式如下:
首先将三个txt文件复制到matlab bin目录下,将数据导入到matlab中,在工作区会看到导入的数据。绘图代码如下
`data1 = load(‘noweights.txt’);
data2 = load(‘darknet53.txt’); % data1,2,3 加载txt文件
data3 = load(‘spp.txt’);
save(‘data1.mat’,‘data1’);save(‘data2.mat’,‘data2’);save(‘data3.mat’,‘data3’); %将txt保存为.mat格式
figure(1);
x = data1(:,1); %读取第一列数据
c1 = data1(:,3);
c2 = data2(:,3); % 读取第三列数据
c3 = data3(:,3);
subplot(251);
plot(x,c1,‘r:’);title(‘GIoU’);xlabel(‘epochs’);ylabel(‘loss’);hold on;
plot(x,c2,‘b–’);hold on;
plot(x,c3,‘g’);
figure(1);
x = data1(:,1);
c1 = data1(:,4);
c2 = data2(:,4);
c3 = data3(:,4);
subplot(252);
plot(x,c1,‘r:’);title(‘Objectness’);xlabel(‘epochs’);ylabel(‘loss’);hold on;
plot(x,c2,‘b–’);hold on;
plot(x,c3,‘g’);
figure(1);
x = data1(:,1);
c1 = data1(:,5);
c2 = data2(:,5);
c3 = data3(:,5);
subplot(253);
plot(x,c1,‘r:’);title(‘Classification’);xlabel(‘epochs’);ylabel(‘loss’);hold on;
plot(x,c2,‘b–’);hold on;
plot(x,c3,‘g’);
figure(1);
x = data1(:,1);
c1 = data1(:,9);
c2 = data2(:,9);
c3 = data3(:,9);
subplot(254);
plot(x,c1,‘r:’);title(‘Precision’);xlabel(‘epochs’);ylabel(‘loss’);hold on;
plot(x,c2,‘b–’);hold on;
plot(x,c3,‘g’);
figure(1);
x = data1(:,1);
c1 = data1(:,10);
c2 = data2(:,10);
c3 = data3(:,10);
subplot(255);
plot(x,c1,‘r:’);title(‘Recall’);xlabel(‘epochs’);ylabel(‘loss’);hold on;
plot(x,c2,‘b–’);hold on;
plot(x,c3,‘g’);
figure(1);
x = data1(:,1);
c1 = data1(:,13);
c2 = data2(:,13);
c3 = data3(:,13);
subplot(256);
plot(x,c1,‘r:’);title(‘val GIoU’);xlabel(‘epochs’);ylabel(‘loss’);hold on;
plot(x,c2,‘b–’);hold on;
plot(x,c3,‘g’);
figure(1);
x = data1(:,1);
c1 = data1(:,14);
c2 = data2(:,14);
c3 = data3(:,14);
subplot(257);
plot(x,c1,‘r:’);title(‘val Objectness’);xlabel(‘epochs’);ylabel(‘loss’);hold on;
plot(x,c2,‘b–’);hold on;
plot(x,c3,‘g’);
figure(1);
x = data1(:,1);
c1 = data1(:,15);
c2 = data2(:,15);
c3 = data3(:,15);
subplot(258);
plot(x,c1,‘r:’);title(‘val Classification’);xlabel(‘epochs’);ylabel(‘loss’);hold on;
plot(x,c2,‘b–’);hold on;
plot(x,c3,‘g’);
figure(1);
x = data1(:,1);
c1 = data1(:,11);
c2 = data2(:,11);
c3 = data3(:,11);
subplot(259);
plot(x,c1,‘r:’);title(‘[email protected]’);xlabel(‘epochs’);ylabel(‘loss’);hold on;
plot(x,c2,‘b–’);hold on;
plot(x,c3,‘g’);
figure(1);
x = data1(:,1);
c1 = data1(:,12);
c2 = data2(:,12);
c3 = data3(:,12);
subplot(2,5,10);
plot(x,c1,‘r:’);title(‘F1’);xlabel(‘epochs’);ylabel(‘loss’);hold on;
plot(x,c2,‘b–’);hold on;
plot(x,c3,‘g’);`
绘制结果如下
绘制完后可以点击下图中位置,对坐标轴信息进行编辑