Instructions to use litert-community/resnet50 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use litert-community/resnet50 with LiteRT:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Add channelwise INT8 ResNet50 artifact
Browse files- README.md +52 -14
- resnet50_int8_channelwise.tflite +3 -0
README.md
CHANGED
|
@@ -41,12 +41,49 @@ The ResNet-50 architecture is a convolutional neural network pre-trained on the
|
|
| 41 |
|
| 42 |
## Model description
|
| 43 |
|
| 44 |
-
The model was converted from a checkpoint from PyTorch Vision.
|
| 45 |
|
| 46 |
-
The original model has:
|
| 47 |
-
acc@1 (on ImageNet-1K): 76.13%
|
| 48 |
-
acc@5 (on ImageNet-1K): 92.862%
|
| 49 |
-
num_params: 25,557,032
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
## Intended uses & limitations
|
| 52 |
|
|
@@ -54,9 +91,9 @@ The model files were converted from pretrained weights from PyTorch Vision. The
|
|
| 54 |
|
| 55 |
## How to Use
|
| 56 |
|
| 57 |
-
**1. Install Dependencies** Ensure your Python environment is set up with the required libraries. Run the following command in your terminal:
|
| 58 |
|
| 59 |
-
```bash
|
| 60 |
pip install numpy Pillow huggingface_hub ai-edge-litert
|
| 61 |
```
|
| 62 |
|
|
@@ -127,16 +164,17 @@ if __name__ == "__main__":
|
|
| 127 |
|
| 128 |
**4. Execute the Python Script** Run the below command:
|
| 129 |
|
| 130 |
-
```bash
|
| 131 |
python classify.py --image cat.jpg
|
| 132 |
```
|
| 133 |
|
| 134 |
### BibTeX entry and citation info
|
| 135 |
|
| 136 |
```bibtex
|
| 137 |
-
@inproceedings{he2016deep,
|
| 138 |
-
title={Deep residual learning for image recognition},
|
| 139 |
-
author={He, Kaiming and Zhang, Xiangyu and Ren, Shaoqing and Sun, Jian},
|
| 140 |
-
booktitle={Proceedings of the IEEE conference on computer vision and pattern recognition}, pages={770--778},
|
| 141 |
-
year={2016}
|
| 142 |
-
}
|
|
|
|
|
|
| 41 |
|
| 42 |
## Model description
|
| 43 |
|
| 44 |
+
The model was converted from a checkpoint from PyTorch Vision.
|
| 45 |
|
| 46 |
+
The original model has:
|
| 47 |
+
acc@1 (on ImageNet-1K): 76.13%
|
| 48 |
+
acc@5 (on ImageNet-1K): 92.862%
|
| 49 |
+
num_params: 25,557,032
|
| 50 |
+
|
| 51 |
+
## Available Model Files
|
| 52 |
+
|
| 53 |
+
| File | Description | Quantization |
|
| 54 |
+
|---|---|---|
|
| 55 |
+
| `resnet50.tflite` | Floating-point LiteRT/TFLite model. | Floating-point weights and activations. |
|
| 56 |
+
| `resnet50_dynamic_wi8_afp32.tflite` | Dynamic weight-quantized LiteRT/TFLite model. | INT8 weights with floating-point activations. |
|
| 57 |
+
| `resnet50_int8_channelwise.tflite` | Static INT8 LiteRT/TFLite model. | INT8 weights and INT8 activations, with channelwise weight quantization. |
|
| 58 |
+
|
| 59 |
+
## Quantization Schema
|
| 60 |
+
|
| 61 |
+
`resnet50_int8_channelwise.tflite` was quantized with AI Edge Quantizer's
|
| 62 |
+
static W8A8 recipe (`STATIC_WI8_AI8`).
|
| 63 |
+
|
| 64 |
+
The schema is:
|
| 65 |
+
|
| 66 |
+
| Tensor group | Quantization |
|
| 67 |
+
|---|---|
|
| 68 |
+
| Weights | INT8, symmetric, channelwise quantization. |
|
| 69 |
+
| Activations | INT8, asymmetric, tensorwise quantization. |
|
| 70 |
+
| Model input | INT8, tensorwise quantized NCHW image tensor with shape `[1, 3, 224, 224]`. |
|
| 71 |
+
| Model output | INT8, tensorwise quantized logits tensor with shape `[1, 1000]`. |
|
| 72 |
+
|
| 73 |
+
Calibration used real ImageNet validation images with the TorchVision ResNet
|
| 74 |
+
preprocessing flow. When using APIs that expose raw tensor buffers, prepare the
|
| 75 |
+
input and output using the quantization parameters stored in the model.
|
| 76 |
+
|
| 77 |
+
## Runtime Compatibility
|
| 78 |
+
|
| 79 |
+
These artifacts are intended for LiteRT CPU and GPU execution. The static INT8
|
| 80 |
+
channelwise artifact is also suitable for Qualcomm NPU deployment through the
|
| 81 |
+
LiteRT Qualcomm compiler plugin and QNN AOT compilation on compatible Qualcomm
|
| 82 |
+
devices.
|
| 83 |
+
|
| 84 |
+
MediaTek NPU enablement for the static INT8 channelwise artifact is still under
|
| 85 |
+
validation, so this repository does not mark that artifact as MediaTek-NPU-ready
|
| 86 |
+
yet. Use LiteRT CPU/GPU or a compatible Qualcomm NPU path for that file today.
|
| 87 |
|
| 88 |
## Intended uses & limitations
|
| 89 |
|
|
|
|
| 91 |
|
| 92 |
## How to Use
|
| 93 |
|
| 94 |
+
**1. Install Dependencies** Ensure your Python environment is set up with the required libraries. Run the following command in your terminal:
|
| 95 |
|
| 96 |
+
```bash
|
| 97 |
pip install numpy Pillow huggingface_hub ai-edge-litert
|
| 98 |
```
|
| 99 |
|
|
|
|
| 164 |
|
| 165 |
**4. Execute the Python Script** Run the below command:
|
| 166 |
|
| 167 |
+
```bash
|
| 168 |
python classify.py --image cat.jpg
|
| 169 |
```
|
| 170 |
|
| 171 |
### BibTeX entry and citation info
|
| 172 |
|
| 173 |
```bibtex
|
| 174 |
+
@inproceedings{he2016deep,
|
| 175 |
+
title={Deep residual learning for image recognition},
|
| 176 |
+
author={He, Kaiming and Zhang, Xiangyu and Ren, Shaoqing and Sun, Jian},
|
| 177 |
+
booktitle={Proceedings of the IEEE conference on computer vision and pattern recognition}, pages={770--778},
|
| 178 |
+
year={2016}
|
| 179 |
+
}
|
| 180 |
+
```
|
resnet50_int8_channelwise.tflite
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4b47a9100b1ccd66c1dd5ad59c2ef6bc1ae43dbda240cd9354e1ea874a6f0ebc
|
| 3 |
+
size 26307408
|