


Neural Machine Translation demonstrates how to convert a sequence-to-sequence neural machine translation model trained with the code in the PyTorch NMT tutorial and use the model in an Android app to do French-English translation. Object Detection demonstrates how to convert the popular YOLOv5 model and use it in an Android app that detects objects from pictures in your photos, taken with camera, or with live camera. Image Segmentation demonstrates a Python script that converts the PyTorch DeepLabV3 model and an Android app that uses the model to segment images. This demo app also shows how to use the native pre-built torchvision-ops library. More PyTorch Android Demo Apps D2goĭ2Go demonstrates a Python script that creates the much lighter and much faster Facebook D2Go model that is powered by PyTorch 1.8, torchvision 0.9, and Detectron2 with built-in SOTA networks for mobile, and an Android app that uses it to detect objects from pictures in your photos, taken with camera, or with live camera. Tensor outputTensor = mModule.forward(om(inputTensor)).toTensor()Īfter that, the code processes the output, finding classes with the highest scores. The module has a get_classes method that returns List, which can be called using method nMethod(methodName): Result class names are packaged inside the TorchScript model and initialized just after initial module initialization. The logic happens in TextClassificattionActivity. Language Processing ExampleĪnother example is natural language processing, based on an LSTM model, trained on a reddit comments dataset. It uses the aforementioned TensorImageUtils.imageYUV420CenterCropToFloat32Tensor method to convert in YUV420 format to input tensor.Īfter getting predicted scores from the model it finds top K classes with the highest scores and shows on the UI. Where the analyzeImage method process the camera output,. setImageReaderMode(_LATEST_IMAGE)įinal ImageAnalysis imageAnalysis = new ImageAnalysis(imageAnalysisConfig) ĬameraX.bindToLifecycle(this, preview, imageAnalysis) tOnPreviewOutputUpdateListener(output -> tSurfaceTexture(output.getSurfaceTexture())) įinal ImageAnalysisConfig imageAnalysisConfig =

Final PreviewConfig previewConfig = new PreviewConfig.Builder().build() įinal Preview preview = new Preview(previewConfig)
