Python scripts to perform monocular depth estimation using Python with the Midas v2.1 small Tensorflow Lite model. Tested on Windows 10, Tensorflow 2.4.0 (Python 3.8).
Requirements
- OpenCV, Numpy and tflite (or tensorflow). pafy and youtube-dl are required for youtube video inference.
Installation
1
2
| pip install numpy opencv-python tflite tensorflow
pip install pafy youtube-dl
|
Midas v2.1 small (link)
- Input: RGB image of size 256 x 256 pixels.
- Output: Inverse relative depth map with 256 x256 pixels.
- Inference speed: - 30 FPS on Iphone 11 NPU and 22 FPS on OnePlus8 GPU (Snapdragon 865).
Examples
1
| python imageDepthEstimation.py
|
1
| python webcamDepthEstimation.py
|
1
| python videoDepthEstimation.py
|
# Inference video Example
Original video: https://youtu.be/TGadVbd-C-E (by Nagasaki Biopark)