Skip to content

Commit 103220f

Browse files
author
Ruilong Li
committed
init
0 parents  commit 103220f

32 files changed

+1878
-0
lines changed

.gitignore

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
# lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
MANIFEST
27+
28+
# PyInstaller
29+
# Usually these files are written by a python script from a template
30+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
31+
*.manifest
32+
*.spec
33+
34+
# Installer logs
35+
pip-log.txt
36+
pip-delete-this-directory.txt
37+
38+
# Unit test / coverage reports
39+
htmlcov/
40+
.tox/
41+
.coverage
42+
.coverage.*
43+
.cache
44+
nosetests.xml
45+
coverage.xml
46+
*.cover
47+
.hypothesis/
48+
.pytest_cache/
49+
50+
# Translations
51+
*.mo
52+
*.pot
53+
54+
# Django stuff:
55+
*.log
56+
local_settings.py
57+
db.sqlite3
58+
59+
# Flask stuff:
60+
instance/
61+
.webassets-cache
62+
63+
# Scrapy stuff:
64+
.scrapy
65+
66+
# Sphinx documentation
67+
docs/_build/
68+
69+
# PyBuilder
70+
target/
71+
72+
# Jupyter Notebook
73+
.ipynb_checkpoints
74+
75+
# pyenv
76+
.python-version
77+
78+
# celery beat schedule file
79+
celerybeat-schedule
80+
81+
# SageMath parsed files
82+
*.sage.py
83+
84+
# Environments
85+
.env
86+
.venv
87+
env/
88+
venv/
89+
ENV/
90+
env.bak/
91+
venv.bak/
92+
93+
# Spyder project settings
94+
.spyderproject
95+
.spyproject
96+
97+
# Rope project settings
98+
.ropeproject
99+
100+
# mkdocs documentation
101+
/site
102+
103+
# mypy
104+
.mypy_cache/
105+
106+
data/
107+
108+
.DS_Store

README.md

Whitespace-only changes.

RTL/main.py

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
import sys
2+
import os
3+
import argparse
4+
import glob
5+
6+
import torch
7+
8+
from monoport.lib.common.config import get_cfg_defaults
9+
from monoport.lib.modeling.MonoPortNet import MonoPortNet
10+
from monoport.lib.modeling.MonoPortNet import PIFuNetG, PIFuNetC
11+
12+
import streamer_pytorch as streamer
13+
import human_inst_seg
14+
15+
########################################
16+
## load configs
17+
########################################
18+
parser = argparse.ArgumentParser()
19+
parser.add_argument(
20+
'-cfg', '--config_file', default=None, type=str,
21+
help='path of the yaml config file')
22+
parser.add_argument(
23+
'--camera', action="store_true")
24+
parser.add_argument(
25+
'--images', default="", nargs="*")
26+
parser.add_argument(
27+
'--image_folder', default=None)
28+
parser.add_argument(
29+
'--videos', default="", nargs="*")
30+
parser.add_argument(
31+
'--loop', action="store_true")
32+
parser.add_argument(
33+
'--vis', action="store_true")
34+
parser.add_argument(
35+
'--use_VRweb', action="store_true")
36+
37+
argv = sys.argv[1:sys.argv.index('--')]
38+
args = parser.parse_args(argv)
39+
opts = sys.argv[sys.argv.index('--') + 1:]
40+
41+
cfg = get_cfg_defaults()
42+
if args.config_file is not None:
43+
cfg.merge_from_file(args.config_file)
44+
cfg.merge_from_list(opts)
45+
cfg.freeze()
46+
47+
48+
########################################
49+
## access avaiable GPUs
50+
########################################
51+
device_count = torch.cuda.device_count()
52+
if device_count == 1:
53+
cuda_backbone_G='cuda:0'
54+
cuda_backbone_C='cuda:0'
55+
cuda_recon='cuda:0'
56+
cuda_color='cuda:0'
57+
elif device_count == 2:
58+
cuda_backbone_G='cuda:1'
59+
cuda_backbone_C='cuda:1'
60+
cuda_recon='cuda:0'
61+
cuda_color='cuda:1'
62+
else:
63+
raise NotImplementedError
64+
65+
66+
########################################
67+
## load networks
68+
########################################
69+
print (f'loading networkG from {cfg.netG.ckpt_path} ...')
70+
netG = MonoPortNet(cfg.netG)
71+
assert os.path.exists(cfg.netG.ckpt_path), 'we need a ckpt to run RTL demo.'
72+
netG.load_legacy_pifu(cfg.netG.ckpt_path)
73+
74+
netG.image_filter = netG.image_filter.to(cuda_backbone_G)
75+
netG.surface_classifier = netG.surface_classifier.to(cuda_recon)
76+
77+
print (f'loading networkC from {cfg.netC.ckpt_path} ...')
78+
netC = MonoPortNet(cfg.netC)
79+
assert os.path.exists(cfg.netC.ckpt_path), 'we need a ckpt to run RTL demo.'
80+
netC.load_legacy_pifu(cfg.netC.ckpt_path)
81+
82+
netC.image_filter = netC.image_filter.to(cuda_backbone_C)
83+
netC.surface_classifier = netC.surface_classifier.to(cuda_color)
84+
85+
86+
87+
########################################
88+
## initialize data streamer
89+
########################################
90+
print (f'initialize data streamer ...')
91+
if args.camera:
92+
data_stream = streamer.CaptureStreamer()
93+
elif len(args.videos) > 0:
94+
data_stream = streamer.VideoListStreamer(
95+
args.videos * (10 if args.loop else 1))
96+
elif len(args.images) > 0:
97+
data_stream = streamer.ImageListStreamer(
98+
args.images * (10000 if args.loop else 1))
99+
elif args.image_folder is not None:
100+
images = sorted(glob.glob(args.image_folder+'/*.jpg'))
101+
images += sorted(glob.glob(args.image_folder+'/*.png'))
102+
data_stream = streamer.ImageListStreamer(
103+
images * (10 if args.loop else 1))
104+
105+

RTL/run_pifu.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
python RTL/main.py \
2+
--image_folder /home/rui/local/projects/PIFu-RealTime/zenTelePort/data/recording/test \
3+
-- \
4+
netG.projection orthogonal \
5+
netG.backbone.IMF PIFuHGFilters \
6+
netG.normalizer.IMF PIFuNomalizer \
7+
netG.head.IMF PIFuNetGMLP \
8+
netG.ckpt_path ./data/PIFu/net_G \
9+
netC.projection orthogonal \
10+
netC.backbone.IMF PIFuResBlkFilters \
11+
netC.normalizer.IMF PIFuNomalizer \
12+
netC.head.IMF PIFuNetCMLP \
13+
netC.ckpt_path ./data/PIFu/net_C

monoport/__init__.py

Whitespace-only changes.

monoport/lib/common/config.py

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
from yacs.config import CfgNode as CN
2+
3+
4+
_C = CN()
5+
6+
# needed by trainer
7+
_C.name = 'default'
8+
_C.checkpoints_path = '../data/checkpoints/'
9+
_C.results_path = '../data/results/'
10+
_C.learning_rate = 1e-3
11+
_C.weight_decay = 0.0
12+
_C.momentum = 0.0
13+
_C.optim = 'RMSprop'
14+
_C.schedule = [40, 60]
15+
_C.gamma = 0.1
16+
_C.resume = False
17+
18+
# needed by train()
19+
_C.batch_size = 4
20+
_C.num_threads = 4
21+
_C.num_epoch = 100
22+
_C.freq_plot = 10
23+
_C.freq_save = 100
24+
_C.freq_eval = 100
25+
_C.freq_vis = 100
26+
27+
28+
# --- netG options ---
29+
_C.netG = CN()
30+
_C.netG.ckpt_path = ''
31+
_C.netG.projection = 'orthogonal'
32+
33+
# --- netG:backbone options ---
34+
_C.netG.backbone = CN()
35+
_C.netG.backbone.IMF = 'PIFuHGFilters'
36+
37+
# --- netG:normalizer options ---
38+
_C.netG.normalizer = CN()
39+
_C.netG.normalizer.IMF = 'PIFuNomalizer'
40+
_C.netG.normalizer.soft_onehot = False
41+
_C.netG.normalizer.soft_dim = 64
42+
43+
# --- netG:head options ---
44+
_C.netG.head = CN()
45+
_C.netG.head.IMF = 'PIFuNetGMLP'
46+
47+
# --- netG:loss options ---
48+
_C.netG.loss = CN()
49+
_C.netG.loss.IMF = 'MSE'
50+
51+
52+
# --- netC options ---
53+
_C.netC = CN()
54+
_C.netC.ckpt_path = ''
55+
_C.netC.projection = 'orthogonal'
56+
57+
# --- netC:backbone options ---
58+
_C.netC.backbone = CN()
59+
_C.netC.backbone.IMF = 'PIFuResBlkFilters'
60+
61+
# --- netC:normalizer options ---
62+
_C.netC.normalizer = CN()
63+
_C.netC.normalizer.IMF = 'PIFuNomalizer'
64+
_C.netC.normalizer.soft_onehot = False
65+
_C.netC.normalizer.soft_dim = 64
66+
67+
# --- netC:head options ---
68+
_C.netC.head = CN()
69+
_C.netC.head.IMF = 'PIFuNetCMLP'
70+
71+
# --- netC:loss options ---
72+
_C.netC.loss = CN()
73+
_C.netC.loss.IMF = 'L1'
74+
75+
76+
# --- dataset options ---
77+
_C.dataset = CN()
78+
_C.dataset.aug_bri = 0.0
79+
_C.dataset.aug_con = 0.0
80+
_C.dataset.aug_sat = 0.0
81+
_C.dataset.aug_hue = 0.0
82+
_C.dataset.blur = 0
83+
_C.dataset.num_sample_geo = 5000
84+
_C.dataset.num_sample_color = 0
85+
_C.dataset.sigma_geo = 0.05
86+
_C.dataset.sigma_color = 0.001
87+
_C.dataset.pre_load = False
88+
89+
90+
def get_cfg_defaults():
91+
"""Get a yacs CfgNode object with default values for my_project."""
92+
# Return a clone so that the defaults will not be altered
93+
# This is for the "local variable" use pattern
94+
return _C.clone()
95+
96+
# Alternatively, provide a way to import the defaults as
97+
# a global singleton:
98+
# cfg = _C # users can `from config import cfg`
99+
100+
# cfg = get_cfg_defaults()
101+
# cfg.merge_from_file('../configs/example.yaml')
102+
103+
# # Now override from a list (opts could come from the command line)
104+
# opts = ['dataset.root', '../data/XXXX', 'learning_rate', '1e-2']
105+
# cfg.merge_from_list(opts)
106+

0 commit comments

Comments
 (0)