Skip to content

Instantly share code, notes, and snippets.

@shahdghorsi
shahdghorsi / TFLiteObjectDetectionAPIModel.java
Last active April 30, 2021 09:59
Solving the array out of bound error
- recognitions.add(
- new Recognition(
- "" + i,
- labels.get((int) outputClasses[0][i] + labelOffset),
- outputScores[0][i],
- detection));
+ final int classLabel = (int) outputClasses[0][i] + labelOffset;
+ if (inRange(classLabel, labels.size(), 0) && inRange(outputScores[0][i], 1, 0)) {
+ recognitions.add(
+ new Recognition(
@shahdghorsi
shahdghorsi / DetectorActivity.java
Last active September 14, 2019 13:37
The Detector Activity
// Configuration values for the prepackaged SSD model.
private static final int TF_OD_API_INPUT_SIZE = 300;
private static final boolean TF_OD_API_IS_QUANTIZED = false;
private static final String TF_OD_API_MODEL_FILE = "detect.tflite";
private static final String TF_OD_API_LABELS_FILE = "file:///android_asset/labelmap.txt";
private static final DetectorMode MODE = DetectorMode.TF_OD_API;
@shahdghorsi
shahdghorsi / image_resizer.py
Last active September 14, 2019 10:08
Image resizer python file
import os
import glob
import cv2
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser(
description="Resize raw images to uniformed target size."
)