forked from DLR-RM/BlenderProc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
47 lines (38 loc) · 1.56 KB
/
run.py
File metadata and controls
47 lines (38 loc) · 1.56 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
# blender --background --python run.py -- <config> [<args>]
import sys
import os
from sys import platform
# Make sure the current script directory is in PATH, so we can load other python modules
dir = "." # From CLI
if not dir in sys.path:
sys.path.append(dir)
# Add path to custom packages inside the blender main directory
if platform == "linux" or platform == "linux2":
packages_path = os.path.abspath(os.path.join(os.path.dirname(sys.executable), "custom-python-packages"))
elif platform == "darwin":
packages_path = os.path.abspath(os.path.join(os.path.dirname(sys.executable), "..", "Resources", "custom-python-packages"))
elif platform == "win32":
packages_path = os.path.abspath(os.path.join(os.path.dirname(sys.executable), "custom-python-packages"))
else:
raise Exception("This system is not supported yet: {}".format(platform))
sys.path.append(packages_path)
# Read args
argv = sys.argv
batch_index_file = None
if "--batch-process" in argv:
batch_index_file = argv[argv.index("--batch-process") + 1]
argv = argv[argv.index("--") + 1:]
working_dir = os.path.dirname(os.path.abspath(__file__))
from src.main.Pipeline import Pipeline
from src.utility.Utility import Utility
config_path = argv[0]
if batch_index_file == None:
pipeline = Pipeline(config_path, argv[1:], working_dir)
pipeline.run()
else:
with open(Utility.resolve_path(batch_index_file), "r") as f:
lines = f.readlines()
for line in lines:
args = line.split(" ")
pipeline = Pipeline(config_path, args, working_dir)
pipeline.run()