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).
- OpenCV, Numpy and tflite (or tensorflow). pafy and youtube-dl are required for youtube video inference.
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).
- Image inference:
python imageDepthEstimation.py
- Webcam inference:
python webcamDepthEstimation.py
- Video inference:
python videoDepthEstimation.py
Original video: https://youtu.be/TGadVbd-C-E (by Nagasaki Biopark)