|
|
|
@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
|
|
|
|
import org.wlld.MatrixTools.Matrix;
|
|
|
|
|
import org.wlld.ModelData;
|
|
|
|
|
import org.wlld.config.Classifier;
|
|
|
|
|
import org.wlld.config.RZ;
|
|
|
|
|
import org.wlld.config.StudyPattern;
|
|
|
|
|
import org.wlld.imageRecognition.Operation;
|
|
|
|
|
import org.wlld.imageRecognition.Picture;
|
|
|
|
@ -21,45 +22,60 @@ public class FoodTest {
|
|
|
|
|
|
|
|
|
|
public static void food() throws Exception {
|
|
|
|
|
Picture picture = new Picture();
|
|
|
|
|
TempleConfig templeConfig = new TempleConfig(false, true);
|
|
|
|
|
TempleConfig templeConfig = new TempleConfig();
|
|
|
|
|
templeConfig.setClassifier(Classifier.DNN);
|
|
|
|
|
//templeConfig.setMatrixWidth(10);
|
|
|
|
|
templeConfig.isShowLog(true);
|
|
|
|
|
templeConfig.setRzType(RZ.L2);
|
|
|
|
|
//templeConfig.setDeep(1);
|
|
|
|
|
//templeConfig.setStudyPoint(0.05);
|
|
|
|
|
// templeConfig.setHiddenNerveNub(6);
|
|
|
|
|
templeConfig.setlParam(0.015);//0.015
|
|
|
|
|
templeConfig.init(StudyPattern.Accuracy_Pattern, true, 640, 640, 4);
|
|
|
|
|
// ModelParameter modelParameter2 = JSON.parseObject(ModelData.DATA3, ModelParameter.class);
|
|
|
|
|
// templeConfig.insertModel(modelParameter2);
|
|
|
|
|
ModelParameter modelParameter2 = JSON.parseObject(ModelData.DATA3, ModelParameter.class);
|
|
|
|
|
templeConfig.insertModel(modelParameter2);
|
|
|
|
|
Operation operation = new Operation(templeConfig);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 一阶段
|
|
|
|
|
for (int j = 0; j < 1; j++) {
|
|
|
|
|
for (int i = 1; i < 1500; i++) {//一阶段
|
|
|
|
|
System.out.println("study1===================" + i);
|
|
|
|
|
//读取本地URL地址图片,并转化成矩阵
|
|
|
|
|
Matrix a = picture.getImageMatrixByLocal("D:\\share\\picture/a" + i + ".jpg");
|
|
|
|
|
Matrix b = picture.getImageMatrixByLocal("D:\\share\\picture/b" + i + ".jpg");
|
|
|
|
|
Matrix c = picture.getImageMatrixByLocal("D:\\share\\picture/c" + i + ".jpg");
|
|
|
|
|
Matrix d = picture.getImageMatrixByLocal("D:\\share\\picture/d" + i + ".jpg");
|
|
|
|
|
//将图像矩阵和标注加入进行学习,Accuracy_Pattern 模式 进行第二次学习
|
|
|
|
|
//第二次学习的时候,第三个参数必须是 true
|
|
|
|
|
operation.learning(a, 1, false);
|
|
|
|
|
operation.learning(b, 2, false);
|
|
|
|
|
operation.learning(c, 3, false);
|
|
|
|
|
operation.learning(d, 4, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// for (int j = 0; j < 1; j++) {
|
|
|
|
|
// for (int i = 1; i < 1500; i++) {//一阶段
|
|
|
|
|
// System.out.println("study1===================" + i);
|
|
|
|
|
// //读取本地URL地址图片,并转化成矩阵
|
|
|
|
|
// Matrix a = picture.getImageMatrixByLocal("D:\\share\\picture/a" + i + ".jpg");
|
|
|
|
|
// Matrix b = picture.getImageMatrixByLocal("D:\\share\\picture/b" + i + ".jpg");
|
|
|
|
|
// Matrix c = picture.getImageMatrixByLocal("D:\\share\\picture/c" + i + ".jpg");
|
|
|
|
|
// Matrix d = picture.getImageMatrixByLocal("D:\\share\\picture/d" + i + ".jpg");
|
|
|
|
|
// //将图像矩阵和标注加入进行学习,Accuracy_Pattern 模式 进行第二次学习
|
|
|
|
|
// //第二次学习的时候,第三个参数必须是 true
|
|
|
|
|
// operation.learning(a, 1, false);
|
|
|
|
|
// operation.learning(b, 2, false);
|
|
|
|
|
// operation.learning(c, 3, false);
|
|
|
|
|
// operation.learning(d, 4, false);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// //二阶段
|
|
|
|
|
// for (int i = 1; i < 1500; i++) {
|
|
|
|
|
// System.out.println("avg==" + i);
|
|
|
|
|
// Matrix a = picture.getImageMatrixByLocal("D:\\share\\picture/a" + i + ".jpg");
|
|
|
|
|
// Matrix b = picture.getImageMatrixByLocal("D:\\share\\picture/b" + i + ".jpg");
|
|
|
|
|
// Matrix c = picture.getImageMatrixByLocal("D:\\share\\picture/c" + i + ".jpg");
|
|
|
|
|
// Matrix d = picture.getImageMatrixByLocal("D:\\share\\picture/d" + i + ".jpg");
|
|
|
|
|
// operation.normalization(a, templeConfig.getConvolutionNerveManager());
|
|
|
|
|
// operation.normalization(b, templeConfig.getConvolutionNerveManager());
|
|
|
|
|
// operation.normalization(c, templeConfig.getConvolutionNerveManager());
|
|
|
|
|
// operation.normalization(d, templeConfig.getConvolutionNerveManager());
|
|
|
|
|
// }
|
|
|
|
|
// templeConfig.getNormalization().avg();
|
|
|
|
|
// templeConfig.finishStudy();//结束学习
|
|
|
|
|
// ModelParameter modelParameter = templeConfig.getModel();
|
|
|
|
|
// String model = JSON.toJSONString(modelParameter);
|
|
|
|
|
// System.out.println(model);
|
|
|
|
|
// System.out.println("AAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
|
|
|
|
|
|
|
|
|
|
//二阶段
|
|
|
|
|
for (int i = 1; i < 1500; i++) {
|
|
|
|
|
System.out.println("avg==" + i);
|
|
|
|
|
Matrix a = picture.getImageMatrixByLocal("D:\\share\\picture/a" + i + ".jpg");
|
|
|
|
|
Matrix b = picture.getImageMatrixByLocal("D:\\share\\picture/b" + i + ".jpg");
|
|
|
|
|
Matrix c = picture.getImageMatrixByLocal("D:\\share\\picture/c" + i + ".jpg");
|
|
|
|
|
Matrix d = picture.getImageMatrixByLocal("D:\\share\\picture/d" + i + ".jpg");
|
|
|
|
|
operation.normalization(a, templeConfig.getConvolutionNerveManager());
|
|
|
|
|
operation.normalization(b, templeConfig.getConvolutionNerveManager());
|
|
|
|
|
operation.normalization(c, templeConfig.getConvolutionNerveManager());
|
|
|
|
|
operation.normalization(d, templeConfig.getConvolutionNerveManager());
|
|
|
|
|
}
|
|
|
|
|
templeConfig.getNormalization().avg();
|
|
|
|
|
for (int j = 0; j < 1; j++) {
|
|
|
|
|
|
|
|
|
|
for (int j = 0; j < 2; j++) {
|
|
|
|
|
for (int i = 1; i < 1500; i++) {
|
|
|
|
|
System.out.println("j==" + j + ",study2==================" + i);
|
|
|
|
|
//读取本地URL地址图片,并转化成矩阵
|
|
|
|
@ -77,15 +93,6 @@ public class FoodTest {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
templeConfig.finishStudy();//结束学习
|
|
|
|
|
ModelParameter modelParameter = templeConfig.getModel();
|
|
|
|
|
String model = JSON.toJSONString(modelParameter);
|
|
|
|
|
System.out.println(model);
|
|
|
|
|
// ModelParameter modelParameter2 = JSON.parseObject(model, ModelParameter.class);
|
|
|
|
|
// TempleConfig templeConfig2 = new TempleConfig(false);
|
|
|
|
|
// templeConfig2.init(StudyPattern.Accuracy_Pattern, true, 1000, 1000, 2);
|
|
|
|
|
// templeConfig2.insertModel(modelParameter2);
|
|
|
|
|
|
|
|
|
|
// Operation operation2 = new Operation(templeConfig2);
|
|
|
|
|
int wrong = 0;
|
|
|
|
|
int allNub = 0;
|
|
|
|
|
for (int i = 1500; i <= 1600; i++) {
|
|
|
|
@ -124,7 +131,11 @@ public class FoodTest {
|
|
|
|
|
}
|
|
|
|
|
double wrongPoint = ArithUtil.div(wrong, allNub);
|
|
|
|
|
System.out.println("错误率1:" + (wrongPoint * 100) + "%");
|
|
|
|
|
ModelParameter modelParameter = templeConfig.getModel();
|
|
|
|
|
String model = JSON.toJSONString(modelParameter);
|
|
|
|
|
System.out.println(model);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void test1() throws Exception {//覆盖率计算
|
|
|
|
|
Picture picture = new Picture();
|
|
|
|
|
TempleConfig templeConfig = new TempleConfig(false, true);
|
|
|
|
|