Predict depth map from image using neural net with pytorch the depth map
The same code with train model included (run out of the box) could be download from: 1
The net was trained using the SUN3D dataset that can be downloaded from here
Based on paper Depth Map Prediction from a Single Image using a Multi-Scale Deep Network For more details
For using the trained net for prediction, no specific hardware is needed, but the net will run much faster on Nvidia GPU.
For training the net, an Nvidia GPU is needed (the net was trained on RTX 3090)
Create a environment with the required dependencies (Pytorch, torchvision, scipy and OpenCV, Open3D): conda env create -f environment.yml
This network was run with Python 3.88 Anaconda with Pytorch 1.8, (open3d)[http://www.open3d.org/] and OpenCV* package.
- Installing opencv for conda can usually be done using: pip install opencv-python or conda install opencv
- Train net or download code with pre-trained net weight from 1.
- Open RunOnImage.py
- Set image path to InputImage parameter
- Set the path to the trained net weights file in: Trained_model_path (If you downloaded the code with the pre-train network from, the model path is already set)
- Run script to get prediction display on the screen.
-
Open Train.py
-
Set the path to TransProteus train folders parameter "Sun3DDir" in the input parameter section .
-
Run the script
-
The trained net weight will appear in the folder defined in the logs_dir
-
For other optional training parameters, see the "Other training paramters" section in Train.py script
- Train net or download code with pre-trained net weight from: 1
- Open EvaluateModel.py
- Set a path to the trained net weights file in: Trained_model_path (If you downloaded the code with the pre-train network from the model path is already set)
- Set Test data folder path to the Sun3EvalDDir parameter. 5Run the script
For other parameters, see the Input parameters section.
See paper Depth Map Prediction from a Single Image using a Multi-Scale Deep Network For more details
Input image