[JAVA] Code style check added (#1984)
This commit is contained in:
parent
40fd1858a2
commit
53c03db307
33
.github/workflows/code_style.yml
vendored
33
.github/workflows/code_style.yml
vendored
@ -31,10 +31,37 @@ jobs:
|
|||||||
if: failure()
|
if: failure()
|
||||||
run: |
|
run: |
|
||||||
ngraph/maint/apply-code-format.sh
|
ngraph/maint/apply-code-format.sh
|
||||||
git diff >code_style_diff.patch
|
git diff >ngraph_code_style_diff.patch
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v2
|
- uses: actions/upload-artifact@v2
|
||||||
if: failure()
|
if: failure()
|
||||||
with:
|
with:
|
||||||
name: code_style_diff
|
name: ngraph_code_style_diff
|
||||||
path: code_style_diff.patch
|
path: ngraph_code_style_diff.patch
|
||||||
|
|
||||||
|
Java:
|
||||||
|
runs-on: ubuntu-18.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-java@v1
|
||||||
|
with:
|
||||||
|
java-version: '11'
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
wget -nc https://github.com/google/google-java-format/releases/download/google-java-format-1.9/google-java-format-1.9-all-deps.jar
|
||||||
|
|
||||||
|
- name: Check code style
|
||||||
|
run: |
|
||||||
|
java -jar google-java-format-1.9-all-deps.jar --set-exit-if-changed -a -i $(find . -type f -name "*.java")
|
||||||
|
|
||||||
|
- name: Create code style diff
|
||||||
|
if: failure()
|
||||||
|
run: |
|
||||||
|
git diff >java_code_style_diff.patch
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v2
|
||||||
|
if: failure()
|
||||||
|
with:
|
||||||
|
name: java_code_style_diff
|
||||||
|
path: java_code_style_diff.patch
|
||||||
|
@ -11,7 +11,7 @@ public class Blob extends IEWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Blob(TensorDesc tensorDesc, byte[] data) {
|
public Blob(TensorDesc tensorDesc, byte[] data) {
|
||||||
super(BlobByte(tensorDesc.getNativeObjAddr(), data)) ;
|
super(BlobByte(tensorDesc.getNativeObjAddr(), data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Blob(TensorDesc tensorDesc, float[] data) {
|
public Blob(TensorDesc tensorDesc, float[] data) {
|
||||||
@ -22,7 +22,7 @@ public class Blob extends IEWrapper {
|
|||||||
super(BlobCArray(tensorDesc.nativeObj, cArray));
|
super(BlobCArray(tensorDesc.nativeObj, cArray));
|
||||||
}
|
}
|
||||||
|
|
||||||
public TensorDesc getTensorDesc(){
|
public TensorDesc getTensorDesc() {
|
||||||
return new TensorDesc(GetTensorDesc(nativeObj));
|
return new TensorDesc(GetTensorDesc(nativeObj));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,11 +8,11 @@ public class CNNNetwork extends IEWrapper {
|
|||||||
super(addr);
|
super(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName(){
|
public String getName() {
|
||||||
return getName(nativeObj);
|
return getName(nativeObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getBatchSize(){
|
public int getBatchSize() {
|
||||||
return getBatchSize(nativeObj);
|
return getBatchSize(nativeObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ public class CNNNetwork extends IEWrapper {
|
|||||||
return GetOutputsInfo(nativeObj);
|
return GetOutputsInfo(nativeObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, InputInfo> getInputsInfo(){
|
public Map<String, InputInfo> getInputsInfo() {
|
||||||
return GetInputsInfo(nativeObj);
|
return GetInputsInfo(nativeObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ public class CNNNetwork extends IEWrapper {
|
|||||||
reshape(nativeObj, inputShapes);
|
reshape(nativeObj, inputShapes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, int[]> getInputShapes(){
|
public Map<String, int[]> getInputShapes() {
|
||||||
return getInputShapes(nativeObj);
|
return getInputShapes(nativeObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ public class CNNNetwork extends IEWrapper {
|
|||||||
private static native int getBatchSize(long addr);
|
private static native int getBatchSize(long addr);
|
||||||
|
|
||||||
private static native Map<String, InputInfo> GetInputsInfo(long addr);
|
private static native Map<String, InputInfo> GetInputsInfo(long addr);
|
||||||
|
|
||||||
private static native Map<String, Data> GetOutputsInfo(long addr);
|
private static native Map<String, Data> GetOutputsInfo(long addr);
|
||||||
|
|
||||||
private static native void reshape(long addr, Map<String, int[]> inputShapes);
|
private static native void reshape(long addr, Map<String, int[]> inputShapes);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package org.intel.openvino;
|
package org.intel.openvino;
|
||||||
|
|
||||||
public class Data extends IEWrapper{
|
public class Data extends IEWrapper {
|
||||||
|
|
||||||
protected Data(long addr) {
|
protected Data(long addr) {
|
||||||
super(addr);
|
super(addr);
|
||||||
|
@ -25,8 +25,10 @@ public class IECore extends IEWrapper {
|
|||||||
return new ExecutableNetwork(LoadNetwork(nativeObj, net.getNativeObjAddr(), device));
|
return new ExecutableNetwork(LoadNetwork(nativeObj, net.getNativeObjAddr(), device));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExecutableNetwork LoadNetwork(CNNNetwork net, final String device, final Map<String, String> config) {
|
public ExecutableNetwork LoadNetwork(
|
||||||
return new ExecutableNetwork(LoadNetwork1(nativeObj, net.getNativeObjAddr(), device, config));
|
CNNNetwork net, final String device, final Map<String, String> config) {
|
||||||
|
long network = LoadNetwork1(nativeObj, net.getNativeObjAddr(), device, config);
|
||||||
|
return new ExecutableNetwork(network);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RegisterPlugin(String pluginName, String deviceName) {
|
public void RegisterPlugin(String pluginName, String deviceName) {
|
||||||
@ -64,11 +66,13 @@ public class IECore extends IEWrapper {
|
|||||||
/*----------------------------------- native methods -----------------------------------*/
|
/*----------------------------------- native methods -----------------------------------*/
|
||||||
private static native long ReadNetwork(long core, final String modelFileName);
|
private static native long ReadNetwork(long core, final String modelFileName);
|
||||||
|
|
||||||
private static native long ReadNetwork1(long core, final String modelPath, final String weightPath);
|
private static native long ReadNetwork1(
|
||||||
|
long core, final String modelPath, final String weightPath);
|
||||||
|
|
||||||
private static native long LoadNetwork(long core, long net, final String device);
|
private static native long LoadNetwork(long core, long net, final String device);
|
||||||
|
|
||||||
private static native long LoadNetwork1(long core, long net, final String device, final Map<String, String> config);
|
private static native long LoadNetwork1(
|
||||||
|
long core, long net, final String device, final Map<String, String> config);
|
||||||
|
|
||||||
private static native void RegisterPlugin(long core, String pluginName, String deviceName);
|
private static native void RegisterPlugin(long core, String pluginName, String deviceName);
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ package org.intel.openvino;
|
|||||||
public class IEWrapper {
|
public class IEWrapper {
|
||||||
protected final long nativeObj;
|
protected final long nativeObj;
|
||||||
|
|
||||||
protected IEWrapper(long addr){
|
protected IEWrapper(long addr) {
|
||||||
nativeObj = addr;
|
nativeObj = addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,13 +28,13 @@ public class InferRequest extends IEWrapper {
|
|||||||
return StatusCode.valueOf(Wait(nativeObj, waitMode.getValue()));
|
return StatusCode.valueOf(Wait(nativeObj, waitMode.getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetCompletionCallback(Runnable runnable){
|
public void SetCompletionCallback(Runnable runnable) {
|
||||||
SetCompletionCallback(nativeObj, runnable);
|
SetCompletionCallback(nativeObj, runnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, InferenceEngineProfileInfo> GetPerformanceCounts() {
|
public Map<String, InferenceEngineProfileInfo> GetPerformanceCounts() {
|
||||||
return GetPerformanceCounts(nativeObj);
|
return GetPerformanceCounts(nativeObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------- native methods -----------------------------------*/
|
/*----------------------------------- native methods -----------------------------------*/
|
||||||
private static native void Infer(long addr);
|
private static native void Infer(long addr);
|
||||||
|
@ -5,27 +5,27 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class InferenceEngineProfileInfo {
|
public class InferenceEngineProfileInfo {
|
||||||
public enum LayerStatus {
|
public enum LayerStatus {
|
||||||
NOT_RUN(0),
|
NOT_RUN(0),
|
||||||
OPTIMIZED_OUT(1),
|
OPTIMIZED_OUT(1),
|
||||||
EXECUTED(2);
|
EXECUTED(2);
|
||||||
|
|
||||||
private int value;
|
private int value;
|
||||||
private static Map<Integer, LayerStatus> map = new HashMap<Integer, LayerStatus>();
|
private static Map<Integer, LayerStatus> map = new HashMap<Integer, LayerStatus>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
for (LayerStatus layerStatus : LayerStatus.values()) {
|
for (LayerStatus layerStatus : LayerStatus.values()) {
|
||||||
map.put(layerStatus.value, layerStatus);
|
map.put(layerStatus.value, layerStatus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LayerStatus(int value) {
|
LayerStatus(int value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getValue() {
|
int getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static LayerStatus valueOf(int value) {
|
static LayerStatus valueOf(int value) {
|
||||||
return map.get(value);
|
return map.get(value);
|
||||||
}
|
}
|
||||||
@ -38,7 +38,13 @@ public class InferenceEngineProfileInfo {
|
|||||||
public String layerType;
|
public String layerType;
|
||||||
public int executionIndex;
|
public int executionIndex;
|
||||||
|
|
||||||
public InferenceEngineProfileInfo(LayerStatus status, long realTimeUSec, long cpuUSec, String execType, String layerType, int executionIndex) {
|
public InferenceEngineProfileInfo(
|
||||||
|
LayerStatus status,
|
||||||
|
long realTimeUSec,
|
||||||
|
long cpuUSec,
|
||||||
|
String execType,
|
||||||
|
String layerType,
|
||||||
|
int executionIndex) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
this.realTimeUSec = realTimeUSec;
|
this.realTimeUSec = realTimeUSec;
|
||||||
this.cpuUSec = cpuUSec;
|
this.cpuUSec = cpuUSec;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package org.intel.openvino;
|
package org.intel.openvino;
|
||||||
|
|
||||||
public class InputInfo extends IEWrapper{
|
public class InputInfo extends IEWrapper {
|
||||||
|
|
||||||
public InputInfo(long addr) {
|
public InputInfo(long addr) {
|
||||||
super(addr);
|
super(addr);
|
||||||
@ -14,7 +14,7 @@ public class InputInfo extends IEWrapper{
|
|||||||
SetLayout(nativeObj, layout.getValue());
|
SetLayout(nativeObj, layout.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Layout getLayout(){
|
public Layout getLayout() {
|
||||||
return Layout.valueOf(getLayout(nativeObj));
|
return Layout.valueOf(getLayout(nativeObj));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,11 +22,11 @@ public class InputInfo extends IEWrapper{
|
|||||||
SetPrecision(nativeObj, precision.getValue());
|
SetPrecision(nativeObj, precision.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Precision getPrecision(){
|
public Precision getPrecision() {
|
||||||
return Precision.valueOf(getPrecision(nativeObj));
|
return Precision.valueOf(getPrecision(nativeObj));
|
||||||
}
|
}
|
||||||
|
|
||||||
public TensorDesc getTensorDesc(){
|
public TensorDesc getTensorDesc() {
|
||||||
return new TensorDesc(GetTensorDesc(nativeObj));
|
return new TensorDesc(GetTensorDesc(nativeObj));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,4 +20,4 @@ public class Parameter extends IEWrapper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected native void delete(long nativeObj);
|
protected native void delete(long nativeObj);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package org.intel.openvino;
|
package org.intel.openvino;
|
||||||
|
|
||||||
public class PreProcessInfo extends IEWrapper{
|
public class PreProcessInfo extends IEWrapper {
|
||||||
|
|
||||||
public PreProcessInfo(long addr) {
|
public PreProcessInfo(long addr) {
|
||||||
super(addr);
|
super(addr);
|
||||||
|
@ -5,17 +5,17 @@ import java.util.Map;
|
|||||||
|
|
||||||
public enum Precision {
|
public enum Precision {
|
||||||
UNSPECIFIED(255),
|
UNSPECIFIED(255),
|
||||||
MIXED(0),
|
MIXED(0),
|
||||||
FP32(10),
|
FP32(10),
|
||||||
FP16(11),
|
FP16(11),
|
||||||
Q78(20),
|
Q78(20),
|
||||||
I16(30),
|
I16(30),
|
||||||
U8(40),
|
U8(40),
|
||||||
I8(50),
|
I8(50),
|
||||||
U16(60),
|
U16(60),
|
||||||
I32(70),
|
I32(70),
|
||||||
I64(72),
|
I64(72),
|
||||||
BIN(71),
|
BIN(71),
|
||||||
CUSTOM(80);
|
CUSTOM(80);
|
||||||
|
|
||||||
private int value;
|
private int value;
|
||||||
@ -39,4 +39,3 @@ public enum Precision {
|
|||||||
return map.get(value);
|
return map.get(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,7 +1,9 @@
|
|||||||
package org.intel.openvino;
|
package org.intel.openvino;
|
||||||
|
|
||||||
public enum ResizeAlgorithm {
|
public enum ResizeAlgorithm {
|
||||||
NO_RESIZE(0), RESIZE_BILINEAR(1), RESIZE_AREA(2);
|
NO_RESIZE(0),
|
||||||
|
RESIZE_BILINEAR(1),
|
||||||
|
RESIZE_AREA(2);
|
||||||
|
|
||||||
private int value;
|
private int value;
|
||||||
|
|
||||||
|
@ -1,12 +1,21 @@
|
|||||||
package org.intel.openvino;
|
package org.intel.openvino;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public enum StatusCode {
|
public enum StatusCode {
|
||||||
OK(0), GENERAL_ERROR(-1), NOT_IMPLEMENTED(-2), NETWORK_NOT_LOADED(-3),
|
OK(0),
|
||||||
PARAMETER_MISMATCH(-4), NOT_FOUND(-5), OUT_OF_BOUNDS(-6), UNEXPECTED(-7),
|
GENERAL_ERROR(-1),
|
||||||
REQUEST_BUSY(-8), RESULT_NOT_READY(-9), NOT_ALLOCATED(-10), INFER_NOT_STARTED(-11),
|
NOT_IMPLEMENTED(-2),
|
||||||
|
NETWORK_NOT_LOADED(-3),
|
||||||
|
PARAMETER_MISMATCH(-4),
|
||||||
|
NOT_FOUND(-5),
|
||||||
|
OUT_OF_BOUNDS(-6),
|
||||||
|
UNEXPECTED(-7),
|
||||||
|
REQUEST_BUSY(-8),
|
||||||
|
RESULT_NOT_READY(-9),
|
||||||
|
NOT_ALLOCATED(-10),
|
||||||
|
INFER_NOT_STARTED(-11),
|
||||||
NETWORK_NOT_READ(-12);
|
NETWORK_NOT_READ(-12);
|
||||||
|
|
||||||
private int value;
|
private int value;
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
package org.intel.openvino;
|
package org.intel.openvino;
|
||||||
|
|
||||||
import java.util.concurrent.BlockingDeque;
|
|
||||||
|
|
||||||
public class TensorDesc extends IEWrapper {
|
public class TensorDesc extends IEWrapper {
|
||||||
|
|
||||||
public TensorDesc(long addr){
|
public TensorDesc(long addr) {
|
||||||
super(addr);
|
super(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TensorDesc(Precision precision, int[] dims, Layout layout) {
|
public TensorDesc(Precision precision, int[] dims, Layout layout) {
|
||||||
@ -16,11 +14,11 @@ public class TensorDesc extends IEWrapper {
|
|||||||
return GetDims(nativeObj);
|
return GetDims(nativeObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Layout getLayout(){
|
public Layout getLayout() {
|
||||||
return Layout.valueOf(getLayout(nativeObj));
|
return Layout.valueOf(getLayout(nativeObj));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Precision getPrecision(){
|
public Precision getPrecision() {
|
||||||
return Precision.valueOf(getPrecision(nativeObj));
|
return Precision.valueOf(getPrecision(nativeObj));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package org.intel.openvino;
|
package org.intel.openvino;
|
||||||
|
|
||||||
public enum WaitMode {
|
public enum WaitMode {
|
||||||
RESULT_READY(-1), STATUS_ONLY(0);
|
RESULT_READY(-1),
|
||||||
|
STATUS_ONLY(0);
|
||||||
|
|
||||||
private int value;
|
private int value;
|
||||||
|
|
||||||
@ -12,4 +13,4 @@ public enum WaitMode {
|
|||||||
public int getValue() {
|
public int getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import java.util.Map;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class ArgumentParser {
|
public class ArgumentParser {
|
||||||
private Map<String, String> input;
|
private Map<String, String> input;
|
||||||
@ -25,8 +25,8 @@ public class ArgumentParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void parseArgs(String[] args) {
|
public void parseArgs(String[] args) {
|
||||||
try{
|
try {
|
||||||
for(int i = 0; i < args.length; i++) {
|
for (int i = 0; i < args.length; i++) {
|
||||||
String arg = args[i];
|
String arg = args[i];
|
||||||
if (arg.equals("--help") | arg.equals("-h")) {
|
if (arg.equals("--help") | arg.equals("-h")) {
|
||||||
printHelp();
|
printHelp();
|
||||||
@ -40,7 +40,7 @@ public class ArgumentParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(ArrayIndexOutOfBoundsException e) {
|
} catch (ArrayIndexOutOfBoundsException e) {
|
||||||
System.out.println("Error: Incorrect number of arguments");
|
System.out.println("Error: Incorrect number of arguments");
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
@ -61,10 +61,7 @@ https://download.01.org/opencv/2019/open_model_zoo/R1/models_bin/face-detection-
|
|||||||
|
|
||||||
## Build and run
|
## Build and run
|
||||||
|
|
||||||
Build and run steps are similar to ```benchmark_app```, but you need to add OpenCV path.
|
Build and run steps are similar to ```benchmark_app```, but you need to add an environment variable with OpenCV installation or build path before building:
|
||||||
|
|
||||||
### Build
|
|
||||||
Add an environment variable with OpenCV installation or build path:
|
|
||||||
```bash
|
```bash
|
||||||
export OpenCV_DIR=/path/to/opencv/
|
export OpenCV_DIR=/path/to/opencv/
|
||||||
```
|
```
|
||||||
|
@ -1,21 +1,22 @@
|
|||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.intel.openvino.*;
|
import org.intel.openvino.*;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class InferReqWrap {
|
public class InferReqWrap {
|
||||||
|
|
||||||
public InferReqWrap(ExecutableNetwork net, int id, InferRequestsQueue irQueue) {
|
public InferReqWrap(ExecutableNetwork net, int id, InferRequestsQueue irQueue) {
|
||||||
request = net.CreateInferRequest();
|
request = net.CreateInferRequest();
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.irQueue = irQueue;
|
this.irQueue = irQueue;
|
||||||
request.SetCompletionCallback(new Runnable() {
|
request.SetCompletionCallback(
|
||||||
|
new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
endTime = System.nanoTime();
|
endTime = System.nanoTime();
|
||||||
irQueue.putIdleRequest(id, getExecutionTimeInMilliseconds());
|
irQueue.putIdleRequest(id, getExecutionTimeInMilliseconds());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void startAsync() {
|
void startAsync() {
|
||||||
@ -43,9 +44,9 @@ public class InferReqWrap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
double getExecutionTimeInMilliseconds() {
|
double getExecutionTimeInMilliseconds() {
|
||||||
return (double)(endTime - startTime) * 1e-6;
|
return (double) (endTime - startTime) * 1e-6;
|
||||||
}
|
}
|
||||||
|
|
||||||
InferRequest request;
|
InferRequest request;
|
||||||
private InferRequestsQueue irQueue;
|
private InferRequestsQueue irQueue;
|
||||||
private long startTime;
|
private long startTime;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
|
import org.intel.openvino.*;
|
||||||
|
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
|
|
||||||
import org.intel.openvino.*;
|
|
||||||
|
|
||||||
public class InferRequestsQueue {
|
public class InferRequestsQueue {
|
||||||
public InferRequestsQueue(ExecutableNetwork net, int nireq) {
|
public InferRequestsQueue(ExecutableNetwork net, int nireq) {
|
||||||
for (int id = 0; id < nireq; id++) {
|
for (int id = 0; id < nireq; id++) {
|
||||||
@ -12,17 +12,17 @@ public class InferRequestsQueue {
|
|||||||
}
|
}
|
||||||
resetTimes();
|
resetTimes();
|
||||||
}
|
}
|
||||||
|
|
||||||
void resetTimes() {
|
void resetTimes() {
|
||||||
startTime = Long.MAX_VALUE;
|
startTime = Long.MAX_VALUE;
|
||||||
endTime = Long.MIN_VALUE;
|
endTime = Long.MIN_VALUE;
|
||||||
latencies.clear();
|
latencies.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
double getDurationInMilliseconds() {
|
double getDurationInMilliseconds() {
|
||||||
return (double)(endTime - startTime) * 1e-6;
|
return (double) (endTime - startTime) * 1e-6;
|
||||||
}
|
}
|
||||||
|
|
||||||
void putIdleRequest(int id, double latency) {
|
void putIdleRequest(int id, double latency) {
|
||||||
latencies.add(latency);
|
latencies.add(latency);
|
||||||
idleIds.add(id);
|
idleIds.add(id);
|
||||||
@ -32,7 +32,7 @@ public class InferRequestsQueue {
|
|||||||
foo.notify();
|
foo.notify();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
InferReqWrap getIdleRequest() {
|
InferReqWrap getIdleRequest() {
|
||||||
try {
|
try {
|
||||||
InferReqWrap request = requests.get(idleIds.take());
|
InferReqWrap request = requests.get(idleIds.take());
|
||||||
@ -43,11 +43,11 @@ public class InferRequestsQueue {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void waitAll() {
|
void waitAll() {
|
||||||
synchronized (foo) {
|
synchronized (foo) {
|
||||||
try {
|
try {
|
||||||
while(idleIds.size() != requests.size()) {
|
while (idleIds.size() != requests.size()) {
|
||||||
foo.wait();
|
foo.wait();
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
@ -55,16 +55,16 @@ public class InferRequestsQueue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<Double> getLatencies() {
|
Vector<Double> getLatencies() {
|
||||||
return latencies;
|
return latencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<InferReqWrap> requests = new Vector<InferReqWrap>();
|
Vector<InferReqWrap> requests = new Vector<InferReqWrap>();
|
||||||
private BlockingQueue<Integer> idleIds = new LinkedBlockingQueue<Integer>();
|
private BlockingQueue<Integer> idleIds = new LinkedBlockingQueue<Integer>();
|
||||||
private long startTime;
|
private long startTime;
|
||||||
private long endTime;
|
private long endTime;
|
||||||
Vector<Double> latencies = new Vector<Double>();
|
Vector<Double> latencies = new Vector<Double>();
|
||||||
|
|
||||||
Object foo = new Object();
|
Object foo = new Object();
|
||||||
}
|
}
|
||||||
|
@ -1,28 +1,26 @@
|
|||||||
import java.util.Map;
|
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
import javax.management.RuntimeErrorException;
|
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import org.intel.openvino.*;
|
import org.intel.openvino.*;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
static boolean adjustShapesBatch(Map<String, int[]> shapes, int batchSize, Map<String, InputInfo> inputInfo) {
|
static boolean adjustShapesBatch(
|
||||||
|
Map<String, int[]> shapes, int batchSize, Map<String, InputInfo> inputInfo) {
|
||||||
boolean updated = false;
|
boolean updated = false;
|
||||||
|
|
||||||
for (Map.Entry<String, InputInfo> entry : inputInfo.entrySet()) {
|
for (Map.Entry<String, InputInfo> entry : inputInfo.entrySet()) {
|
||||||
Layout layout = entry.getValue().getTensorDesc().getLayout();
|
Layout layout = entry.getValue().getTensorDesc().getLayout();
|
||||||
int batchIndex = -1;
|
int batchIndex = -1;
|
||||||
if ((layout == Layout.NCHW) || (layout == Layout.NCDHW) ||
|
if ((layout == Layout.NCHW)
|
||||||
(layout == Layout.NHWC) || (layout == Layout.NDHWC) ||
|
|| (layout == Layout.NCDHW)
|
||||||
(layout == Layout.NC)) {
|
|| (layout == Layout.NHWC)
|
||||||
|
|| (layout == Layout.NDHWC)
|
||||||
|
|| (layout == Layout.NC)) {
|
||||||
batchIndex = 0;
|
batchIndex = 0;
|
||||||
} else if (layout == Layout.CN) {
|
} else if (layout == Layout.CN) {
|
||||||
batchIndex = 1;
|
batchIndex = 1;
|
||||||
@ -35,28 +33,42 @@ public class Main {
|
|||||||
return updated;
|
return updated;
|
||||||
}
|
}
|
||||||
|
|
||||||
static String setThroughputStreams(IECore core, Map<String, String> device_config, String device, int nstreams, boolean isAsync) {
|
static String setThroughputStreams(
|
||||||
|
IECore core,
|
||||||
|
Map<String, String> device_config,
|
||||||
|
String device,
|
||||||
|
int nstreams,
|
||||||
|
boolean isAsync) {
|
||||||
String key = device + "_THROUGHPUT_STREAMS";
|
String key = device + "_THROUGHPUT_STREAMS";
|
||||||
if (nstreams > 0) {
|
if (nstreams > 0) {
|
||||||
device_config.put(key, Integer.toString(nstreams));
|
device_config.put(key, Integer.toString(nstreams));
|
||||||
} else if (!device_config.containsKey(key) && isAsync) {
|
} else if (!device_config.containsKey(key) && isAsync) {
|
||||||
System.err.println("[ WARNING ] -nstreams default value is determined automatically for " + device + " device. " +
|
System.err.println(
|
||||||
"Although the automatic selection usually provides a reasonable performance," +
|
"[ WARNING ] -nstreams default value is determined automatically for "
|
||||||
"but it still may be non-optimal for some cases, for more information look at README.");
|
+ device
|
||||||
|
+ " device. Although the automatic selection usually provides a"
|
||||||
|
+ " reasonable performance,but it still may be non-optimal for some"
|
||||||
|
+ " cases, for more information look at README.");
|
||||||
device_config.put(key, device + "_THROUGHPUT_AUTO");
|
device_config.put(key, device + "_THROUGHPUT_AUTO");
|
||||||
}
|
}
|
||||||
return device_config.get(key);
|
return device_config.get(key);
|
||||||
};
|
}
|
||||||
|
|
||||||
static void fillBlobs(Vector<InferReqWrap> requests, Map<String, InputInfo> inputsInfo) {
|
static void fillBlobs(Vector<InferReqWrap> requests, Map<String, InputInfo> inputsInfo) {
|
||||||
for (Map.Entry<String, InputInfo> entry : inputsInfo.entrySet()) {
|
for (Map.Entry<String, InputInfo> entry : inputsInfo.entrySet()) {
|
||||||
String inputName = entry.getKey();
|
String inputName = entry.getKey();
|
||||||
TensorDesc tDesc = entry.getValue().getTensorDesc();
|
TensorDesc tDesc = entry.getValue().getTensorDesc();
|
||||||
|
|
||||||
System.err.print("[ INFO ] Network input '" + inputName + "' precision " + tDesc.getPrecision()
|
System.err.print(
|
||||||
+ ", dimensions (" + tDesc.getLayout() + "): ");
|
"[ INFO ] Network input '"
|
||||||
for (int dim : tDesc.getDims())
|
+ inputName
|
||||||
System.err.print(dim + " ");
|
+ "' precision "
|
||||||
|
+ tDesc.getPrecision()
|
||||||
|
+ ", dimensions ("
|
||||||
|
+ tDesc.getLayout()
|
||||||
|
+ "): ");
|
||||||
|
|
||||||
|
for (int dim : tDesc.getDims()) System.err.print(dim + " ");
|
||||||
System.err.println();
|
System.err.println();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +78,7 @@ public class Main {
|
|||||||
String inputName = entry.getKey();
|
String inputName = entry.getKey();
|
||||||
TensorDesc tDesc = entry.getValue().getTensorDesc();
|
TensorDesc tDesc = entry.getValue().getTensorDesc();
|
||||||
request.SetBlob(inputName, blobRandomByte(tDesc));
|
request.SetBlob(inputName, blobRandomByte(tDesc));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +86,7 @@ public class Main {
|
|||||||
int dims[] = tDesc.getDims();
|
int dims[] = tDesc.getDims();
|
||||||
|
|
||||||
int size = 1;
|
int size = 1;
|
||||||
for(int i = 0; i < dims.length; i++) {
|
for (int i = 0; i < dims.length; i++) {
|
||||||
size *= dims[i];
|
size *= dims[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,53 +99,59 @@ public class Main {
|
|||||||
|
|
||||||
static double getMedianValue(Vector<Double> vec) {
|
static double getMedianValue(Vector<Double> vec) {
|
||||||
Object[] objArr = vec.toArray();
|
Object[] objArr = vec.toArray();
|
||||||
Double[] arr = Arrays.copyOf(objArr, objArr.length, Double[].class);
|
Double[] arr = Arrays.copyOf(objArr, objArr.length, Double[].class);
|
||||||
|
|
||||||
Arrays.sort(arr);
|
Arrays.sort(arr);
|
||||||
|
|
||||||
if (arr.length % 2 == 0)
|
if (arr.length % 2 == 0)
|
||||||
return ((double)arr[arr.length / 2] + (double)arr[arr.length / 2 - 1]) / 2;
|
return ((double) arr[arr.length / 2] + (double) arr[arr.length / 2 - 1]) / 2;
|
||||||
else
|
else return (double) arr[arr.length / 2];
|
||||||
return (double)arr[arr.length / 2];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean getApiBoolean(String api) throws RuntimeException {
|
static boolean getApiBoolean(String api) throws RuntimeException {
|
||||||
if(api.equals("sync"))
|
if (api.equals("sync")) return false;
|
||||||
return false;
|
else if (api.equals("async")) return true;
|
||||||
else if(api.equals("async"))
|
|
||||||
return true;
|
|
||||||
else throw new RuntimeException("Incorrect argument: '-api'");
|
else throw new RuntimeException("Incorrect argument: '-api'");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int step = 0;
|
static int step = 0;
|
||||||
static void nextStep(String stepInfo) {
|
|
||||||
|
static void nextStep(String stepInfo) {
|
||||||
step += 1;
|
step += 1;
|
||||||
System.out.println("[Step " + step + "/11] " + stepInfo);
|
System.out.println("[Step " + step + "/11] " + stepInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int deviceDefaultDeviceDurationInSeconds(String device) {
|
static int deviceDefaultDeviceDurationInSeconds(String device) {
|
||||||
final Map<String, Integer> deviceDefaultDurationInSeconds = new HashMap<String, Integer>() {{
|
final Map<String, Integer> deviceDefaultDurationInSeconds =
|
||||||
put("CPU", 60 );
|
new HashMap<String, Integer>() {
|
||||||
put("GPU", 60 );
|
{
|
||||||
put("VPU", 60 );
|
put("CPU", 60);
|
||||||
put("MYRIAD", 60 );
|
put("GPU", 60);
|
||||||
put("HDDL", 60 );
|
put("VPU", 60);
|
||||||
put("FPGA", 120);
|
put("MYRIAD", 60);
|
||||||
put("UNKNOWN", 120);
|
put("HDDL", 60);
|
||||||
}};
|
put("FPGA", 120);
|
||||||
|
put("UNKNOWN", 120);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Integer duration = deviceDefaultDurationInSeconds.get(device);
|
Integer duration = deviceDefaultDurationInSeconds.get(device);
|
||||||
|
|
||||||
if (duration == null) {
|
if (duration == null) {
|
||||||
duration = deviceDefaultDurationInSeconds.get("UNKNOWN");
|
duration = deviceDefaultDurationInSeconds.get("UNKNOWN");
|
||||||
System.err.println("[ WARNING ] Default duration " + duration + " seconds for unknown device '" + device + "' is used");
|
System.err.println(
|
||||||
|
"[ WARNING ] Default duration "
|
||||||
|
+ duration
|
||||||
|
+ " seconds for unknown device '"
|
||||||
|
+ device
|
||||||
|
+ "' is used");
|
||||||
}
|
}
|
||||||
return duration;
|
return duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
static long getTotalMsTime(long startTimeMilliSec) {
|
static long getTotalMsTime(long startTimeMilliSec) {
|
||||||
return (System.currentTimeMillis() - startTimeMilliSec);
|
return (System.currentTimeMillis() - startTimeMilliSec);
|
||||||
};
|
}
|
||||||
|
|
||||||
static long getDurationInMilliseconds(int seconds) {
|
static long getDurationInMilliseconds(int seconds) {
|
||||||
return seconds * 1000L;
|
return seconds * 1000L;
|
||||||
@ -147,7 +165,7 @@ public class Main {
|
|||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------- 1. Parsing and validating input arguments ---------------------------------------------
|
// ----------------- 1. Parsing and validating input arguments -----------------
|
||||||
nextStep("Parsing and validating input arguments");
|
nextStep("Parsing and validating input arguments");
|
||||||
|
|
||||||
ArgumentParser parser = new ArgumentParser("This is benchmarking application");
|
ArgumentParser parser = new ArgumentParser("This is benchmarking application");
|
||||||
@ -169,39 +187,38 @@ public class Main {
|
|||||||
int batchSize = parser.getInteger("-b", 0);
|
int batchSize = parser.getInteger("-b", 0);
|
||||||
int nthreads = parser.getInteger("-nthreads", 0);
|
int nthreads = parser.getInteger("-nthreads", 0);
|
||||||
int nstreams = parser.getInteger("-nstreams", 0);
|
int nstreams = parser.getInteger("-nstreams", 0);
|
||||||
int timeLimit = parser.getInteger("-t",0);
|
int timeLimit = parser.getInteger("-t", 0);
|
||||||
String api = parser.get("-api", "async");
|
String api = parser.get("-api", "async");
|
||||||
boolean isAsync;
|
boolean isAsync;
|
||||||
|
|
||||||
try{
|
try {
|
||||||
isAsync = getApiBoolean(api);
|
isAsync = getApiBoolean(api);
|
||||||
} catch(RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
System.out.println(e.getMessage());
|
System.out.println(e.getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(xmlPath == null) {
|
if (xmlPath == null) {
|
||||||
System.out.println("Error: Missed argument: -m");
|
System.out.println("Error: Missed argument: -m");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------- 2. Loading the Inference Engine --------------------------------------------------------
|
// ----------------- 2. Loading the Inference Engine --------------------------
|
||||||
nextStep("Loading the Inference Engine");
|
nextStep("Loading the Inference Engine");
|
||||||
|
|
||||||
IECore core = new IECore();
|
IECore core = new IECore();
|
||||||
|
|
||||||
// ----------------- 3. Setting device configuration --------------------------------------------------------
|
// ----------------- 3. Setting device configuration --------------------------
|
||||||
nextStep("Setting device configuration");
|
nextStep("Setting device configuration");
|
||||||
|
|
||||||
Map<String, String> device_config = new HashMap<>();
|
Map<String, String> device_config = new HashMap<>();
|
||||||
|
|
||||||
if (device.equals("CPU")) { // CPU supports few special performance-oriented keys
|
if (device.equals("CPU")) { // CPU supports few special performance-oriented keys
|
||||||
// limit threading for CPU portion of inference
|
// limit threading for CPU portion of inference
|
||||||
if (nthreads > 0)
|
if (nthreads > 0) device_config.put("CPU_THREADS_NUM", Integer.toString(nthreads));
|
||||||
device_config.put("CPU_THREADS_NUM", Integer.toString(nthreads));
|
|
||||||
|
|
||||||
if (!device_config.containsKey("CPU_BIND_THREAD")) {
|
if (!device_config.containsKey("CPU_BIND_THREAD")) {
|
||||||
device_config.put("CPU_BIND_THREAD", "YES");
|
device_config.put("CPU_BIND_THREAD", "YES");
|
||||||
}
|
}
|
||||||
|
|
||||||
// for CPU execution, more throughput-oriented execution via streams
|
// for CPU execution, more throughput-oriented execution via streams
|
||||||
@ -212,15 +229,14 @@ public class Main {
|
|||||||
} else if (device.equals("MYRIAD")) {
|
} else if (device.equals("MYRIAD")) {
|
||||||
device_config.put("LOG_LEVEL", "LOG_WARNING");
|
device_config.put("LOG_LEVEL", "LOG_WARNING");
|
||||||
} else if (device.equals("GNA")) {
|
} else if (device.equals("GNA")) {
|
||||||
device_config.put("GNA_PRECISION", "I16");
|
device_config.put("GNA_PRECISION", "I16");
|
||||||
|
|
||||||
if (nthreads > 0)
|
if (nthreads > 0) device_config.put("GNA_LIB_N_THREADS", Integer.toString(nthreads));
|
||||||
device_config.put("GNA_LIB_N_THREADS", Integer.toString(nthreads));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
core.SetConfig(device_config, device);
|
core.SetConfig(device_config, device);
|
||||||
|
|
||||||
// ----------------- 4. Reading the Intermediate Representation network -------------------------------------
|
// ----------- 4. Reading the Intermediate Representation network -------------
|
||||||
nextStep("Reading the Intermediate Representation network");
|
nextStep("Reading the Intermediate Representation network");
|
||||||
|
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
@ -233,14 +249,14 @@ public class Main {
|
|||||||
String inputName = new ArrayList<String>(inputsInfo.keySet()).get(0);
|
String inputName = new ArrayList<String>(inputsInfo.keySet()).get(0);
|
||||||
InputInfo inputInfo = inputsInfo.get(inputName);
|
InputInfo inputInfo = inputsInfo.get(inputName);
|
||||||
|
|
||||||
// ----------------- 5. Resizing network to match image sizes and given batch -------------------------------
|
// ----- 5. Resizing network to match image sizes and given batch --------------
|
||||||
nextStep("Resizing network to match image sizes and given batch");
|
nextStep("Resizing network to match image sizes and given batch");
|
||||||
|
|
||||||
int inputBatchSize = batchSize;
|
int inputBatchSize = batchSize;
|
||||||
batchSize = net.getBatchSize();
|
batchSize = net.getBatchSize();
|
||||||
|
|
||||||
Map<String, int[]> shapes = net.getInputShapes();
|
Map<String, int[]> shapes = net.getInputShapes();
|
||||||
|
|
||||||
if ((inputBatchSize != 0) && (batchSize != inputBatchSize)) {
|
if ((inputBatchSize != 0) && (batchSize != inputBatchSize)) {
|
||||||
adjustShapesBatch(shapes, batchSize, inputsInfo);
|
adjustShapesBatch(shapes, batchSize, inputsInfo);
|
||||||
|
|
||||||
@ -252,15 +268,19 @@ public class Main {
|
|||||||
System.err.println("[ INFO ] Reshape network took " + durationMs + " ms");
|
System.err.println("[ INFO ] Reshape network took " + durationMs + " ms");
|
||||||
}
|
}
|
||||||
|
|
||||||
System.err.println((inputBatchSize != 0 ? "[ INFO ] Network batch size was changed to: " : "[ INFO ] Network batch size: ") + batchSize);
|
System.err.println(
|
||||||
|
(inputBatchSize != 0
|
||||||
|
? "[ INFO ] Network batch size was changed to: "
|
||||||
|
: "[ INFO ] Network batch size: ")
|
||||||
|
+ batchSize);
|
||||||
|
|
||||||
// ----------------- 6. Configuring input -------------------------------------------------------------------
|
// ----------------- 6. Configuring input -------------------------------------
|
||||||
nextStep("Configuring input");
|
nextStep("Configuring input");
|
||||||
|
|
||||||
inputInfo.getPreProcess().setResizeAlgorithm(ResizeAlgorithm.RESIZE_BILINEAR);
|
inputInfo.getPreProcess().setResizeAlgorithm(ResizeAlgorithm.RESIZE_BILINEAR);
|
||||||
inputInfo.setPrecision(Precision.U8);
|
inputInfo.setPrecision(Precision.U8);
|
||||||
|
|
||||||
// ----------------- 7. Loading the model to the device -----------------------------------------------------
|
// ----------------- 7. Loading the model to the device -----------------------
|
||||||
nextStep("Loading the model to the device");
|
nextStep("Loading the model to the device");
|
||||||
|
|
||||||
startTime = System.currentTimeMillis();
|
startTime = System.currentTimeMillis();
|
||||||
@ -269,11 +289,12 @@ public class Main {
|
|||||||
|
|
||||||
System.err.println("[ INFO ] Load network took " + durationMs + " ms");
|
System.err.println("[ INFO ] Load network took " + durationMs + " ms");
|
||||||
|
|
||||||
// ----------------- 8. Setting optimal runtime parameters --------------------------------------------------
|
// ---------------- 8. Setting optimal runtime parameters ---------------------
|
||||||
nextStep("Setting optimal runtime parameters");
|
nextStep("Setting optimal runtime parameters");
|
||||||
|
|
||||||
// Update number of streams
|
// Update number of streams
|
||||||
nstreams = Integer.parseInt(core.GetConfig(device, device + "_THROUGHPUT_STREAMS").asString());
|
String nStr = core.GetConfig(device, device + "_THROUGHPUT_STREAMS").asString();
|
||||||
|
nstreams = Integer.parseInt(nStr);
|
||||||
|
|
||||||
// Number of requests
|
// Number of requests
|
||||||
if (nireq == 0) {
|
if (nireq == 0) {
|
||||||
@ -289,8 +310,12 @@ public class Main {
|
|||||||
int temp = niter;
|
int temp = niter;
|
||||||
niter = ((niter + nireq - 1) / nireq) * nireq;
|
niter = ((niter + nireq - 1) / nireq) * nireq;
|
||||||
if (temp != niter) {
|
if (temp != niter) {
|
||||||
System.err.println("[ INFO ] Number of iterations was aligned by request number from " +
|
System.err.println(
|
||||||
temp + " to " + niter + " using number of requests " + nireq);
|
"[ INFO ] Number of iterations was aligned by request number from "
|
||||||
|
+ " to "
|
||||||
|
+ niter
|
||||||
|
+ " using number of requests "
|
||||||
|
+ nireq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,14 +329,14 @@ public class Main {
|
|||||||
durationSeconds = deviceDefaultDeviceDurationInSeconds(device);
|
durationSeconds = deviceDefaultDeviceDurationInSeconds(device);
|
||||||
}
|
}
|
||||||
durationMs = getDurationInMilliseconds(durationSeconds);
|
durationMs = getDurationInMilliseconds(durationSeconds);
|
||||||
|
|
||||||
// ----------------- 9. Creating infer requests and filling input blobs -------------------------------------
|
// ---------- 9. Creating infer requests and filling input blobs ---------------
|
||||||
nextStep("Creating infer requests and filling input blobs");
|
nextStep("Creating infer requests and filling input blobs");
|
||||||
|
|
||||||
InferRequestsQueue inferRequestsQueue = new InferRequestsQueue(executableNetwork, nireq);
|
InferRequestsQueue inferRequestsQueue = new InferRequestsQueue(executableNetwork, nireq);
|
||||||
fillBlobs(inferRequestsQueue.requests, inputsInfo);
|
fillBlobs(inferRequestsQueue.requests, inputsInfo);
|
||||||
|
|
||||||
// ----------------- 10. Measuring performance --------------------------------------------------------------
|
// ---------- 10. Measuring performance ----------------------------------------
|
||||||
String ss = "Start inference " + api + "ronously";
|
String ss = "Start inference " + api + "ronously";
|
||||||
if (isAsync) {
|
if (isAsync) {
|
||||||
if (!ss.isEmpty()) {
|
if (!ss.isEmpty()) {
|
||||||
@ -352,18 +377,19 @@ public class Main {
|
|||||||
|
|
||||||
startTime = System.currentTimeMillis();
|
startTime = System.currentTimeMillis();
|
||||||
long execTime = getTotalMsTime(startTime);
|
long execTime = getTotalMsTime(startTime);
|
||||||
|
|
||||||
while ((niter != 0 && iteration < niter) ||
|
while ((niter != 0 && iteration < niter)
|
||||||
(durationMs != 0L && execTime < durationMs) ||
|
|| (durationMs != 0L && execTime < durationMs)
|
||||||
(isAsync && iteration % nireq != 0)) {
|
|| (isAsync && iteration % nireq != 0)) {
|
||||||
inferRequest = inferRequestsQueue.getIdleRequest();
|
inferRequest = inferRequestsQueue.getIdleRequest();
|
||||||
|
|
||||||
if (isAsync) {
|
if (isAsync) {
|
||||||
// As the inference request is currently idle, the wait() adds no additional overhead
|
// As the inference request is currently idle, the wait() adds no additional
|
||||||
//(and should return immediately).
|
// overhead (and should return immediately).
|
||||||
// The primary reason for calling the method is exception checking/re-throwing.
|
// The primary reason for calling the method is exception checking/re-throwing.
|
||||||
// Callback, that governs the actual execution can handle errors as well,
|
// Callback, that governs the actual execution can handle errors as well,
|
||||||
// but as it uses just error codes it has no details like ‘what()’ method of `std::exception`
|
// but as it uses just error codes it has no details like ‘what()’ method of
|
||||||
|
// `std::exception`.
|
||||||
// So, rechecking for any exceptions here.
|
// So, rechecking for any exceptions here.
|
||||||
inferRequest._wait();
|
inferRequest._wait();
|
||||||
inferRequest.startAsync();
|
inferRequest.startAsync();
|
||||||
@ -380,10 +406,12 @@ public class Main {
|
|||||||
|
|
||||||
double latency = getMedianValue(inferRequestsQueue.getLatencies());
|
double latency = getMedianValue(inferRequestsQueue.getLatencies());
|
||||||
double totalDuration = inferRequestsQueue.getDurationInMilliseconds();
|
double totalDuration = inferRequestsQueue.getDurationInMilliseconds();
|
||||||
double fps = (!isAsync) ? batchSize * 1000.0 / latency :
|
double fps =
|
||||||
batchSize * 1000.0 * iteration / totalDuration;
|
(!isAsync)
|
||||||
|
? batchSize * 1000.0 / latency
|
||||||
|
: batchSize * 1000.0 * iteration / totalDuration;
|
||||||
|
|
||||||
// ----------------- 11. Dumping statistics report ----------------------------------------------------------
|
// ------------ 11. Dumping statistics report ----------------------------------
|
||||||
nextStep("Dumping statistics report");
|
nextStep("Dumping statistics report");
|
||||||
|
|
||||||
System.out.println("Count: " + iteration + " iterations");
|
System.out.println("Count: " + iteration + " iterations");
|
||||||
|
@ -1,20 +1,19 @@
|
|||||||
import org.opencv.core.*;
|
|
||||||
import org.opencv.imgcodecs.*;
|
|
||||||
import org.opencv.highgui.HighGui;
|
|
||||||
import org.opencv.imgproc.Imgproc;
|
|
||||||
import org.intel.openvino.*;
|
import org.intel.openvino.*;
|
||||||
|
import org.opencv.core.*;
|
||||||
|
import org.opencv.highgui.HighGui;
|
||||||
|
import org.opencv.imgcodecs.*;
|
||||||
|
import org.opencv.imgproc.Imgproc;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This is face detection java sample.
|
This is face detection java sample.
|
||||||
|
|
||||||
Upon the start-up the sample application reads command line parameters and loads a network
|
Upon the start-up the sample application reads command line parameters and loads a network
|
||||||
and an image to the Inference Engine device. When inference is done, the application will show
|
and an image to the Inference Engine device. When inference is done, the application will show
|
||||||
the image with detected objects enclosed in rectangles in new window.It also outputs the
|
the image with detected objects enclosed in rectangles in new window.It also outputs the
|
||||||
confidence value and the coordinates of the rectangle to the standard output stream.
|
confidence value and the coordinates of the rectangle to the standard output stream.
|
||||||
|
|
||||||
To get the list of command line parameters run the application with `--help` paramether.
|
To get the list of command line parameters run the application with `--help` paramether.
|
||||||
*/
|
*/
|
||||||
@ -42,24 +41,25 @@ public class Main {
|
|||||||
String imgPath = parser.get("-i", null);
|
String imgPath = parser.get("-i", null);
|
||||||
String xmlPath = parser.get("-m", null);
|
String xmlPath = parser.get("-m", null);
|
||||||
|
|
||||||
if(imgPath == null) {
|
if (imgPath == null) {
|
||||||
System.out.println("Error: Missed argument: -i");
|
System.out.println("Error: Missed argument: -i");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(xmlPath == null) {
|
if (xmlPath == null) {
|
||||||
System.out.println("Error: Missed argument: -m");
|
System.out.println("Error: Missed argument: -m");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Mat image = Imgcodecs.imread(imgPath);
|
Mat image = Imgcodecs.imread(imgPath);
|
||||||
|
|
||||||
int[] dimsArr = {1, image.channels(), image.height(), image.width()};
|
int[] dimsArr = {1, image.channels(), image.height(), image.width()};
|
||||||
TensorDesc tDesc = new TensorDesc(Precision.U8, dimsArr, Layout.NHWC);
|
TensorDesc tDesc = new TensorDesc(Precision.U8, dimsArr, Layout.NHWC);
|
||||||
|
|
||||||
// The source image is also used at the end of the program to display the detection results,
|
// The source image is also used at the end of the program to display the detection results,
|
||||||
// therefore the Mat object won't be destroyed by Garbage Collector while the network is running.
|
// therefore the Mat object won't be destroyed by Garbage Collector while the network is
|
||||||
|
// running.
|
||||||
Blob imgBlob = new Blob(tDesc, image.dataAddr());
|
Blob imgBlob = new Blob(tDesc, image.dataAddr());
|
||||||
|
|
||||||
IECore core = new IECore();
|
IECore core = new IECore();
|
||||||
|
|
||||||
CNNNetwork net = core.ReadNetwork(xmlPath);
|
CNNNetwork net = core.ReadNetwork(xmlPath);
|
||||||
@ -77,7 +77,7 @@ public class Main {
|
|||||||
ExecutableNetwork executableNetwork = core.LoadNetwork(net, "CPU");
|
ExecutableNetwork executableNetwork = core.LoadNetwork(net, "CPU");
|
||||||
InferRequest inferRequest = executableNetwork.CreateInferRequest();
|
InferRequest inferRequest = executableNetwork.CreateInferRequest();
|
||||||
|
|
||||||
inferRequest.SetBlob(inputName, imgBlob);
|
inferRequest.SetBlob(inputName, imgBlob);
|
||||||
inferRequest.Infer();
|
inferRequest.Infer();
|
||||||
|
|
||||||
Blob output = inferRequest.GetBlob(outputName);
|
Blob output = inferRequest.GetBlob(outputName);
|
||||||
@ -89,27 +89,28 @@ public class Main {
|
|||||||
|
|
||||||
for (int curProposal = 0; curProposal < maxProposalCount; curProposal++) {
|
for (int curProposal = 0; curProposal < maxProposalCount; curProposal++) {
|
||||||
int image_id = (int) detection[curProposal * 7];
|
int image_id = (int) detection[curProposal * 7];
|
||||||
if (image_id < 0)
|
if (image_id < 0) break;
|
||||||
break;
|
|
||||||
|
|
||||||
float confidence = detection[curProposal * 7 + 2];
|
float confidence = detection[curProposal * 7 + 2];
|
||||||
|
|
||||||
// Drawing only objects with >70% probability
|
// Drawing only objects with >70% probability
|
||||||
if (confidence < THRESHOLD)
|
if (confidence < THRESHOLD) continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
int label = (int) (detection[curProposal * 7 + 1]);
|
int label = (int) (detection[curProposal * 7 + 1]);
|
||||||
int xmin = (int) (detection[curProposal * 7 + 3] * image.cols());
|
int xmin = (int) (detection[curProposal * 7 + 3] * image.cols());
|
||||||
int ymin = (int) (detection[curProposal * 7 + 4] * image.rows());
|
int ymin = (int) (detection[curProposal * 7 + 4] * image.rows());
|
||||||
int xmax = (int) (detection[curProposal * 7 + 5] * image.cols());
|
int xmax = (int) (detection[curProposal * 7 + 5] * image.cols());
|
||||||
int ymax = (int) (detection[curProposal * 7 + 6] * image.rows());
|
int ymax = (int) (detection[curProposal * 7 + 6] * image.rows());
|
||||||
|
|
||||||
System.out.println("[" + curProposal + "," + label + "] element, prob = " + confidence + " (" + xmin
|
String result = "[" + curProposal + "," + label + "] element, prob = " + confidence;
|
||||||
+ "," + ymin + ")-(" + xmax + "," + ymax + ")");
|
result += " (" + xmin + "," + ymin + ")-(" + xmax + "," + ymax + ")";
|
||||||
|
|
||||||
|
System.out.println(result);
|
||||||
System.out.println(" - WILL BE PRINTED!");
|
System.out.println(" - WILL BE PRINTED!");
|
||||||
|
|
||||||
// Draw rectangle around detected object.
|
// Draw rectangle around detected object.
|
||||||
Imgproc.rectangle(image, new Point(xmin, ymin), new Point(xmax, ymax), new Scalar(0, 255, 0));
|
Imgproc.rectangle(
|
||||||
|
image, new Point(xmin, ymin), new Point(xmax, ymax), new Scalar(0, 255, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
HighGui.namedWindow("Detection", HighGui.WINDOW_AUTOSIZE);
|
HighGui.namedWindow("Detection", HighGui.WINDOW_AUTOSIZE);
|
||||||
|
@ -1,32 +1,30 @@
|
|||||||
|
import org.intel.openvino.*;
|
||||||
import org.opencv.core.*;
|
import org.opencv.core.*;
|
||||||
import org.opencv.imgcodecs.*;
|
|
||||||
import org.opencv.videoio.*;
|
|
||||||
import org.opencv.imgproc.Imgproc;
|
|
||||||
import org.opencv.highgui.HighGui;
|
import org.opencv.highgui.HighGui;
|
||||||
|
import org.opencv.imgcodecs.*;
|
||||||
|
import org.opencv.imgproc.Imgproc;
|
||||||
|
import org.opencv.videoio.*;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Queue;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Queue;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import org.intel.openvino.*;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This is async face detection java sample.
|
This is async face detection java sample.
|
||||||
|
|
||||||
Upon the start-up the sample application reads command line parameters and loads a network
|
Upon the start-up the sample application reads command line parameters and loads a network
|
||||||
and an images to the Inference Engine device. When inference is done, the application
|
and an images to the Inference Engine device. When inference is done, the application
|
||||||
shows the video with detected objects enclosed in rectangles in new window.
|
shows the video with detected objects enclosed in rectangles in new window.
|
||||||
|
|
||||||
To get the list of command line parameters run the application with `--help` paramether.
|
To get the list of command line parameters run the application with `--help` paramether.
|
||||||
*/
|
*/
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
public static Blob imageToBlob(Mat image) {
|
public static Blob imageToBlob(Mat image) {
|
||||||
int[] dimsArr = {1, image.channels(), image.height(), image.width()};
|
int[] dimsArr = {1, image.channels(), image.height(), image.width()};
|
||||||
TensorDesc tDesc = new TensorDesc(Precision.U8, dimsArr, Layout.NHWC);
|
TensorDesc tDesc = new TensorDesc(Precision.U8, dimsArr, Layout.NHWC);
|
||||||
@ -41,9 +39,8 @@ public class Main {
|
|||||||
while (!startedRequestsIds.isEmpty()) {
|
while (!startedRequestsIds.isEmpty()) {
|
||||||
int requestId = startedRequestsIds.peek();
|
int requestId = startedRequestsIds.peek();
|
||||||
InferRequest inferRequest = inferRequests.get(requestId);
|
InferRequest inferRequest = inferRequests.get(requestId);
|
||||||
|
|
||||||
if (inferRequest.Wait(wait) != StatusCode.OK)
|
if (inferRequest.Wait(wait) != StatusCode.OK) return;
|
||||||
return;
|
|
||||||
|
|
||||||
if (size == 0 && res == null) {
|
if (size == 0 && res == null) {
|
||||||
size = inferRequest.GetBlob(outputName).size();
|
size = inferRequest.GetBlob(outputName).size();
|
||||||
@ -86,11 +83,11 @@ public class Main {
|
|||||||
String device = parser.get("-d", "CPU");
|
String device = parser.get("-d", "CPU");
|
||||||
int inferRequestsSize = parser.getInteger("-nireq", 2);
|
int inferRequestsSize = parser.getInteger("-nireq", 2);
|
||||||
|
|
||||||
if(imgsPath == null ) {
|
if (imgsPath == null) {
|
||||||
System.out.println("Error: Missed argument: -i");
|
System.out.println("Error: Missed argument: -i");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(xmlPath == null) {
|
if (xmlPath == null) {
|
||||||
System.out.println("Error: Missed argument: -m");
|
System.out.println("Error: Missed argument: -m");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -99,137 +96,145 @@ public class Main {
|
|||||||
|
|
||||||
BlockingQueue<Mat> framesQueue = new LinkedBlockingQueue<Mat>();
|
BlockingQueue<Mat> framesQueue = new LinkedBlockingQueue<Mat>();
|
||||||
|
|
||||||
Thread captureThread = new Thread(new Runnable() {
|
Runnable capture =
|
||||||
@Override
|
new Runnable() {
|
||||||
public void run() {
|
@Override
|
||||||
VideoCapture cam = new VideoCapture();
|
public void run() {
|
||||||
cam.open(imgsPath);
|
VideoCapture cam = new VideoCapture();
|
||||||
Mat frame = new Mat();
|
cam.open(imgsPath);
|
||||||
|
Mat frame = new Mat();
|
||||||
|
|
||||||
while (cam.read(frame)) {
|
while (cam.read(frame)) {
|
||||||
framesCounter++;
|
framesCounter++;
|
||||||
framesQueue.add(frame.clone());
|
framesQueue.add(frame.clone());
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Thread inferThread = new Thread(new Runnable() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
IECore core = new IECore();
|
|
||||||
CNNNetwork net = core.ReadNetwork(xmlPath);
|
|
||||||
|
|
||||||
Map<String, InputInfo> inputsInfo = net.getInputsInfo();
|
|
||||||
String inputName = new ArrayList<String>(inputsInfo.keySet()).get(0);
|
|
||||||
InputInfo inputInfo = inputsInfo.get(inputName);
|
|
||||||
|
|
||||||
inputInfo.getPreProcess().setResizeAlgorithm(ResizeAlgorithm.RESIZE_BILINEAR);
|
|
||||||
inputInfo.setLayout(Layout.NHWC);
|
|
||||||
inputInfo.setPrecision(Precision.U8);
|
|
||||||
|
|
||||||
outputName = new ArrayList<String>(net.getOutputsInfo().keySet()).get(0);
|
|
||||||
|
|
||||||
ExecutableNetwork executableNetwork = core.LoadNetwork(net, device);
|
|
||||||
|
|
||||||
asyncInferIsFree = new Vector<Boolean>(inferRequestsSize);
|
|
||||||
|
|
||||||
for (int i = 0; i < inferRequestsSize; i++) {
|
|
||||||
inferRequests.add(executableNetwork.CreateInferRequest());
|
|
||||||
asyncInferIsFree.add(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean isRunning = true;
|
|
||||||
|
|
||||||
while (captureThread.isAlive() || !framesQueue.isEmpty()) {
|
|
||||||
processInferRequets(WaitMode.STATUS_ONLY);
|
|
||||||
|
|
||||||
for (int i = 0; i < inferRequestsSize; i++) {
|
|
||||||
if (!asyncInferIsFree.get(i))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
Mat frame = framesQueue.poll(0, TimeUnit.SECONDS);
|
|
||||||
|
|
||||||
if (frame == null)
|
|
||||||
break;
|
|
||||||
|
|
||||||
InferRequest request = inferRequests.get(i);
|
|
||||||
|
|
||||||
asyncInferIsFree.setElementAt(false, i);
|
|
||||||
processedFramesQueue.add(frame); // predictionsQueue is used in rendering
|
|
||||||
|
|
||||||
// The source frame is kept in processedFramesQueue,
|
|
||||||
// so the frame will be removed by java Garbage Collector only after completion of inference,
|
|
||||||
// and we can create Blob object using Mat object data address.
|
|
||||||
Blob imgBlob = imageToBlob(frame);
|
|
||||||
request.SetBlob(inputName, imgBlob);
|
|
||||||
|
|
||||||
startedRequestsIds.add(i);
|
|
||||||
request.StartAsync();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
processInferRequets(WaitMode.RESULT_READY);
|
};
|
||||||
} catch (InterruptedException e) {
|
Thread captureThread = new Thread(capture);
|
||||||
e.printStackTrace();
|
|
||||||
|
Runnable infer =
|
||||||
for (Thread t : Thread.getAllStackTraces().keySet())
|
new Runnable() {
|
||||||
if (t.getState()==Thread.State.RUNNABLE)
|
@Override
|
||||||
t.interrupt();
|
public void run() {
|
||||||
}
|
try {
|
||||||
}
|
IECore core = new IECore();
|
||||||
});
|
CNNNetwork net = core.ReadNetwork(xmlPath);
|
||||||
|
|
||||||
|
Map<String, InputInfo> inputsInfo = net.getInputsInfo();
|
||||||
|
String inputName = new ArrayList<String>(inputsInfo.keySet()).get(0);
|
||||||
|
InputInfo inputInfo = inputsInfo.get(inputName);
|
||||||
|
|
||||||
|
inputInfo
|
||||||
|
.getPreProcess()
|
||||||
|
.setResizeAlgorithm(ResizeAlgorithm.RESIZE_BILINEAR);
|
||||||
|
inputInfo.setLayout(Layout.NHWC);
|
||||||
|
inputInfo.setPrecision(Precision.U8);
|
||||||
|
|
||||||
|
outputName =
|
||||||
|
new ArrayList<String>(net.getOutputsInfo().keySet()).get(0);
|
||||||
|
|
||||||
|
ExecutableNetwork execNetwork = core.LoadNetwork(net, device);
|
||||||
|
|
||||||
|
asyncInferIsFree = new Vector<Boolean>(inferRequestsSize);
|
||||||
|
|
||||||
|
for (int i = 0; i < inferRequestsSize; i++) {
|
||||||
|
inferRequests.add(execNetwork.CreateInferRequest());
|
||||||
|
asyncInferIsFree.add(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isRunning = true;
|
||||||
|
|
||||||
|
while (captureThread.isAlive() || !framesQueue.isEmpty()) {
|
||||||
|
processInferRequets(WaitMode.STATUS_ONLY);
|
||||||
|
|
||||||
|
for (int i = 0; i < inferRequestsSize; i++) {
|
||||||
|
if (!asyncInferIsFree.get(i)) continue;
|
||||||
|
|
||||||
|
Mat frame = framesQueue.poll(0, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
if (frame == null) break;
|
||||||
|
|
||||||
|
InferRequest request = inferRequests.get(i);
|
||||||
|
|
||||||
|
asyncInferIsFree.setElementAt(false, i);
|
||||||
|
|
||||||
|
// processedFramesQueue is used in rendering
|
||||||
|
processedFramesQueue.add(frame);
|
||||||
|
|
||||||
|
// The source frame is kept in processedFramesQueue,
|
||||||
|
// so the frame will be removed by java Garbage
|
||||||
|
// Collector only after completion of inference,
|
||||||
|
// and we can create Blob object using Mat object data address.
|
||||||
|
Blob imgBlob = imageToBlob(frame);
|
||||||
|
request.SetBlob(inputName, imgBlob);
|
||||||
|
|
||||||
|
startedRequestsIds.add(i);
|
||||||
|
request.StartAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
processInferRequets(WaitMode.RESULT_READY);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
|
||||||
|
for (Thread t : Thread.getAllStackTraces().keySet())
|
||||||
|
if (t.getState() == Thread.State.RUNNABLE) t.interrupt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Thread inferThread = new Thread(infer);
|
||||||
|
|
||||||
captureThread.start();
|
captureThread.start();
|
||||||
inferThread.start();
|
inferThread.start();
|
||||||
|
|
||||||
TickMeter tm = new TickMeter();
|
TickMeter tm = new TickMeter();
|
||||||
|
Scalar color = new Scalar(0, 255, 0);
|
||||||
try {
|
try {
|
||||||
while (inferThread.isAlive() || !detectionOutput.isEmpty()) {
|
while (inferThread.isAlive() || !detectionOutput.isEmpty()) {
|
||||||
|
|
||||||
float[] detection = detectionOutput.poll(waitingTime, TimeUnit.SECONDS);
|
float[] detection = detectionOutput.poll(waitingTime, TimeUnit.SECONDS);
|
||||||
if (detection == null)
|
if (detection == null) continue;
|
||||||
continue;
|
|
||||||
|
Mat img = processedFramesQueue.poll(waitingTime, TimeUnit.SECONDS);
|
||||||
Mat img = processedFramesQueue.poll(waitingTime, TimeUnit.SECONDS);
|
|
||||||
int maxProposalCount = detection.length / 7;
|
int maxProposalCount = detection.length / 7;
|
||||||
|
|
||||||
for (int curProposal = 0; curProposal < maxProposalCount; curProposal++) {
|
for (int curProposal = 0; curProposal < maxProposalCount; curProposal++) {
|
||||||
int imageId = (int) detection[curProposal * 7];
|
int imageId = (int) detection[curProposal * 7];
|
||||||
if (imageId < 0)
|
if (imageId < 0) break;
|
||||||
break;
|
|
||||||
|
|
||||||
float confidence = detection[curProposal * 7 + 2];
|
float confidence = detection[curProposal * 7 + 2];
|
||||||
|
|
||||||
// Drawing only objects with >70% probability
|
// Drawing only objects with >70% probability
|
||||||
if (confidence < CONFIDENCE_THRESHOLD)
|
if (confidence < CONFIDENCE_THRESHOLD) continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
int label = (int) (detection[curProposal * 7 + 1]);
|
int label = (int) (detection[curProposal * 7 + 1]);
|
||||||
int xmin = (int) (detection[curProposal * 7 + 3] * img.cols());
|
int xmin = (int) (detection[curProposal * 7 + 3] * img.cols());
|
||||||
int ymin = (int) (detection[curProposal * 7 + 4] * img.rows());
|
int ymin = (int) (detection[curProposal * 7 + 4] * img.rows());
|
||||||
int xmax = (int) (detection[curProposal * 7 + 5] * img.cols());
|
int xmax = (int) (detection[curProposal * 7 + 5] * img.cols());
|
||||||
int ymax = (int) (detection[curProposal * 7 + 6] * img.rows());
|
int ymax = (int) (detection[curProposal * 7 + 6] * img.rows());
|
||||||
|
|
||||||
// Draw rectangle around detected object.
|
// Draw rectangle around detected object.
|
||||||
Imgproc.rectangle(img, new Point(xmin, ymin), new Point(xmax, ymax), new Scalar(0, 255, 0), 2);
|
Point lt = new Point(xmin, ymin);
|
||||||
|
Point br = new Point(xmax, ymax);
|
||||||
|
Imgproc.rectangle(img, lt, br, color, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resultCounter == warmupNum) {
|
if (resultCounter == warmupNum) {
|
||||||
tm.start();
|
tm.start();
|
||||||
} else if (resultCounter > warmupNum) {
|
} else if (resultCounter > warmupNum) {
|
||||||
tm.stop();
|
tm.stop();
|
||||||
double worksFps = ((double)(resultCounter - warmupNum)) / tm.getTimeSec();
|
double worksFps = ((double) (resultCounter - warmupNum)) / tm.getTimeSec();
|
||||||
double readFps = ((double)(framesCounter - warmupNum)) / tm.getTimeSec();
|
double readFps = ((double) (framesCounter - warmupNum)) / tm.getTimeSec();
|
||||||
tm.start();
|
tm.start();
|
||||||
|
|
||||||
Imgproc.putText(img, "Reading fps: " + String.format("%.3f", readFps), new Point(10, 50), 0 , 0.7, new Scalar(0, 255, 0), 1);
|
String label = "Reading fps: " + String.format("%.3f", readFps);
|
||||||
Imgproc.putText(img, "Inference fps: " + String.format("%.3f", worksFps), new Point(10, 80), 0 , 0.7, new Scalar(0, 255, 0), 1);
|
String label1 = "Inference fps: " + String.format("%.3f", worksFps);
|
||||||
|
|
||||||
|
Imgproc.putText(img, label, new Point(10, 50), 0, 0.7, color, 1);
|
||||||
|
Imgproc.putText(img, label1, new Point(10, 80), 0, 0.7, color, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
HighGui.imshow("Detection", img);
|
HighGui.imshow("Detection", img);
|
||||||
}
|
}
|
||||||
|
|
||||||
captureThread.join();
|
captureThread.join();
|
||||||
inferThread.join();
|
inferThread.join();
|
||||||
|
|
||||||
@ -239,8 +244,7 @@ public class Main {
|
|||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
for (Thread t : Thread.getAllStackTraces().keySet())
|
for (Thread t : Thread.getAllStackTraces().keySet())
|
||||||
if (t.getState()==Thread.State.RUNNABLE)
|
if (t.getState() == Thread.State.RUNNABLE) t.interrupt();
|
||||||
t.interrupt();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
|
import org.intel.openvino.*;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.intel.openvino.*;
|
|
||||||
|
|
||||||
public class BlobTests extends IETest {
|
public class BlobTests extends IETest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetBlob() {
|
public void testGetBlob() {
|
||||||
int[] dimsArr = {1, 3, 200, 200};
|
int[] dimsArr = {1, 3, 200, 200};
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import org.intel.openvino.*;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.intel.openvino.*;
|
|
||||||
|
|
||||||
public class CNNNetworkTests extends IETest {
|
public class CNNNetworkTests extends IETest {
|
||||||
IECore core = new IECore();
|
IECore core = new IECore();
|
||||||
|
|
||||||
@ -37,13 +37,12 @@ public class CNNNetworkTests extends IETest {
|
|||||||
public void testAddOutput() {
|
public void testAddOutput() {
|
||||||
CNNNetwork net = core.ReadNetwork(modelXml);
|
CNNNetwork net = core.ReadNetwork(modelXml);
|
||||||
Map<String, Data> output = net.getOutputsInfo();
|
Map<String, Data> output = net.getOutputsInfo();
|
||||||
|
|
||||||
assertEquals("Input size", 1, output.size());
|
assertEquals("Input size", 1, output.size());
|
||||||
|
|
||||||
net.addOutput("19/WithoutBiases");
|
net.addOutput("19/WithoutBiases");
|
||||||
output = net.getOutputsInfo();
|
output = net.getOutputsInfo();
|
||||||
|
|
||||||
assertEquals("Input size", 2, output.size());
|
assertEquals("Input size", 2, output.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import org.intel.openvino.*;
|
import org.intel.openvino.*;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class IECoreTests extends IETest {
|
public class IECoreTests extends IETest {
|
||||||
IECore core = new IECore();
|
IECore core = new IECore();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testReadNetwork() {
|
public void testReadNetwork() {
|
||||||
CNNNetwork net = core.ReadNetwork(modelXml, modelBin);
|
CNNNetwork net = core.ReadNetwork(modelXml, modelBin);
|
||||||
@ -57,7 +57,7 @@ public class IECoreTests extends IETest {
|
|||||||
|
|
||||||
Map<String, String> testMap = new HashMap<String, String>();
|
Map<String, String> testMap = new HashMap<String, String>();
|
||||||
|
|
||||||
//When specifying key values as raw strings, omit the KEY_ prefix
|
// When specifying key values as raw strings, omit the KEY_ prefix
|
||||||
testMap.put("CPU_BIND_THREAD", "YES");
|
testMap.put("CPU_BIND_THREAD", "YES");
|
||||||
testMap.put("CPU_THREADS_NUM", "1");
|
testMap.put("CPU_THREADS_NUM", "1");
|
||||||
|
|
||||||
@ -75,6 +75,8 @@ public class IECoreTests extends IETest {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
exceptionMessage = e.getMessage();
|
exceptionMessage = e.getMessage();
|
||||||
}
|
}
|
||||||
assertTrue(exceptionMessage.contains("Device with \"DEVISE\" name is not registered in the InferenceEngine"));
|
assertTrue(
|
||||||
|
exceptionMessage.contains(
|
||||||
|
"Device with \"DEVISE\" name is not registered in the InferenceEngine"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,11 @@
|
|||||||
import org.junit.Assert;
|
import org.intel.openvino.*;
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.runner.Description;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.rules.TestWatcher;
|
import org.junit.rules.TestWatcher;
|
||||||
|
import org.junit.runner.Description;
|
||||||
|
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
import org.intel.openvino.*;
|
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
public class IETest {
|
public class IETest {
|
||||||
String modelXml;
|
String modelXml;
|
||||||
@ -23,20 +19,33 @@ public class IETest {
|
|||||||
System.err.println("Failed to load Inference Engine library\n" + e);
|
System.err.println("Failed to load Inference Engine library\n" + e);
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
modelXml = Paths.get(System.getenv("MODELS_PATH"), "models", "test_model", "test_model_fp32.xml").toString();
|
modelXml =
|
||||||
modelBin = Paths.get(System.getenv("MODELS_PATH"), "models", "test_model", "test_model_fp32.bin").toString();
|
Paths.get(
|
||||||
|
System.getenv("MODELS_PATH"),
|
||||||
|
"models",
|
||||||
|
"test_model",
|
||||||
|
"test_model_fp32.xml")
|
||||||
|
.toString();
|
||||||
|
modelBin =
|
||||||
|
Paths.get(
|
||||||
|
System.getenv("MODELS_PATH"),
|
||||||
|
"models",
|
||||||
|
"test_model",
|
||||||
|
"test_model_fp32.bin")
|
||||||
|
.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public TestWatcher watchman = new TestWatcher() {
|
public TestWatcher watchman =
|
||||||
@Override
|
new TestWatcher() {
|
||||||
protected void succeeded(Description description) {
|
@Override
|
||||||
System.out.println(description + " - OK");
|
protected void succeeded(Description description) {
|
||||||
}
|
System.out.println(description + " - OK");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void failed(Throwable e, Description description) {
|
protected void failed(Throwable e, Description description) {
|
||||||
System.out.println(description + " - FAILED");
|
System.out.println(description + " - FAILED");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.Before;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Vector;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import org.intel.openvino.*;
|
import org.intel.openvino.*;
|
||||||
import org.intel.openvino.InferenceEngineProfileInfo.LayerStatus;
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
public class InferRequestTests extends IETest {
|
public class InferRequestTests extends IETest {
|
||||||
IECore core;
|
IECore core;
|
||||||
@ -59,13 +58,14 @@ public class InferRequestTests extends IETest {
|
|||||||
ArrayList<String> resKeySet = new ArrayList<String>(res.keySet());
|
ArrayList<String> resKeySet = new ArrayList<String>(res.keySet());
|
||||||
|
|
||||||
for (int i = 0; i < res.size(); i++) {
|
for (int i = 0; i < res.size(); i++) {
|
||||||
String key = resKeySet.get(i);
|
String key = resKeySet.get(i);
|
||||||
InferenceEngineProfileInfo resVal = res.get(key);
|
InferenceEngineProfileInfo resVal = res.get(key);
|
||||||
|
|
||||||
assertEquals(key + " execType", key, layer_name.elementAt(i));
|
assertEquals(key + " execType", key, layer_name.elementAt(i));
|
||||||
assertEquals(key + " executionIndex", i, resVal.executionIndex);
|
assertEquals(key + " executionIndex", i, resVal.executionIndex);
|
||||||
assertTrue(resVal.status == InferenceEngineProfileInfo.LayerStatus.EXECUTED
|
assertTrue(
|
||||||
|| resVal.status == InferenceEngineProfileInfo.LayerStatus.NOT_RUN);
|
resVal.status == InferenceEngineProfileInfo.LayerStatus.EXECUTED
|
||||||
|
|| resVal.status == InferenceEngineProfileInfo.LayerStatus.NOT_RUN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,20 +79,21 @@ public class InferRequestTests extends IETest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetCompletionCallback() {
|
public void testSetCompletionCallback() {
|
||||||
inferRequest.SetCompletionCallback(new Runnable() {
|
inferRequest.SetCompletionCallback(
|
||||||
|
new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
completionCallback = true;
|
completionCallback = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
for(int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
inferRequest.Wait(WaitMode.RESULT_READY);
|
inferRequest.Wait(WaitMode.RESULT_READY);
|
||||||
inferRequest.StartAsync();
|
inferRequest.StartAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
inferRequest.Wait(WaitMode.RESULT_READY);
|
inferRequest.Wait(WaitMode.RESULT_READY);
|
||||||
inferRequest.StartAsync();
|
inferRequest.StartAsync();
|
||||||
StatusCode statusCode = inferRequest.Wait(WaitMode.RESULT_READY);
|
StatusCode statusCode = inferRequest.Wait(WaitMode.RESULT_READY);
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import org.intel.openvino.*;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.intel.openvino.*;
|
|
||||||
|
|
||||||
public class InputInfoTests extends IETest {
|
public class InputInfoTests extends IETest {
|
||||||
IECore core = new IECore();
|
IECore core = new IECore();
|
||||||
|
|
||||||
@ -26,12 +26,11 @@ public class InputInfoTests extends IETest {
|
|||||||
public void testSetPrecision() {
|
public void testSetPrecision() {
|
||||||
CNNNetwork net = core.ReadNetwork(modelXml);
|
CNNNetwork net = core.ReadNetwork(modelXml);
|
||||||
Map<String, InputInfo> inputsInfo = net.getInputsInfo();
|
Map<String, InputInfo> inputsInfo = net.getInputsInfo();
|
||||||
|
|
||||||
String inputName = new ArrayList<String>(inputsInfo.keySet()).get(0);
|
String inputName = new ArrayList<String>(inputsInfo.keySet()).get(0);
|
||||||
InputInfo inputInfo = inputsInfo.get(inputName);
|
InputInfo inputInfo = inputsInfo.get(inputName);
|
||||||
inputInfo.setPrecision(Precision.U8);
|
inputInfo.setPrecision(Precision.U8);
|
||||||
|
|
||||||
assertEquals("setPrecision", Precision.U8, inputInfo.getPrecision());
|
assertEquals("setPrecision", Precision.U8, inputInfo.getPrecision());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import org.intel.openvino.*;
|
||||||
import org.junit.runner.JUnitCore;
|
import org.junit.runner.JUnitCore;
|
||||||
import org.junit.runner.Result;
|
import org.junit.runner.Result;
|
||||||
import org.junit.runner.notification.Failure;
|
import org.junit.runner.notification.Failure;
|
||||||
@ -11,9 +12,9 @@ public class OpenVinoTestRunner {
|
|||||||
IETest.device = parser.get("-d", "CPU");
|
IETest.device = parser.get("-d", "CPU");
|
||||||
|
|
||||||
Result result = JUnitCore.runClasses(TestsSuite.class);
|
Result result = JUnitCore.runClasses(TestsSuite.class);
|
||||||
|
|
||||||
for (Failure failure : result.getFailures()) {
|
for (Failure failure : result.getFailures()) {
|
||||||
System.out.println(failure.toString());
|
System.out.println(failure.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,40 +1,38 @@
|
|||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.junit.runners.AllTests;
|
|
||||||
|
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
import java.util.List;
|
import org.intel.openvino.*;
|
||||||
import java.util.ArrayList;
|
import org.junit.runner.RunWith;
|
||||||
import java.util.zip.*;
|
import org.junit.runners.AllTests;
|
||||||
|
|
||||||
import java.nio.file.FileSystems;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import java.lang.Class;
|
|
||||||
import java.net.*;
|
import java.net.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
import org.intel.openvino.*;
|
import java.util.List;
|
||||||
|
import java.util.zip.*;
|
||||||
|
|
||||||
@RunWith(AllTests.class)
|
@RunWith(AllTests.class)
|
||||||
|
public class TestsSuite extends IETest {
|
||||||
public class TestsSuite extends IETest{
|
|
||||||
|
|
||||||
public static TestSuite suite() {
|
public static TestSuite suite() {
|
||||||
TestSuite suite = new TestSuite();
|
TestSuite suite = new TestSuite();
|
||||||
try {
|
try {
|
||||||
//get openvino_test.jar path
|
// get openvino_test.jar path
|
||||||
String dir = new File(TestsSuite.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getPath().toString();
|
String dir =
|
||||||
|
new File(
|
||||||
|
TestsSuite.class
|
||||||
|
.getProtectionDomain()
|
||||||
|
.getCodeSource()
|
||||||
|
.getLocation()
|
||||||
|
.toURI())
|
||||||
|
.getPath()
|
||||||
|
.toString();
|
||||||
|
|
||||||
List<Class<?>> results = findClasses(dir);
|
List<Class<?>> results = findClasses(dir);
|
||||||
for (Class<?> cl : results) {
|
for (Class<?> cl : results) {
|
||||||
if (cl.getName() == "ArgumentParser")
|
if (cl.getName() == "ArgumentParser") continue;
|
||||||
continue;
|
|
||||||
suite.addTest(new junit.framework.JUnit4TestAdapter(cl));
|
suite.addTest(new junit.framework.JUnit4TestAdapter(cl));
|
||||||
}
|
}
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
@ -51,14 +49,19 @@ public class TestsSuite extends IETest{
|
|||||||
ZipInputStream zip = new ZipInputStream(new FileInputStream(directory));
|
ZipInputStream zip = new ZipInputStream(new FileInputStream(directory));
|
||||||
for (ZipEntry entry = zip.getNextEntry(); entry != null; entry = zip.getNextEntry()) {
|
for (ZipEntry entry = zip.getNextEntry(); entry != null; entry = zip.getNextEntry()) {
|
||||||
String name = entry.getName().toString();
|
String name = entry.getName().toString();
|
||||||
if (name.endsWith(".class") && !name.contains("$") && !name.contains("/")
|
if (name.endsWith(".class")
|
||||||
&& !name.equals("TestsSuite.class") && !name.equals("OpenVinoTestRunner.class") && !name.equals("IETest.class")) {
|
&& !name.contains("$")
|
||||||
classes.add(Class.forName(name.substring(0, name.length() - ".class".length())));
|
&& !name.contains("/")
|
||||||
|
&& !name.equals("TestsSuite.class")
|
||||||
|
&& !name.equals("OpenVinoTestRunner.class")
|
||||||
|
&& !name.equals("IETest.class")) {
|
||||||
|
classes.add(
|
||||||
|
Class.forName(name.substring(0, name.length() - ".class".length())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
System.out.println("FileNotFoundException: " + e.getMessage());
|
System.out.println("FileNotFoundException: " + e.getMessage());
|
||||||
} catch(IOException e) {
|
} catch (IOException e) {
|
||||||
System.out.println("IOException: " + e.getMessage());
|
System.out.println("IOException: " + e.getMessage());
|
||||||
}
|
}
|
||||||
return classes;
|
return classes;
|
||||||
|
Loading…
Reference in New Issue
Block a user