File size: 1,642 Bytes
cccc7e4
f559c43
 
 
3a8aaca
 
882f153
 
cccc7e4
882f153
567acaa
cccc7e4
 
 
 
f559c43
fd6ec67
f559c43
cccc7e4
f559c43
cccc7e4
fd6ec67
cccc7e4
 
 
fd6ec67
cccc7e4
 
 
 
 
 
fd6ec67
 
882f153
 
 
 
 
 
 
 
5faf826
882f153
 
 
 
 
cccc7e4
 
f559c43
cb59257
866bc8b
fd6ec67
cb59257
 
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
import os
import subprocess
import sys

import spaces

ZeroGPU = bool(os.getenv("SPACES_ZERO_GPU"))

# Install latest git main code
ZeroGPU and subprocess.run((
    sys.executable, "-m", "pip", "install", "--upgrade",
    "git+https://github.com/BrokenSource/BrokenSource@main",
    "git+https://github.com/BrokenSource/ShaderFlow@main",
    "git+https://github.com/BrokenSource/DepthFlow@main",
))

# -----------------------------------------------|

from DepthFlow.Webui import ESTIMATORS, UPSCALERS

from Broken.Externals.Depthmap import DepthAnythingV2

# Remove legacy upscalers
UPSCALERS.pop("Real-ESRGAN")
UPSCALERS.pop("Waifu2x")

# Remove unsuitable models
ESTIMATORS.clear()
ESTIMATORS.update({
    # Base and Large models are CC BY-NC 4.0, better safe than sorry
    "DepthAnything2": DepthAnythingV2(model=DepthAnythingV2.Model.Small),
})

# -----------------------------------------------|
# Create Vulkan and EGL ICD loaders files

from pathlib import Path

if ZeroGPU:
    egl_vendor = Path("/usr/share/glvnd/egl_vendor.d/10_nvidia.json")
    egl_vendor.parent.mkdir(parents=True, exist_ok=True)
    egl_vendor.write_text('{"file_format_version":"1.0.0","ICD":{"library_path":"libEGL_nvidia.so.0"}}')

    vulkan_icd = Path("/usr/share/vulkan/icd.d/nvidia_icd.json")
    vulkan_icd.parent.mkdir(parents=True, exist_ok=True)
    vulkan_icd.write_text('{"file_format_version":"1.0.0","ICD":{"library_path":"libGLX_nvidia.so.0","api_version":"1.3"}}')

# -----------------------------------------------|
from DepthFlow.Webui import DepthGradio

DepthGradio().launch(
    workers=4,
    nvenc=True,
    turbo=True,
    pwa=True,
)