qaihm-bot commited on
Commit
ae0b2e0
·
verified ·
1 Parent(s): 68e3059

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +158 -0
README.md ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: pytorch
3
+ license: mit
4
+ pipeline_tag: depth-estimation
5
+ tags:
6
+ - quantized
7
+ - android
8
+
9
+ ---
10
+
11
+ ![](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/midas_quantized/web-assets/model_demo.png)
12
+
13
+ # Midas-V2-Quantized: Optimized for Mobile Deployment
14
+ ## Quantized Deep Convolutional Neural Network model for depth estimation
15
+
16
+ Midas is designed for estimating depth at each point in an image.
17
+
18
+ This model is an implementation of Midas-V2-Quantized found [here](https://github.com/isl-org/MiDaS).
19
+ This repository provides scripts to run Midas-V2-Quantized on Qualcomm® devices.
20
+ More details on model performance across various devices, can be found
21
+ [here](https://aihub.qualcomm.com/models/midas_quantized).
22
+
23
+
24
+ ### Model Details
25
+
26
+ - **Model Type:** Depth estimation
27
+ - **Model Stats:**
28
+ - Model checkpoint: MiDaS_small
29
+ - Input resolution: 256x256
30
+ - Number of parameters: 16.6M
31
+ - Model size: 16.6 MB
32
+
33
+
34
+
35
+
36
+ | Device | Chipset | Target Runtime | Inference Time (ms) | Peak Memory Range (MB) | Precision | Primary Compute Unit | Target Model
37
+ | ---|---|---|---|---|---|---|---|
38
+ | Samsung Galaxy S23 Ultra (Android 13) | Snapdragon® 8 Gen 2 | TFLite | 1.154 ms | 0 - 2 MB | INT8 | NPU | [Midas-V2-Quantized.tflite](https://huggingface.co/qualcomm/Midas-V2-Quantized/blob/main/Midas-V2-Quantized.tflite)
39
+ | Samsung Galaxy S23 Ultra (Android 13) | Snapdragon® 8 Gen 2 | QNN Model Library | 1.482 ms | 0 - 275 MB | INT8 | NPU | [Midas-V2-Quantized.so](https://huggingface.co/qualcomm/Midas-V2-Quantized/blob/main/Midas-V2-Quantized.so)
40
+
41
+
42
+
43
+ ## Installation
44
+
45
+ This model can be installed as a Python package via pip.
46
+
47
+ ```bash
48
+ pip install "qai-hub-models[midas_quantized]"
49
+ ```
50
+
51
+
52
+
53
+ ## Configure Qualcomm® AI Hub to run this model on a cloud-hosted device
54
+
55
+ Sign-in to [Qualcomm® AI Hub](https://app.aihub.qualcomm.com/) with your
56
+ Qualcomm® ID. Once signed in navigate to `Account -> Settings -> API Token`.
57
+
58
+ With this API token, you can configure your client to run models on the cloud
59
+ hosted devices.
60
+ ```bash
61
+ qai-hub configure --api_token API_TOKEN
62
+ ```
63
+ Navigate to [docs](https://app.aihub.qualcomm.com/docs/) for more information.
64
+
65
+
66
+
67
+ ## Demo off target
68
+
69
+ The package contains a simple end-to-end demo that downloads pre-trained
70
+ weights and runs this model on a sample input.
71
+
72
+ ```bash
73
+ python -m qai_hub_models.models.midas_quantized.demo
74
+ ```
75
+
76
+ The above demo runs a reference implementation of pre-processing, model
77
+ inference, and post processing.
78
+
79
+ **NOTE**: If you want running in a Jupyter Notebook or Google Colab like
80
+ environment, please add the following to your cell (instead of the above).
81
+ ```
82
+ %run -m qai_hub_models.models.midas_quantized.demo
83
+ ```
84
+
85
+
86
+ ### Run model on a cloud-hosted device
87
+
88
+ In addition to the demo, you can also run the model on a cloud-hosted Qualcomm®
89
+ device. This script does the following:
90
+ * Performance check on-device on a cloud-hosted device
91
+ * Downloads compiled assets that can be deployed on-device for Android.
92
+ * Accuracy check between PyTorch and on-device outputs.
93
+
94
+ ```bash
95
+ python -m qai_hub_models.models.midas_quantized.export
96
+ ```
97
+
98
+ ```
99
+ Profile Job summary of Midas-V2-Quantized
100
+ --------------------------------------------------
101
+ Device: Snapdragon X Elite CRD (11)
102
+ Estimated Inference Time: 1.52 ms
103
+ Estimated Peak Memory Range: 0.46-0.46 MB
104
+ Compute Units: NPU (148) | Total (148)
105
+
106
+
107
+ ```
108
+
109
+
110
+
111
+
112
+ ## Run demo on a cloud-hosted device
113
+
114
+ You can also run the demo on-device.
115
+
116
+ ```bash
117
+ python -m qai_hub_models.models.midas_quantized.demo --on-device
118
+ ```
119
+
120
+ **NOTE**: If you want running in a Jupyter Notebook or Google Colab like
121
+ environment, please add the following to your cell (instead of the above).
122
+ ```
123
+ %run -m qai_hub_models.models.midas_quantized.demo -- --on-device
124
+ ```
125
+
126
+
127
+ ## Deploying compiled model to Android
128
+
129
+
130
+ The models can be deployed using multiple runtimes:
131
+ - TensorFlow Lite (`.tflite` export): [This
132
+ tutorial](https://www.tensorflow.org/lite/android/quickstart) provides a
133
+ guide to deploy the .tflite model in an Android application.
134
+
135
+
136
+ - QNN (`.so` export ): This [sample
137
+ app](https://docs.qualcomm.com/bundle/publicresource/topics/80-63442-50/sample_app.html)
138
+ provides instructions on how to use the `.so` shared library in an Android application.
139
+
140
+
141
+ ## View on Qualcomm® AI Hub
142
+ Get more details on Midas-V2-Quantized's performance across various devices [here](https://aihub.qualcomm.com/models/midas_quantized).
143
+ Explore all available models on [Qualcomm® AI Hub](https://aihub.qualcomm.com/)
144
+
145
+ ## License
146
+ - The license for the original implementation of Midas-V2-Quantized can be found
147
+ [here](https://github.com/isl-org/MiDaS/blob/master/LICENSE).
148
+ - The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf)
149
+
150
+ ## References
151
+ * [Towards Robust Monocular Depth Estimation: Mixing Datasets for Zero-shot Cross-dataset Transfer](https://arxiv.org/abs/1907.01341v3)
152
+ * [Source Model Implementation](https://github.com/isl-org/MiDaS)
153
+
154
+ ## Community
155
+ * Join [our AI Hub Slack community](https://qualcomm-ai-hub.slack.com/join/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA#/shared-invite/email) to collaborate, post questions and learn more about on-device AI.
156
+ * For questions or feedback please [reach out to us](mailto:[email protected]).
157
+
158
+