kylinfires commited on
Commit
6a06db2
·
verified ·
1 Parent(s): 381a806

WorldGen: native 1600x800 DA-2 trace

Browse files
Files changed (1) hide show
  1. worldgen/worldgen_da2.py +8 -3
worldgen/worldgen_da2.py CHANGED
@@ -12,12 +12,17 @@ MODELS = Path(os.environ.get("WORLDGEN_MODELS", ROOT / "models"))
12
  EXE = Path(os.environ.get("DA2_NCNN_EXE", ROOT / "tools/da2-ncnn/da2ncnn.exe"))
13
  PARAM = MODELS / "da2/da2_trace_1024.ncnn.param"
14
  BIN = MODELS / "da2/da2_trace_1024.ncnn.bin"
 
 
15
  NCNN_DLL = Path(os.environ.get("NCNN_DLL_DIR", ROOT / "tools/ncnn/src"))
16
 
17
 
18
  def depth(pano: Image.Image, width: int = 1024, height: int = 512) -> np.ndarray:
19
- """Run DA-2 at its fixed 1024x512 trace size; resample other sizes."""
20
- rw, rh = 1024, 512
 
 
 
21
  arr = np.asarray(pano.convert("RGB").resize((rw, rh))).astype("<f4") / 255.0
22
  nchw = np.ascontiguousarray(arr.transpose(2, 0, 1))
23
  tmp_in = ROOT / "output" / "_da2_in.f32"
@@ -27,7 +32,7 @@ def depth(pano: Image.Image, width: int = 1024, height: int = 512) -> np.ndarray
27
  env = dict(os.environ)
28
  env["PATH"] = str(NCNN_DLL) + os.pathsep + env.get("PATH", "")
29
  subprocess.run(
30
- [str(EXE), str(PARAM), str(BIN), str(tmp_in), str(tmp_out),
31
  str(rw), str(rh), "vulkan"],
32
  check=True,
33
  env=env,
 
12
  EXE = Path(os.environ.get("DA2_NCNN_EXE", ROOT / "tools/da2-ncnn/da2ncnn.exe"))
13
  PARAM = MODELS / "da2/da2_trace_1024.ncnn.param"
14
  BIN = MODELS / "da2/da2_trace_1024.ncnn.bin"
15
+ PARAM_1600 = MODELS / "da2/da2_trace_1600.ncnn.param"
16
+ BIN_1600 = MODELS / "da2/da2_trace_1600.ncnn.bin"
17
  NCNN_DLL = Path(os.environ.get("NCNN_DLL_DIR", ROOT / "tools/ncnn/src"))
18
 
19
 
20
  def depth(pano: Image.Image, width: int = 1024, height: int = 512) -> np.ndarray:
21
+ """Run DA-2 through ncnn Vulkan; 1600x800 uses its own trace."""
22
+ if width == 1600 and height == 800:
23
+ param, binp, rw, rh = PARAM_1600, BIN_1600, 1600, 800
24
+ else:
25
+ param, binp, rw, rh = PARAM, BIN, 1024, 512
26
  arr = np.asarray(pano.convert("RGB").resize((rw, rh))).astype("<f4") / 255.0
27
  nchw = np.ascontiguousarray(arr.transpose(2, 0, 1))
28
  tmp_in = ROOT / "output" / "_da2_in.f32"
 
32
  env = dict(os.environ)
33
  env["PATH"] = str(NCNN_DLL) + os.pathsep + env.get("PATH", "")
34
  subprocess.run(
35
+ [str(EXE), str(param), str(binp), str(tmp_in), str(tmp_out),
36
  str(rw), str(rh), "vulkan"],
37
  check=True,
38
  env=env,