org.deeplearning4j.zoo.util.Labels Java Examples
The following examples show how to use
org.deeplearning4j.zoo.util.Labels.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: YOLOOutputAdapter.java From konduit-serving with Apache License 2.0 | 6 votes |
@Builder public YOLOOutputAdapter(double threshold, int[] inputShape, Labels labels, int numLabels, double[][] boundingBoxPriors) { this.labels = labels == null ? getLabels() : labels; if (threshold == 0.0) this.threshold = 0.5; else this.threshold = threshold; if (inputShape != null) this.inputShape = inputShape; else this.inputShape = new int[]{3, 608, 608}; this.labels = labels; this.numLabels = numLabels; if (boundingBoxPriors == null) this.boundingBoxPriors = Nd4j.create(YOLO2.DEFAULT_PRIOR_BOXES).castTo(DataType.FLOAT); else { this.boundingBoxPriors = Nd4j.create(boundingBoxPriors).castTo(DataType.FLOAT); } gridWidth = DarknetHelper.getGridWidth(inputShape); gridHeight = DarknetHelper.getGridHeight(inputShape); }
Example #2
Source File: YOLOOutputAdapter.java From konduit-serving with Apache License 2.0 | 5 votes |
public YOLOOutputAdapter(double threshold, Labels labels, int numLabels) { this.threshold = threshold; inputShape = new int[]{3, 608, 608}; this.labels = labels; this.numLabels = numLabels; boundingBoxPriors = Nd4j.create(YOLO2.DEFAULT_PRIOR_BOXES).castTo(DataType.FLOAT); gridWidth = DarknetHelper.getGridWidth(inputShape); gridHeight = DarknetHelper.getGridHeight(inputShape); }
Example #3
Source File: YOLOOutputAdapter.java From konduit-serving with Apache License 2.0 | 5 votes |
private static Labels getLabels() { try { return new COCOLabels(); } catch (IOException e) { return null; } }
Example #4
Source File: SSDOutputAdapter.java From konduit-serving with Apache License 2.0 | 5 votes |
public SSDOutputAdapter(double threshold, Labels labels, int numLabels) { this.threshold = threshold; inputShape = new int[]{3, 0, 0}; this.labels = labels; this.numLabels = numLabels; }
Example #5
Source File: YOLOOutputAdapter.java From konduit-serving with Apache License 2.0 | 4 votes |
private static Labels getLabels(InputStream is, int numLabels) { try { return new BaseLabels() { protected ArrayList<String> getLabels() { Scanner scanner = new Scanner(is); int id1 = -1; int count = 0; List<String> ret = new ArrayList<>(); String name = null; while (scanner.hasNext()) { String token = scanner.next(); if (token.equals("id:")) { id1 = scanner.nextInt(); } if (token.equals("display_name:")) { name = scanner.nextLine(); name = name.substring(2, name.length() - 1); } if (id1 > 0 && name != null) { ret.add(name); id1 = -1; name = null; } } return (ArrayList<String>) ret; } @Override public List<List<ClassPrediction>> decodePredictions(INDArray predictions, int n) { return super.decodePredictions(predictions, n); } @Override protected URL getURL() { return null; } @Override protected String resourceName() { return null; } @Override protected String resourceMD5() { return null; } }; } catch (IOException e) { e.printStackTrace(); return null; } }
Example #6
Source File: SSDOutputAdapter.java From konduit-serving with Apache License 2.0 | 4 votes |
public static Labels getLabels(InputStream is, int numLabels) { try { return new BaseLabels() { protected ArrayList<String> getLabels() { Scanner scanner = new Scanner(is); int id1 = -1; int count = 0; List<String> ret = new ArrayList<>(); String name = null; while (scanner.hasNext()) { String token = scanner.next(); if (token.equals("id:")) { id1 = scanner.nextInt(); } if (token.equals("display_name:")) { name = scanner.nextLine(); name = name.substring(2, name.length() - 1); } if (id1 > 0 && name != null) { ret.add(name); id1 = -1; name = null; } } return (ArrayList<String>) ret; } @Override protected URL getURL() { return null; } @Override protected String resourceName() { return null; } @Override protected String resourceMD5() { return null; } }; } catch (IOException e) { e.printStackTrace(); return null; } }
Example #7
Source File: SSDOutputAdapter.java From konduit-serving with Apache License 2.0 | 4 votes |
public static Labels getLabels() { return getLabels(SSDOutputAdapter.class.getResourceAsStream(DEFAULT_LABELS_RESOURCE_NAME), 100); }