-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
68 lines (61 loc) · 2.04 KB
/
main.py
File metadata and controls
68 lines (61 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import sys
import os
import argparse
import glob
import multiprocessing as mp
from pathlib import Path
from processing.image_processor import LightEstimator
from utils.logging_utils import setup_logging
def get_parser():
parser = argparse.ArgumentParser(description="Detectron2 + MoGe: Object-Shadow 3D Estimation")
parser.add_argument(
"--config-file",
default="../SSIS/configs/SSIS/MS_R_101_BiFPN_SSISv2_demo.yaml",
metavar="FILE",
help="Path to config file"
)
parser.add_argument(
"--input",
default="./",
help="Path to input image or directory"
)
parser.add_argument(
"--output",
default="./result/",
help="Output directory"
)
parser.add_argument(
"--confidence-threshold",
type=float,
default=0.1,
help="Detection confidence threshold"
)
parser.add_argument(
"--opts",
default=[],
nargs=argparse.REMAINDER,
help="Modify config options using command-line"
)
return parser
if __name__ == "__main__":
# Configure environment paths
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../SSIS")))
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../MoGe")))
mp.set_start_method("spawn", force=True)
args = get_parser().parse_args()
setup_logging()
# Validate paths
if not Path(args.config_file).exists():
raise FileNotFoundError(f"Config file {args.config_file} not found!")
if not Path(args.input).exists():
raise FileNotFoundError(f"Input path {args.input} not found!")
# Initialize and process
estimator = LightEstimator(args)
input_paths = []
if os.path.isdir(args.input):
for ext in ('*.png', '*.jpg', '*.jpeg'):
input_paths.extend(glob.glob(os.path.join(args.input, ext)))
else:
input_paths = [args.input]
for path in tqdm.tqdm(input_paths, desc="Processing Images"):
estimator.process_image(path)