-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
42 lines (32 loc) · 1.31 KB
/
main.py
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
import argparse
import os
from pathlib import Path
from xlib import appargs as lib_appargs
from rich.traceback import install
install()
def main():
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers()
run_parser = subparsers.add_parser( "run", help="Run the application.")
run_subparsers = run_parser.add_subparsers()
def run_FaceFilterLive(args):
userdata_path = Path(args.userdata_dir)
lib_appargs.set_arg_bool('NO_CUDA', args.no_cuda)
print('Running FaceFilterLive.')
from app.FaceFilterLiveApp import FaceFilterLiveApp
FaceFilterLiveApp(userdata_path=userdata_path).run()
p = run_subparsers.add_parser('FaceFilterLive')
p.add_argument('--userdata-dir', default=None, action=fixPathAction, help="Workspace directory.")
p.add_argument('--no-cuda', action="store_true", default=False, help="Disable CUDA.")
p.set_defaults(func=run_FaceFilterLive)
def bad_args(arguments):
parser.print_help()
exit(0)
parser.set_defaults(func=bad_args)
args = parser.parse_args()
args.func(args)
class fixPathAction(argparse.Action):
def __call__(self, parser, namespace, values, option_string=None):
setattr(namespace, self.dest, os.path.abspath(os.path.expanduser(values)))
if __name__ == '__main__':
main()