This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Predicted value for [0, 1] normalization. Label index: 682, confidence: 39% | |
Predicted value for [-1, 1] normalization. Label index: 682, confidence: 53% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
imgUrl = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/de/Compaqarmada7800.jpg/1024px-Compaqarmada7800.jpg" | |
img = Image.open(requests.get(imgUrl, stream=True).raw) | |
img.load() | |
img = img.resize((224, 224), PIL.Image.ANTIALIAS) | |
# Normalize to [0, 1] | |
data = np.asarray( img, dtype="int32" ) / 255.0 | |
# Inference on input data normalized to [0, 1] | |
inputImg = np.expand_dims(data,0).astype(np.float32) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
== Input details == | |
name: input | |
shape: [ 1 224 224 3] | |
type: <class 'numpy.float32’> | |
== Output details == | |
name: MobilenetV2/Predictions/Reshape_1 | |
shape: [ 1 1001] | |
type: <class 'numpy.float32’> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
== Input details == | |
name: flatten_input | |
shape: [ 1 28 28] | |
type: <class 'numpy.float32'> | |
== Output details == | |
name: dense_2/Softmax | |
shape: [ 1 10] | |
type: <class 'numpy.float32'> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interpreter = tf.lite.Interpreter(model_path="mnist.tflite") | |
interpreter.allocate_tensors() | |
print("== Input details ==") | |
print("name:", interpreter.get_input_details()[0]['name']) | |
print("shape:", interpreter.get_input_details()[0]['shape']) | |
print("type:", interpreter.get_input_details()[0]['dtype’]) | |
print("\n== Output details ==") | |
print("name:", interpreter.get_output_details()[0]['name']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class ModelConfig { | |
static final int FLOAT_BYTES_COUNT = 4; | |
public abstract String getModelFilename(); | |
public abstract String getLabelsFilename(); | |
public abstract int getInputWidth(); | |
public abstract int getInputHeight(); | |
public abstract int getInputSize(); | |
public abstract int getChannelsCount(); | |
public abstract float getMean(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ClassificationFrameProcessor implements FrameProcessor { | |
private final Interpreter interpreter; | |
private final List<String> labels; | |
private final ClassificationListener classificationListener; | |
private final ModelConfig modelConfig; | |
/* ... */ | |
@Override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity extends AppCompatActivity { | |
private CameraView cameraView; | |
private ClassificationFrameProcessor classificationFrameProcessor; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SimpleObserver<T> implements Observer<T> { | |
///... | |
@Override | |
public void onError(Throwable e) { | |
view.showGeneralErrorPopup(); | |
loggingManager.logException(e); // <-- !!!!! | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@AutoHandler | |
public interface PaymentErrorListener { | |
@ErrorCode(CODE_UNSUPPORTED_PREPAID_CARD) | |
void onUnsupportedPrepaidCardError(); | |
@ErrorCode(CODE_UNSUPPORTED_CONSUMER_CARD) | |
void onUnsupportedConsumerCardError(); | |
@ErrorCode(CODE_INSUFFICIENT_FUNDS) |