-
Notifications
You must be signed in to change notification settings - Fork 1
/
webui.py
156 lines (141 loc) · 4.64 KB
/
webui.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
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import gradio as gr
import argparse
class WebUI:
def __init__(self, args: argparse.Namespace):
super().__init__()
self.root_dir = args.root_dir # root directory
self.run_in_new_terminal = args.run_in_new_terminal # run in new terminal
self.demo = gr.Blocks()
self.tabs = []
if args.enable_trainer_tab:
from modules.trainer_tab import TrainerTab
self.trainer_tab = TrainerTab(args)
self.tabs.append(self.trainer_tab)
if args.enable_visualizer_tab:
from modules.visualizer_tab import VisualizerTab
self.visualizer_tab = VisualizerTab(args)
self.tabs.append(self.visualizer_tab)
if args.enable_data_processor_tab:
from modules.data_processor_tab import DataProcessorTab
self.data_processor_tab = DataProcessorTab(args)
self.tabs.append(self.data_processor_tab)
if args.enable_exporter_tab:
from modules.exporter_tab import ExporterTab
self.exporter_tab = ExporterTab(args)
self.tabs.append(self.exporter_tab)
self.setup_ui()
def setup_ui(self):
with self.demo:
for tab in self.tabs:
tab.setup_ui()
def launch(self, **kwargs):
self.demo.launch(**kwargs)
if __name__ == "__main__":
parser = argparse.ArgumentParser(
prog="nerfstudio webui",
description="A gradio based web-ui for nerfstudio.",
epilog="Source: https://github.com/nerfstudio-project/nerfstudio-webui",
)
parser.add_argument(
"--device_type", type=str, default="cuda", help="Type of the devices"
)
parser.add_argument("--dist_url", type=str, default="auto", help="Distributed URL")
parser.add_argument("--machine_rank", type=int, default=0, help="Machine rank")
parser.add_argument(
"--num_devices", type=int, default=1, help="Number of processing (GPU) devices"
)
parser.add_argument(
"--num_machines", type=int, default=1, help="Number of available machines"
)
parser.add_argument(
"--root_dir",
type=str,
default="./",
help="Root directory for data selection in web-ui",
)
parser.add_argument(
"--run_in_new_terminal",
type=bool,
default=False,
help="Run commands in new terminal",
)
parser.add_argument(
"--share", type=bool, default=False, help="Create public gradio share link"
)
parser.add_argument(
"--server_name",
type=str,
default="0.0.0.0",
help="IP address or hostname of the web-ui server",
)
parser.add_argument(
"--server_port", type=int, default=7860, help="Port of the web-ui server"
)
parser.add_argument(
"--websocket_port",
type=int,
default=7007,
help="Port of the Viser websocket, choose 0 to pick random free port",
)
parser.add_argument(
"--enable_trainer_tab",
action="store_true",
default=True,
help="Enable the Trainer tab",
)
parser.add_argument(
"--disable_trainer_tab",
action="store_false",
dest="enable_trainer_tab",
help="Disable the Trainer tab",
)
parser.add_argument(
"--enable_visualizer_tab",
action="store_true",
default=True,
help="Enable the Visualizer tab",
)
parser.add_argument(
"--disable_visualizer_tab",
action="store_false",
dest="enable_visualizer_tab",
help="Disable the Visualizer tab",
)
parser.add_argument(
"--enable_data_processor_tab",
action="store_true",
default=True,
help="Enable the Data Processor tab",
)
parser.add_argument(
"--disable_data_processor_tab",
action="store_false",
dest="enable_data_processor_tab",
help="Disable the Data Processor tab",
)
parser.add_argument(
"--enable_exporter_tab",
action="store_true",
default=True,
help="Enable the Exporter tab",
)
parser.add_argument(
"--disable_exporter_tab",
action="store_false",
dest="enable_exporter_tab",
help="Disable the Exporter tab",
)
parser.add_argument(
"--use_external_methods",
action="store_true",
default=False,
help="Use external methods in the Trainer tab",
)
parsed_args: argparse.Namespace = parser.parse_args()
app = WebUI(parsed_args)
app.launch(
inbrowser=True,
share=parsed_args.share,
server_name=parsed_args.server_name,
server_port=parsed_args.server_port,
)