Skip to content

File: DepthFlow/Webui.py

DepthFlow.Webui

WEBUI_OUTPUT

1
2
3
WEBUI_OUTPUT: Path = BrokenPath.recreate(
    DEPTHFLOW.DIRECTORIES.SYSTEM_TEMP / "WebUI"
)

The temporary output for the WebUI, cleaned at the start and after any render

DepthGradio

Source code in Projects/DepthFlow/DepthFlow/Webui.py
 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
@define(slots=False)
class DepthGradio:
    interface: gradio.Blocks = None
    fields: DotMap = Factory(DotMap)

    estimators = {
        "DepthAnything V2": DepthAnythingV2,
        "DepthAnything V1": DepthAnythingV1,
        "DepthPro": DepthPro,
        "ZoeDepth": ZoeDepth,
        "Marigold": Marigold,
    }

    upscalers = {
        "Upscayl": Upscayl,
        "Real-ESRGAN": Realesr,
        "Waifu2x": Waifu2x,
    }

    def simple(self, method: Callable, **options: Dict) -> Dict:
        """An ugly hack to avoid manually listing inputs and outputs"""
        show_progress = bool(options.get("outputs"))
        outputs = options.pop("outputs", set(DictUtils.rvalues(self.fields)))
        inputs = options.pop("inputs", set(DictUtils.rvalues(self.fields)))
        return dict(
            fn=method,
            inputs=inputs,
            outputs=outputs,
            show_progress=show_progress,
            **options,
        )

    def _estimator(self, user: Dict) -> BaseEstimator:
        return self.estimators[user[self.fields.estimator]]()

    def _upscaler(self, user: Dict) -> UpscalerBase:
        return self.upscalers[user[self.fields.upscaler]]()

    def estimate(self, user: Dict):
        if ((image := user[self.fields.image]) is None):
            return None
        yield {
            self.fields.depth:  self._estimator(user).estimate(image),
            self.fields.width:  image.size[0],
            self.fields.height: image.size[1]
        }

    def upscale(self, user: Dict):
        if ((image := user[self.fields.image]) is None):
            return gradio.Warning("The input image is empty")
        yield {self.fields.image: self._upscaler(user).upscale(image)}

    def _fit_resolution(self, user: Dict, target: Tuple[int, int]) -> Tuple[int, int]:
        if (user[self.fields.image] is None):
            raise GeneratorExit()
        width, height = user[self.fields.image].size
        return BrokenResolution().fit(
            old=(1920, 1080), new=target,
            ar=(width/height), multiple=1,
        )

    def fit_width(self, user: Dict):
        yield {self.fields.height: self._fit_resolution(user, (user[self.fields.width], None))[1]}

    def fit_height(self, user: Dict):
        yield {self.fields.width: self._fit_resolution(user, (None, user[self.fields.height]))[0]}

    def render(self, user: Dict):
        if (user[self.fields.image] is None):
            return gradio.Warning("The input image is empty")
        if (user[self.fields.depth] is None):
            return gradio.Warning("The input depthmap is empty")

        def worker():
            from DepthFlow.Scene import DepthScene
            scene = DepthScene(backend="headless")
            scene.set_estimator(self._estimator(user))
            scene.input(image=user[self.fields.image], depth=user[self.fields.depth])
            scene.aspect_ratio = None

            # Build and add any enabled preset class
            for preset in Actions.members():
                preset_name = preset.__name__
                preset_dict = self.fields.animation[preset_name]
                if (not preset_dict.enable):
                    continue
                if (not user[preset_dict.enable]):
                    continue
                scene.animation.add(preset(**{
                    key: user[item] for (key, item) in preset_dict.options.items()
                }))

            return scene.main(
                width=user[self.fields.width],
                height=user[self.fields.height],
                ssaa=user[self.fields.ssaa],
                fps=user[self.fields.fps],
                time=user[self.fields.time],
                loop=user[self.fields.loop],
                output=(WEBUI_OUTPUT/f"{uuid.uuid4()}.mp4"),
                noturbo=(not user[self.fields.turbopipe]),
            )[0]

        with ThreadPool() as pool:
            task = pool.submit(worker)
            yield {self.fields.video: task.result()}
            os.remove(task.result())

    def launch(self,
        port: Annotated[int, Option("--port", "-p",
            help="Port to run the WebUI on")]=None,
        server: Annotated[str, Option("--server",
            help="Server to run the WebUI on")]="0.0.0.0",
        share: Annotated[bool, Option("--share", "-s",
            help="Share the WebUI on the network")]=False,
        threads: Annotated[int,  Option("--threads", "-t",
            help="Number of maximum concurrent renders")]=4,
        browser: Annotated[bool, Option("--open", " /--no-open",
            help="Open the WebUI in the browser")]=True,
        block: Annotated[bool, Option("--block", "-b", " /--no-block",
            help="Holds the main thread until the WebUI is closed")]=True,
    ) -> gradio.Blocks:
        with gradio.Blocks(
            theme=gradio.themes.Ocean(
                font=(fonts.GoogleFont("Roboto Slab"),),
                font_mono=(fonts.GoogleFont("Fira Code"),),
                primary_hue=colors.emerald,
                spacing_size=sizes.spacing_sm,
                radius_size=sizes.radius_sm,
                text_size=sizes.text_sm,
            ),
            analytics_enabled=False,
            title="DepthFlow WebUI",
            fill_height=True,
            fill_width=True
        ) as self.interface:

            gradio.Markdown("# 🌊 DepthFlow")

            with gradio.Tab("Application"):
                with gradio.Row(equal_height=True):
                    with gradio.Column(variant="panel"):
                        self.fields.image = gradio.Image(scale=1,
                            sources=["upload", "clipboard"],
                            type="pil", label="Input image",
                            interactive=True,
                        )
                        with gradio.Row(equal_height=True):
                            self.fields.upscaler = gradio.Dropdown(
                                choices=list(self.upscalers.keys()),
                                value=list(self.upscalers.keys())[0],
                                label="Upscaler", scale=10
                            )
                            self.fields.upscale = gradio.Button(value="🚀 Upscale", scale=1)

                    with gradio.Column(variant="panel"):
                        self.fields.depth = gradio.Image(scale=1,
                            sources=["upload", "clipboard"],
                            type="pil", label="Depthmap"
                        )
                        with gradio.Row(equal_height=True):
                            self.fields.estimator = gradio.Dropdown(
                                choices=list(self.estimators.keys()),
                                value=list(self.estimators.keys())[0],
                                label="Depth Estimator", scale=10
                            )
                            self.fields.estimate = gradio.Button(value="🔎 Estimate", scale=1)

                    with gradio.Column(variant="panel"):
                        self.fields.video = gradio.Video(scale=1,
                            label="Output video",
                            interactive=False,
                            autoplay=True,
                        )
                        self.fields.render = gradio.Button(
                            value="🔥 Render 🔥",
                            variant="primary",
                        )

                with gradio.Row(equal_height=True, variant="panel"):
                    with gradio.Accordion("Animation (WIP)", open=False):
                        def animation_type(type):
                            for preset in Actions.members():
                                if not issubclass(preset, type):
                                    continue
                                preset_name = preset.__name__
                                preset_dict = self.fields.animation[preset_name]

                                with gradio.Tab(preset_name):
                                    preset_dict.enable = gradio.Checkbox(
                                        value=False, label="Enable", info=preset.__doc__)

                                    for attr, field in preset.model_fields.items():
                                        if (attr.lower() == "enable"):
                                            continue
                                        if (field.annotation is bool):
                                            preset_dict.options[attr] = gradio.Checkbox(
                                                value=field.default,
                                                label=attr.capitalize(),
                                                info=field.description,
                                            )
                                        elif (field.annotation is float):
                                            preset_dict.options[attr] = gradio.Slider(
                                                minimum=field.metadata[0].min,
                                                maximum=field.metadata[0].max,
                                                step=0.01, label=attr.capitalize(),
                                                value=field.default,
                                                info=field.description,
                                            )
                                        elif (isinstance(field.annotation, Tuple)):
                                            print(attr, field, field.annotation)

                        with gradio.Tab("Presets"):
                            animation_type(PresetBase)
                        with gradio.Tab("Filters"):
                            animation_type(FilterBase)

                with gradio.Row(equal_height=True):
                    with gradio.Row(equal_height=True, variant="panel"):
                        self.fields.width = gradio.Number(label="Width",
                            minimum=1, precision=0, scale=10, value=1920)
                        self.fields.fit_height = gradio.Button(
                            value="➡️ Fit height", scale=1)

                    with gradio.Row(equal_height=True, variant="panel"):
                        self.fields.height = gradio.Number(label="Height",
                            minimum=1, precision=0, scale=10, value=1080)
                        self.fields.fit_width = gradio.Button(
                            value="⬅️ Fit width", scale=1)

                    with gradio.Row(equal_height=True, variant="panel"):
                        self.fields.ssaa = gradio.Slider(label="Super sampling anti-aliasing",
                            info="Renders at a higher resolution for smoother edges",
                            value=1.5, minimum=1, maximum=2, step=0.1)

                    with gradio.Row(equal_height=True, variant="panel"):
                        self.fields.quality = gradio.Slider(label="Shader quality",
                            info="Reduces internal step size for better quality",
                            value=50, minimum=0, maximum=100, step=10)

                    self.fields.fit_height.click(**self.simple(self.fit_width))
                    self.fields.fit_width.click(**self.simple(self.fit_height))

                with gradio.Row(equal_height=True, variant="panel"):
                    self.fields.time = gradio.Slider(label="Duration (seconds)",
                        info="How long the animation or its loop lasts",
                        minimum=0, maximum=30, step=0.5, value=5)
                    self.fields.fps = gradio.Slider(label="Framerate (fps)",
                        info="Defines the animation smoothness",
                        minimum=1, maximum=120, step=1, value=60)
                    self.fields.loop = gradio.Slider(label="Loop count",
                        info="Repeat the final video this many times",
                        minimum=1, maximum=10, step=1, value=1)

            with gradio.Tab("Advanced"):
                self.fields.turbopipe = gradio.Checkbox(label="Enable TurboPipe", value=True,
                    info="Improves rendering speeds, disable if you encounter issues or crashes")

            # Update depth map and resolution on image change
            outputs = {self.fields.image, self.fields.depth, self.fields.width, self.fields.height}
            self.fields.image    .change(**self.simple(self.estimate, outputs=outputs))
            self.fields.upscale  .click (**self.simple(self.upscale,  outputs=outputs))
            self.fields.estimator.change(**self.simple(self.estimate, outputs=outputs))
            self.fields.estimate .click (**self.simple(self.estimate, outputs=outputs))

            # Main render button
            self.fields.render.click(**self.simple(
                self.render, outputs={self.fields.video}
            ))

            gradio.Markdown(''.join((
                "Made with ❤️ by [**Tremeschin**](https://github.com/Tremeschin) | ",
                f"**Alpha** WebUI v{DEPTHFLOW.VERSION} | ",
                "[**Website**](https://brokensrc.dev/depthflow) | "
                "[**Discord**](https://discord.com/invite/KjqvcYwRHm/) | ",
                "[**Telegram**](https://t.me/brokensource/) | ",
                "[**GitHub**](https://github.com/BrokenSource/DepthFlow)"
            )))

        return self.interface.launch(
            allowed_paths=[DEPTHFLOW.DIRECTORIES.DATA],
            favicon_path=DEPTHFLOW.RESOURCES.ICON_PNG,
            inbrowser=browser, show_api=False,
            prevent_thread_lock=(not block),
            max_threads=threads,
            server_name=server,
            server_port=port,
            share=share,
        )

interface

1
interface: gradio.Blocks = None

fields

1
fields: DotMap = Factory(DotMap)

estimators

1
2
3
4
5
6
7
estimators = {
    "DepthAnything V2": DepthAnythingV2,
    "DepthAnything V1": DepthAnythingV1,
    "DepthPro": DepthPro,
    "ZoeDepth": ZoeDepth,
    "Marigold": Marigold,
}

upscalers

1
2
3
4
5
upscalers = {
    "Upscayl": Upscayl,
    "Real-ESRGAN": Realesr,
    "Waifu2x": Waifu2x,
}

simple

1
simple(method: Callable, **options: Dict) -> Dict

An ugly hack to avoid manually listing inputs and outputs

Source code in Projects/DepthFlow/DepthFlow/Webui.py
51
52
53
54
55
56
57
58
59
60
61
62
def simple(self, method: Callable, **options: Dict) -> Dict:
    """An ugly hack to avoid manually listing inputs and outputs"""
    show_progress = bool(options.get("outputs"))
    outputs = options.pop("outputs", set(DictUtils.rvalues(self.fields)))
    inputs = options.pop("inputs", set(DictUtils.rvalues(self.fields)))
    return dict(
        fn=method,
        inputs=inputs,
        outputs=outputs,
        show_progress=show_progress,
        **options,
    )

estimate

1
estimate(user: Dict)
Source code in Projects/DepthFlow/DepthFlow/Webui.py
70
71
72
73
74
75
76
77
def estimate(self, user: Dict):
    if ((image := user[self.fields.image]) is None):
        return None
    yield {
        self.fields.depth:  self._estimator(user).estimate(image),
        self.fields.width:  image.size[0],
        self.fields.height: image.size[1]
    }

upscale

1
upscale(user: Dict)
Source code in Projects/DepthFlow/DepthFlow/Webui.py
79
80
81
82
def upscale(self, user: Dict):
    if ((image := user[self.fields.image]) is None):
        return gradio.Warning("The input image is empty")
    yield {self.fields.image: self._upscaler(user).upscale(image)}

fit_width

1
fit_width(user: Dict)
Source code in Projects/DepthFlow/DepthFlow/Webui.py
93
94
def fit_width(self, user: Dict):
    yield {self.fields.height: self._fit_resolution(user, (user[self.fields.width], None))[1]}

fit_height

1
fit_height(user: Dict)
Source code in Projects/DepthFlow/DepthFlow/Webui.py
96
97
def fit_height(self, user: Dict):
    yield {self.fields.width: self._fit_resolution(user, (None, user[self.fields.height]))[0]}

render

1
render(user: Dict)
Source code in Projects/DepthFlow/DepthFlow/Webui.py
 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
def render(self, user: Dict):
    if (user[self.fields.image] is None):
        return gradio.Warning("The input image is empty")
    if (user[self.fields.depth] is None):
        return gradio.Warning("The input depthmap is empty")

    def worker():
        from DepthFlow.Scene import DepthScene
        scene = DepthScene(backend="headless")
        scene.set_estimator(self._estimator(user))
        scene.input(image=user[self.fields.image], depth=user[self.fields.depth])
        scene.aspect_ratio = None

        # Build and add any enabled preset class
        for preset in Actions.members():
            preset_name = preset.__name__
            preset_dict = self.fields.animation[preset_name]
            if (not preset_dict.enable):
                continue
            if (not user[preset_dict.enable]):
                continue
            scene.animation.add(preset(**{
                key: user[item] for (key, item) in preset_dict.options.items()
            }))

        return scene.main(
            width=user[self.fields.width],
            height=user[self.fields.height],
            ssaa=user[self.fields.ssaa],
            fps=user[self.fields.fps],
            time=user[self.fields.time],
            loop=user[self.fields.loop],
            output=(WEBUI_OUTPUT/f"{uuid.uuid4()}.mp4"),
            noturbo=(not user[self.fields.turbopipe]),
        )[0]

    with ThreadPool() as pool:
        task = pool.submit(worker)
        yield {self.fields.video: task.result()}
        os.remove(task.result())

launch

 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
launch(
    port: Annotated[
        int,
        Option(
            --port, -p, help="Port to run the WebUI on"
        ),
    ] = None,
    server: Annotated[
        str,
        Option(--server, help="Server to run the WebUI on"),
    ] = "0.0.0.0",
    share: Annotated[
        bool,
        Option(
            --share,
            -s,
            help="Share the WebUI on the network",
        ),
    ] = False,
    threads: Annotated[
        int,
        Option(
            --threads,
            -t,
            help="Number of maximum concurrent renders",
        ),
    ] = 4,
    browser: Annotated[
        bool,
        Option(
            --open,
            " /--no-open",
            help="Open the WebUI in the browser",
        ),
    ] = True,
    block: Annotated[
        bool,
        Option(
            --block,
            -b,
            " /--no-block",
            help="Holds the main thread until the WebUI is closed",
        ),
    ] = True,
) -> gradio.Blocks
Source code in Projects/DepthFlow/DepthFlow/Webui.py
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
def launch(self,
    port: Annotated[int, Option("--port", "-p",
        help="Port to run the WebUI on")]=None,
    server: Annotated[str, Option("--server",
        help="Server to run the WebUI on")]="0.0.0.0",
    share: Annotated[bool, Option("--share", "-s",
        help="Share the WebUI on the network")]=False,
    threads: Annotated[int,  Option("--threads", "-t",
        help="Number of maximum concurrent renders")]=4,
    browser: Annotated[bool, Option("--open", " /--no-open",
        help="Open the WebUI in the browser")]=True,
    block: Annotated[bool, Option("--block", "-b", " /--no-block",
        help="Holds the main thread until the WebUI is closed")]=True,
) -> gradio.Blocks:
    with gradio.Blocks(
        theme=gradio.themes.Ocean(
            font=(fonts.GoogleFont("Roboto Slab"),),
            font_mono=(fonts.GoogleFont("Fira Code"),),
            primary_hue=colors.emerald,
            spacing_size=sizes.spacing_sm,
            radius_size=sizes.radius_sm,
            text_size=sizes.text_sm,
        ),
        analytics_enabled=False,
        title="DepthFlow WebUI",
        fill_height=True,
        fill_width=True
    ) as self.interface:

        gradio.Markdown("# 🌊 DepthFlow")

        with gradio.Tab("Application"):
            with gradio.Row(equal_height=True):
                with gradio.Column(variant="panel"):
                    self.fields.image = gradio.Image(scale=1,
                        sources=["upload", "clipboard"],
                        type="pil", label="Input image",
                        interactive=True,
                    )
                    with gradio.Row(equal_height=True):
                        self.fields.upscaler = gradio.Dropdown(
                            choices=list(self.upscalers.keys()),
                            value=list(self.upscalers.keys())[0],
                            label="Upscaler", scale=10
                        )
                        self.fields.upscale = gradio.Button(value="🚀 Upscale", scale=1)

                with gradio.Column(variant="panel"):
                    self.fields.depth = gradio.Image(scale=1,
                        sources=["upload", "clipboard"],
                        type="pil", label="Depthmap"
                    )
                    with gradio.Row(equal_height=True):
                        self.fields.estimator = gradio.Dropdown(
                            choices=list(self.estimators.keys()),
                            value=list(self.estimators.keys())[0],
                            label="Depth Estimator", scale=10
                        )
                        self.fields.estimate = gradio.Button(value="🔎 Estimate", scale=1)

                with gradio.Column(variant="panel"):
                    self.fields.video = gradio.Video(scale=1,
                        label="Output video",
                        interactive=False,
                        autoplay=True,
                    )
                    self.fields.render = gradio.Button(
                        value="🔥 Render 🔥",
                        variant="primary",
                    )

            with gradio.Row(equal_height=True, variant="panel"):
                with gradio.Accordion("Animation (WIP)", open=False):
                    def animation_type(type):
                        for preset in Actions.members():
                            if not issubclass(preset, type):
                                continue
                            preset_name = preset.__name__
                            preset_dict = self.fields.animation[preset_name]

                            with gradio.Tab(preset_name):
                                preset_dict.enable = gradio.Checkbox(
                                    value=False, label="Enable", info=preset.__doc__)

                                for attr, field in preset.model_fields.items():
                                    if (attr.lower() == "enable"):
                                        continue
                                    if (field.annotation is bool):
                                        preset_dict.options[attr] = gradio.Checkbox(
                                            value=field.default,
                                            label=attr.capitalize(),
                                            info=field.description,
                                        )
                                    elif (field.annotation is float):
                                        preset_dict.options[attr] = gradio.Slider(
                                            minimum=field.metadata[0].min,
                                            maximum=field.metadata[0].max,
                                            step=0.01, label=attr.capitalize(),
                                            value=field.default,
                                            info=field.description,
                                        )
                                    elif (isinstance(field.annotation, Tuple)):
                                        print(attr, field, field.annotation)

                    with gradio.Tab("Presets"):
                        animation_type(PresetBase)
                    with gradio.Tab("Filters"):
                        animation_type(FilterBase)

            with gradio.Row(equal_height=True):
                with gradio.Row(equal_height=True, variant="panel"):
                    self.fields.width = gradio.Number(label="Width",
                        minimum=1, precision=0, scale=10, value=1920)
                    self.fields.fit_height = gradio.Button(
                        value="➡️ Fit height", scale=1)

                with gradio.Row(equal_height=True, variant="panel"):
                    self.fields.height = gradio.Number(label="Height",
                        minimum=1, precision=0, scale=10, value=1080)
                    self.fields.fit_width = gradio.Button(
                        value="⬅️ Fit width", scale=1)

                with gradio.Row(equal_height=True, variant="panel"):
                    self.fields.ssaa = gradio.Slider(label="Super sampling anti-aliasing",
                        info="Renders at a higher resolution for smoother edges",
                        value=1.5, minimum=1, maximum=2, step=0.1)

                with gradio.Row(equal_height=True, variant="panel"):
                    self.fields.quality = gradio.Slider(label="Shader quality",
                        info="Reduces internal step size for better quality",
                        value=50, minimum=0, maximum=100, step=10)

                self.fields.fit_height.click(**self.simple(self.fit_width))
                self.fields.fit_width.click(**self.simple(self.fit_height))

            with gradio.Row(equal_height=True, variant="panel"):
                self.fields.time = gradio.Slider(label="Duration (seconds)",
                    info="How long the animation or its loop lasts",
                    minimum=0, maximum=30, step=0.5, value=5)
                self.fields.fps = gradio.Slider(label="Framerate (fps)",
                    info="Defines the animation smoothness",
                    minimum=1, maximum=120, step=1, value=60)
                self.fields.loop = gradio.Slider(label="Loop count",
                    info="Repeat the final video this many times",
                    minimum=1, maximum=10, step=1, value=1)

        with gradio.Tab("Advanced"):
            self.fields.turbopipe = gradio.Checkbox(label="Enable TurboPipe", value=True,
                info="Improves rendering speeds, disable if you encounter issues or crashes")

        # Update depth map and resolution on image change
        outputs = {self.fields.image, self.fields.depth, self.fields.width, self.fields.height}
        self.fields.image    .change(**self.simple(self.estimate, outputs=outputs))
        self.fields.upscale  .click (**self.simple(self.upscale,  outputs=outputs))
        self.fields.estimator.change(**self.simple(self.estimate, outputs=outputs))
        self.fields.estimate .click (**self.simple(self.estimate, outputs=outputs))

        # Main render button
        self.fields.render.click(**self.simple(
            self.render, outputs={self.fields.video}
        ))

        gradio.Markdown(''.join((
            "Made with ❤️ by [**Tremeschin**](https://github.com/Tremeschin) | ",
            f"**Alpha** WebUI v{DEPTHFLOW.VERSION} | ",
            "[**Website**](https://brokensrc.dev/depthflow) | "
            "[**Discord**](https://discord.com/invite/KjqvcYwRHm/) | ",
            "[**Telegram**](https://t.me/brokensource/) | ",
            "[**GitHub**](https://github.com/BrokenSource/DepthFlow)"
        )))

    return self.interface.launch(
        allowed_paths=[DEPTHFLOW.DIRECTORIES.DATA],
        favicon_path=DEPTHFLOW.RESOURCES.ICON_PNG,
        inbrowser=browser, show_api=False,
        prevent_thread_lock=(not block),
        max_threads=threads,
        server_name=server,
        server_port=port,
        share=share,
    )

demo

1
demo = DepthGradio()