{"id":20493733,"url":"https://github.com/guanyingc/sdps-net","last_synced_at":"2025-09-10T07:45:18.558Z","repository":{"id":46988167,"uuid":"175965810","full_name":"guanyingc/SDPS-Net","owner":"guanyingc","description":"Learning Based Uncalibrated Photometric Stereo for Non-Lambertian Surface (CVPR 2019 Oral)","archived":false,"fork":false,"pushed_at":"2024-07-08T10:56:01.000Z","size":43501,"stargazers_count":187,"open_issues_count":2,"forks_count":32,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-10T05:10:36.638Z","etag":null,"topics":["deep-learning","non-lambertian","photometric-stereo","pytorch","uncalibrated"],"latest_commit_sha":null,"homepage":"http://guanyingc.github.io/SDPS-Net/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/guanyingc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-16T11:53:17.000Z","updated_at":"2025-04-08T02:12:44.000Z","dependencies_parsed_at":"2022-09-10T20:02:06.639Z","dependency_job_id":"6605928a-9153-42ba-9a24-aecd934f2af8","html_url":"https://github.com/guanyingc/SDPS-Net","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/guanyingc/SDPS-Net","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guanyingc%2FSDPS-Net","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guanyingc%2FSDPS-Net/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guanyingc%2FSDPS-Net/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guanyingc%2FSDPS-Net/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/guanyingc","download_url":"https://codeload.github.com/guanyingc/SDPS-Net/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guanyingc%2FSDPS-Net/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272922274,"owners_count":25015766,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-30T02:00:09.474Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deep-learning","non-lambertian","photometric-stereo","pytorch","uncalibrated"],"created_at":"2024-11-15T17:36:34.607Z","updated_at":"2025-08-30T23:44:53.954Z","avatar_url":"https://github.com/guanyingc.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SDPS-Net\n**[SDPS-Net: Self-calibrating Deep Photometric Stereo Networks, CVPR 2019 (Oral)](http://guanyingc.github.io/SDPS-Net/)**.\n\u003cbr\u003e\n[Guanying Chen](https://guanyingc.github.io), [Kai Han](http://www.hankai.org/), [Boxin Shi](http://alumni.media.mit.edu/~shiboxin/), [Yasuyuki Matsushita](http://www-infobiz.ist.osaka-u.ac.jp/en/member/matsushita/), [Kwan-Yee K. Wong](http://i.cs.hku.hk/~kykwong/)\n\u003cbr\u003e\n\nThis paper addresses the problem of learning based _uncalibrated_ photometric stereo for non-Lambertian surface.\n\u003cbr\u003e\n\u003cp align=\"center\"\u003e\n    \u003cimg src='data/images/buddha.gif' height=\"250\" \u003e\n    \u003cimg src='data/images/GT.png' height=\"250\" \u003e\n\u003c/p\u003e\n\n### _Changelog_\n- July 28, 2019: We have already updated the code to support Python 3.7 + PyTorch 1.10. To run the previous version (Python 2.7 + PyTorch 0.40), please checkout to `python2.7` branch first (by `git checkout python2.7`).\n\n## Dependencies\nSDPS-Net is implemented in [PyTorch](https://pytorch.org/) and tested with Ubuntu (14.04 and 16.04), please install PyTorch first following the official instruction. \n\n- Python 3.7 \n- PyTorch (version = 1.10)\n- torchvision\n- CUDA-9.0 # Skip this if you only have CPUs in your computer\n- numpy\n- scipy\n- scikit-image \n\nYou are highly recommended to use Anaconda and create a new environment to run this code.\n```shell\n# Create a new python3.7 environment named py3.7\nconda create -n py3.7 python=3.7\n\n# Activate the created environment\nsource activate py3.7\n\n# Example commands for installing the dependencies \nconda install pytorch torchvision cudatoolkit=9.0 -c pytorch\nconda install -c anaconda scipy \nconda install -c anaconda scikit-image \n\n# Download this code\ngit clone https://github.com/guanyingc/SDPS-Net.git\ncd SDPS-Net\n```\n## Overview\nWe provide:\n- Trained models\n    - LCNet for lighting calibration from input images\n    - NENet for normal estimation from input images and estimated lightings.\n- Code to test on DiLiGenT main dataset\n- Full code to train a new model, including codes for debugging, visualization and logging.\n\n## Testing\n### Download the trained models\n```\nsh scripts/download_pretrained_models.sh\n```\nIf the above command is not working, please manually download the trained models from BaiduYun ([LCNet and NENet](https://pan.baidu.com/s/10huOyPkfDSkDUK23_j4y1w?pwd=i5ha)) and put them in `./data/models/`.\n\n### Test SDPS-Net on the DiLiGenT main dataset\n```shell\n# Prepare the DiLiGenT main dataset\nsh scripts/prepare_diligent_dataset.sh\n# This command will first download and unzip the DiLiGenT dataset, and then centered crop \n# the original images based on the object mask with a margin size of 15 pixels.\n\n# Test SDPS-Net on DiLiGenT main dataset using all of the 96 image\nCUDA_VISIBLE_DEVICES=0 python eval/run_stage2.py --retrain data/models/LCNet_CVPR2019.pth.tar --retrain_s2 data/models/NENet_CVPR2019.pth.tar\n# Please check the outputs in data/models/\n\n# If you only have CPUs, please add the argument \"--cuda\" to disable the usage of GPU\npython eval/run_stage2.py --cuda --retrain data/models/LCNet_CVPR2019.pth.tar --retrain_s2 data/models/NENet_CVPR2019.pth.tar\n```\n\n### Test SDPS-Net on your own dataset\nYou have two options to test our method on your dataset. In the first option, you have to implement a customized Dataset class to load your data, which should not be difficult. Please refer to `datasets/UPS_DiLiGenT_main.py` for an example that loads the DiLiGenT main dataset.\n\nIf you don't want to implement your own Dataset class, you may try our `datasets/UPS_Custom_Dataset.py`. However, you have to first arrange your dataset in the same format as the `data/ToyPSDataset/`. Then you can call the following commands.\n```shell\nCUDA_VISIBLE_DEVICES=0 python eval/run_stage2.py --retrain data/models/LCNet_CVPR2019.pth.tar --retrain_s2 data/models/NENet_CVPR2019.pth.tar --benchmark UPS_Custom_Dataset --bm_dir /path/to/your/dataset\n\n# To test SDPS-Net on the ToyPSDataset, simply run\nCUDA_VISIBLE_DEVICES=0 python eval/run_stage2.py --retrain data/models/LCNet_CVPR2019.pth.tar --retrain_s2 data/models/NENet_CVPR2019.pth.tar --benchmark UPS_Custom_Dataset --bm_dir data/ToyPSDataset/\n# Please check the outputs in data/models/\n```\nYou may find input arguments in `run_model_opts.py` (particularly `--have_l_dirs`, `--have_l_ints`, and `--have_gt_n`) useful when testing your own dataset.\n\n## Training\nWe adopted the publicly available synthetic [PS Blobby and Sculpture datasets](https://github.com/guanyingc/PS-FCN) for training.\nTo train a new SDPS-Net model, please follow the following steps:\n\n### Download the training data\n```shell\n# The total size of the zipped synthetic datasets is 4.7+19=23.7 GB \n# and it takes some times to download and unzip the datasets.\nsh scripts/download_synthetic_datasets.sh\n```\nIf the above command is not working, please manually download the training datasets from BaiduYun ([PS Sculpture Dataset and PS Blobby Dataset](https://pan.baidu.com/s/1WUVu9ibIBh4wM1shTXBuNw?pwd=snyc) and put them in `./data/datasets/`.\n\n### First stage: train Lighting Calibration Network (LCNet)\n```shell\n# Train LCNet on synthetic datasets using 32 input images\nCUDA_VISIBLE_DEVICES=0 python main_stage1.py --in_img_num 32\n# Please refer to options/base_opt.py and options/stage1_opt.py for more options\n\n# You can find checkpoints and results in data/logdir/\n# It takes about 20 hours to train LCNet on a single Titan X Pascal GPU.\n```\n### Second stage: train Normal Estimation Network (NENet)\n```shell\n# Train NENet on synthetic datasets using 32 input images\nCUDA_VISIBLE_DEVICES=0 python main_stage2.py --in_img_num 32 --retrain data/logdir/path/to/checkpointDirOfLCNet/checkpoint20.pth.tar\n# Please refer to options/base_opt.py and options/stage2_opt.py for more options\n\n# You can find checkpoints and results in data/logdir/\n# It takes about 26 hours to train NENet on a single Titan X Pascal GPU.\n```\n\n## FAQ\n\n#### Q1: How to test SDPS-Net on other datasets?\n- You can implement a customized Dataset class to load your data. You may also use the provided `datasets/UPS_Custom_Dataset.py` Dataset class to load your data. However, you have to first arrange your dataset in the same format as the `data/ToyPSDataset/`. Precomputed results on DiLiGenT main dataset, Gourd\\\u0026Apple dataset, Light Stage Dataset and Synthetic Test dataset are available upon request.\n\n#### Q2: What should I do if I have problem in running your code?\n- Please create an issue if you encounter errors when trying to run the code. Please also feel free to submit a bug report.\n\n#### Q3: Could I run your code only using CPUs?\n- The good news is that you can simply append `--cuda` in your command to disable the usage of GPU. The running time for the testing on DiLiGenT benchmark using CPUs is still bearable (should be less than 20 minutes). However, it is EXTREMELY SLOW for training! \n\n## Citation\nIf you find this code or the provided models useful in your research, please consider cite: \n```\n@inproceedings{chen2019SDPS_Net,\n  title={SDPS-Net: Self-calibrating Deep Photometric Stereo Networks},\n  author={Chen, Guanying and Han, Kai and Shi, Boxin and Matsushita, Yasuyuki and Wong, Kwan-Yee~K.},\n  booktitle={CVPR},\n  year={2019}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguanyingc%2Fsdps-net","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguanyingc%2Fsdps-net","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguanyingc%2Fsdps-net/lists"}