parent
f6dc51c287
commit
7dd91c9310
@ -0,0 +1,24 @@
|
||||
package org.example;
|
||||
|
||||
import org.python.core.PyFunction;
|
||||
import org.python.core.PyObject;
|
||||
import org.python.core.PyString;
|
||||
import org.python.util.PythonInterpreter;
|
||||
|
||||
import javax.imageio.IIOException;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.example.runmodel.*;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) throws IOException {
|
||||
String dir_pic = "E:\\Git project\\medicine\\src\\medicine\\springboot\\src\\main\\resources\\upload\\cancerpictures";
|
||||
String res = runmodel.get_percent(dir_pic);
|
||||
System.out.println(res);
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package org.example;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
public class runmodel {
|
||||
|
||||
public static String get_percent(String dir_pic) throws IOException {
|
||||
// 自行设置相对路径即可
|
||||
String dir_model = "test_model/src/main/java/org/example/model";
|
||||
String py_dir = "test_model/src/main/java/org/example/python/output_result.py";
|
||||
|
||||
/**
|
||||
* py_dir output_result文件所在位置
|
||||
* dir_pic 图片位置
|
||||
* dir_model 模型的位置
|
||||
*/
|
||||
String[] path = new String[]{"python " , py_dir , dir_pic , dir_model};
|
||||
Process proc = Runtime.getRuntime().exec(path);
|
||||
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
|
||||
String line = null;
|
||||
String temp = null;
|
||||
while ((line = in.readLine()) != null) temp = line;
|
||||
assert temp != null;
|
||||
String[] t = temp.split(",");
|
||||
return "良性:" + t[0] + " 恶性:" + t[1];
|
||||
}
|
||||
}
|
Loading…
Reference in new issue