-
Notifications
You must be signed in to change notification settings - Fork 307
[mobile][android] Tutorial corrections and aligning with the android api #267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[mobile][android] Tutorial corrections and aligning with the android api #267
Conversation
_mobile/android.md
Outdated
@@ -71,9 +71,9 @@ Further in this doc you can find how to rebuild it only for specific list of and | |||
|
|||
`org.pytorch:pytorch_android_torchvision` - additional library with utility functions for converting `android.media.Image` and `android.graphics.Bitmap` to tensors. | |||
|
|||
#### 4. Reading static image from android asset | |||
#### 4. Reading image from android asset |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Capitalization "Reading Image from Android Asset"
_mobile/android.md
Outdated
|
||
All logic happens in [org.pytorch.helloworld.MainActivity](https://github.com/pytorch/android-demo-app/blob/master/HelloWorldApp/app/src/main/java/org/pytorch/helloworld/MainActivity.java#L31-L69). | ||
All logic happens in [`org.pytorch.helloworld.MainActivity`](https://github.com/pytorch/android-demo-app/blob/master/HelloWorldApp/app/src/main/java/org/pytorch/helloworld/MainActivity.java#L31-L69). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"All [the] logic happens in ..."
_mobile/android.md
Outdated
|
||
All logic happens in [org.pytorch.helloworld.MainActivity](https://github.com/pytorch/android-demo-app/blob/master/HelloWorldApp/app/src/main/java/org/pytorch/helloworld/MainActivity.java#L31-L69). | ||
All logic happens in [`org.pytorch.helloworld.MainActivity`](https://github.com/pytorch/android-demo-app/blob/master/HelloWorldApp/app/src/main/java/org/pytorch/helloworld/MainActivity.java#L31-L69). | ||
As a first step we read `image.jpg` to `android.graphics.Bitmap` using standard android api. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"As a first step we read image.jpg
to android.graphics.Bitmap
using [the] standard [A]ndroid [API]."
@@ -90,13 +90,13 @@ Module module = Module.load(assetFilePath(this, "model.pt")); | |||
Tensor inputTensor = TensorImageUtils.bitmapToFloat32Tensor(bitmap, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Capitalization " Preparing Input"
_mobile/android.md
Outdated
@@ -90,13 +90,13 @@ Module module = Module.load(assetFilePath(this, "model.pt")); | |||
Tensor inputTensor = TensorImageUtils.bitmapToFloat32Tensor(bitmap, | |||
TensorImageUtils.TORCHVISION_NORM_MEAN_RGB, TensorImageUtils.TORCHVISION_NORM_STD_RGB); | |||
``` | |||
`org.pytorch.torchvision.TensorImageUtils` is part of 'org.pytorch:pytorch_android_torchvision' library. | |||
`org.pytorch.torchvision.TensorImageUtils` is part of `org.pytorch:pytorch_android_torchvision` library. | |||
`TensorImageUtils#bitmapToFloat32Tensor` method creates tensor in [torch vision format](https://pytorch.org/docs/stable/torchvision/models.html) using `android.graphics.Bitmap` as a source. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"[The] TensorImageUtils#bitmapToFloat32Tensor
method creates tensor[s] in [the] [torchvision] format ..."
_mobile/android.md
Outdated
1. Builds libtorch for android for all 4 android abis (armeabi-v7a, arm64-v8a, x86, x86_64) | ||
2. Creates symbolic links to the results of those builds: | ||
|
||
1\. Builds libtorch for android for all 4 android abis (armeabi-v7a, arm64-v8a, x86, x86_64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change tenses:
"Builds..." --> "Build"
"Creates..." ---> "Create"
"runs..." ----> "run"
_mobile/android.md
Outdated
@@ -244,41 +248,38 @@ org.pytorch.Tensor | |||
|
|||
If the reader is familiar with pytorch python api, we can think that org.pytorch.Tensor represents torch.tensor, org.pytorch.Module torch.Module<?>, while org.pytorch.IValue represents value of TorchScript variable, supporting all its types. ( https://pytorch.org/docs/stable/jit.html#types ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Capitalization "pytorch python api" --> "PyTorch Python API"
- Remove the <?> after Module
- Remove spaces before and after parenthesis around the url
Revision:
"If the reader is familiar with [the PyTorch Python API], we can think [of] org.pytorch.Tensor [representing] torch.tensor, org.pytorch.Module [representing] torch.Module, [and] org.pytorch.IValue [representing the] of TorchScript [the] variable, supporting all its types.
_mobile/android.md
Outdated
|
||
Java’s primitive type byte is signed and java does not have unsigned 8 bit type. For dtype=uint8 api uses byte that will be reinterpretted as uint8 on native side. On java side unsigned value of byte can be read as (byte & 0xFF). | ||
Java’s primitive type byte is signed and java does not have unsigned 8 bit type. For dtype=uint8 api uses byte that will be reinterpretted as uint8 on native side. On java side unsigned value of byte can be read as `byte & 0xFF`. | ||
|
||
#### Tensor content layout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Capitalization "Tensor Content Layout"
_mobile/android.md
Outdated
|
||
IValue represents a TorchScript variable that can be one of the supported (by torchscript) types ( https://pytorch.org/docs/stable/jit.html#types ). IValue is a tagged union. For every supported type it has a factory method, method to check the type and a getter method to retrieve a value. | ||
Getters throw IllegalStateException if called for inappropriate type. | ||
IValue represents a TorchScript variable that can be one of the supported (by torchscript) types ( [https://pytorch.org/docs/stable/jit.html#types](https://pytorch.org/docs/stable/jit.html#types) ). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hyperlink to the word types
types
_mobile/android.md
Outdated
|
||
### org.pytorch.Module (Module) | ||
[github](https://github.com/pytorch/pytorch/blob/master/android/pytorch_android/src/main/java/org/pytorch/Module.java) | ||
### [`org.pytorch.Module`](https://github.com/pytorch/pytorch/blob/master/android/pytorch_android/src/main/java/org/pytorch/Module.java) | ||
|
||
Module is a wrapper of torch.jit.ScriptModule (`torch::jit::script::Module` in pytorch c++ api) which can be constructed with factory method load providing absolute path to the file with serialized TorchScript. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Capitalization "PyTorch C++ API"
"... with [the] factory method"
47a50ad
to
b956376
Compare
_mobile/android.md
Outdated
@@ -12,7 +12,7 @@ published: true | |||
|
|||
## Quick start with a HelloWorld example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spelling and Capitalization: "Quickstart with a HelloWorld Example"
_mobile/android.md
Outdated
@@ -12,7 +12,7 @@ published: true | |||
|
|||
## Quick start with a HelloWorld example | |||
|
|||
[HelloWorld](https://github.com/pytorch/android-demo-app/tree/master/HelloWorldApp) is a simple image classification application that demonstrates how to use PyTorch android api. | |||
[HelloWorld](https://github.com/pytorch/android-demo-app/tree/master/HelloWorldApp) is a simple image classification application that demonstrates how to use PyTorch Android API. | |||
This application runs TorchScript serialized TorchVision pretrained resnet18 model on static image which is packaged inside the app as android asset. | |||
|
|||
#### 1. Model preparation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Capitalization "Model Preparation"
b956376
to
0f4b92a
Compare
…tate of android api
0f4b92a
to
c3ac4d7
Compare
…fixes_1007 [mobile][android] Tutorial corrections and aligning with the android api
No description provided.