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
Update validated TorchVision exports and compatibility documentation
Browse filesPublish the reviewed model files and current CPU/GPU/NPU compatibility table.
- README.md +14 -16
- resnet50.tflite +2 -2
- resnet50_int8_channelwise.tflite +2 -2
README.md
CHANGED
|
@@ -43,9 +43,9 @@ The ResNet-50 architecture is a convolutional neural network pre-trained on the
|
|
| 43 |
|
| 44 |
The model was converted from a checkpoint from PyTorch Vision.
|
| 45 |
|
| 46 |
-
The
|
| 47 |
-
acc@1 (on ImageNet-1K):
|
| 48 |
-
acc@5 (on ImageNet-1K):
|
| 49 |
num_params: 25,557,032
|
| 50 |
|
| 51 |
## Available Model Files
|
|
@@ -74,14 +74,12 @@ 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 |
-
##
|
| 78 |
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
Enablement for other NPU backends is still under validation.
|
| 85 |
|
| 86 |
## Intended uses & limitations
|
| 87 |
|
|
@@ -111,20 +109,20 @@ from ai_edge_litert.compiled_model import CompiledModel
|
|
| 111 |
def preprocess(img: Image.Image) -> np.ndarray:
|
| 112 |
img = img.convert("RGB")
|
| 113 |
w, h = img.size
|
| 114 |
-
s =
|
| 115 |
if w < h:
|
| 116 |
-
img = img.resize((s, int(
|
| 117 |
else:
|
| 118 |
-
img = img.resize((int(
|
| 119 |
-
left = (img.size[0] - 224) /
|
| 120 |
-
top = (img.size[1] - 224) /
|
| 121 |
img = img.crop((left, top, left + 224, top + 224))
|
| 122 |
|
| 123 |
x = np.asarray(img, dtype=np.float32) / 255.0
|
| 124 |
x = (x - np.array([0.485, 0.456, 0.406], dtype=np.float32)) / np.array(
|
| 125 |
[0.229, 0.224, 0.225], dtype=np.float32
|
| 126 |
)
|
| 127 |
-
return np.
|
| 128 |
|
| 129 |
def main():
|
| 130 |
ap = argparse.ArgumentParser()
|
|
|
|
| 43 |
|
| 44 |
The model was converted from a checkpoint from PyTorch Vision.
|
| 45 |
|
| 46 |
+
The source checkpoint has:
|
| 47 |
+
acc@1 (on ImageNet-1K): 80.858%
|
| 48 |
+
acc@5 (on ImageNet-1K): 95.434%
|
| 49 |
num_params: 25,557,032
|
| 50 |
|
| 51 |
## Available Model Files
|
|
|
|
| 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 |
+
## Compatibility
|
| 78 |
|
| 79 |
+
| File | CPU | GPU | NPU |
|
| 80 |
+
|---|---|---|---|
|
| 81 |
+
| `resnet50.tflite` | Supported | Supported | N/A |
|
| 82 |
+
| `resnet50_int8_channelwise.tflite` | Supported | Not supported | Qualcomm / MediaTek |
|
|
|
|
|
|
|
| 83 |
|
| 84 |
## Intended uses & limitations
|
| 85 |
|
|
|
|
| 109 |
def preprocess(img: Image.Image) -> np.ndarray:
|
| 110 |
img = img.convert("RGB")
|
| 111 |
w, h = img.size
|
| 112 |
+
s = 232
|
| 113 |
if w < h:
|
| 114 |
+
img = img.resize((s, int(h * s / w)), Image.BILINEAR)
|
| 115 |
else:
|
| 116 |
+
img = img.resize((int(w * s / h), s), Image.BILINEAR)
|
| 117 |
+
left = int(round((img.size[0] - 224) / 2.0))
|
| 118 |
+
top = int(round((img.size[1] - 224) / 2.0))
|
| 119 |
img = img.crop((left, top, left + 224, top + 224))
|
| 120 |
|
| 121 |
x = np.asarray(img, dtype=np.float32) / 255.0
|
| 122 |
x = (x - np.array([0.485, 0.456, 0.406], dtype=np.float32)) / np.array(
|
| 123 |
[0.229, 0.224, 0.225], dtype=np.float32
|
| 124 |
)
|
| 125 |
+
return np.ascontiguousarray(x.transpose(2, 0, 1)[None])
|
| 126 |
|
| 127 |
def main():
|
| 128 |
ap = argparse.ArgumentParser()
|
resnet50.tflite
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b60ece2473934776b8de38244d1fc5d107ecebabd7080a1a19ea8c28a4643be5
|
| 3 |
+
size 102147184
|
resnet50_int8_channelwise.tflite
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b5a5bcd4cc610c8bc8afb48f8d220a1716a4a0d752b6d9f3ab0e7a8e65d4f23a
|
| 3 |
+
size 26305808
|