hzxie commited on
Commit
1b18401
·
verified ·
1 Parent(s): b0dcc9c

perf: faster initialize env.

Browse files
Files changed (2) hide show
  1. app.py +17 -18
  2. gaussiancity/inference.py +0 -1
app.py CHANGED
@@ -87,20 +87,19 @@ def setup_runtime_env():
87
  logging.info("CUDA is available: %s" % torch.cuda.is_available())
88
  logging.info("CUDA Device Capability: %s" % (torch.cuda.get_device_capability(),))
89
 
90
- # Install Pre-compiled CUDA extensions (Not working)
91
  # Ref: https://huggingface.co/spaces/zero-gpu-explorers/README/discussions/110
92
- #
93
- # ext_dir = os.path.join(os.path.dirname(__file__), "wheels")
94
- # for e in os.listdir(ext_dir):
95
- # logging.info("Installing Extensions from %s" % e)
96
- # subprocess.call(
97
- # ["pip", "install", os.path.join(ext_dir, e)], stderr=subprocess.STDOUT
98
- # )
99
- # Compile CUDA extensions
100
- ext_dir = os.path.join(os.path.dirname(__file__), "gaussiancity", "extensions")
101
  for e in os.listdir(ext_dir):
102
- if os.path.isdir(os.path.join(ext_dir, e)):
103
- subprocess.call(["pip", "install", "."], cwd=os.path.join(ext_dir, e))
 
 
 
 
 
 
 
104
 
105
  logging.info("Installed Python Packages: %s" % _get_output(["pip", "list"]))
106
 
@@ -218,14 +217,14 @@ if __name__ == "__main__":
218
  format="[%(levelname)s] %(asctime)s %(message)s", level=logging.INFO
219
  )
220
  logging.info("Environment Variables: %s" % os.environ)
221
- if _get_output(["nvcc", "--version"]) is None:
222
- logging.info("Installing CUDA toolkit...")
223
- install_cuda_toolkit()
224
- else:
225
- logging.info("Detected CUDA: %s" % _get_output(["nvcc", "--version"]))
226
 
227
  logging.info("Compiling CUDA extensions...")
228
- # setup_runtime_env()
229
 
230
  logging.info("Downloading pretrained models...")
231
  fgm = get_models("GaussianCity-Fgnd.pth")
 
87
  logging.info("CUDA is available: %s" % torch.cuda.is_available())
88
  logging.info("CUDA Device Capability: %s" % (torch.cuda.get_device_capability(),))
89
 
90
+ # Install Pre-compiled CUDA extensions
91
  # Ref: https://huggingface.co/spaces/zero-gpu-explorers/README/discussions/110
92
+ ext_dir = os.path.join(os.path.dirname(__file__), "wheels")
 
 
 
 
 
 
 
 
93
  for e in os.listdir(ext_dir):
94
+ logging.info("Installing Extensions from %s" % e)
95
+ subprocess.call(
96
+ ["pip", "install", os.path.join(ext_dir, e)], stderr=subprocess.STDOUT
97
+ )
98
+ # Compile CUDA extensions
99
+ # ext_dir = os.path.join(os.path.dirname(__file__), "gaussiancity", "extensions")
100
+ # for e in os.listdir(ext_dir):
101
+ # if os.path.isdir(os.path.join(ext_dir, e)):
102
+ # subprocess.call(["pip", "install", "."], cwd=os.path.join(ext_dir, e))
103
 
104
  logging.info("Installed Python Packages: %s" % _get_output(["pip", "list"]))
105
 
 
217
  format="[%(levelname)s] %(asctime)s %(message)s", level=logging.INFO
218
  )
219
  logging.info("Environment Variables: %s" % os.environ)
220
+ # if _get_output(["nvcc", "--version"]) is None:
221
+ # logging.info("Installing CUDA toolkit...")
222
+ # install_cuda_toolkit()
223
+ # else:
224
+ # logging.info("Detected CUDA: %s" % _get_output(["nvcc", "--version"]))
225
 
226
  logging.info("Compiling CUDA extensions...")
227
+ setup_runtime_env()
228
 
229
  logging.info("Downloading pretrained models...")
230
  fgm = get_models("GaussianCity-Fgnd.pth")
gaussiancity/inference.py CHANGED
@@ -52,7 +52,6 @@ def get_instance_seg_map(seg_map):
52
  # Mapping constructions to buildings
53
  seg_map[seg_map == CLASSES["CONSTRUCTION"]] = CLASSES["BLDG_FACADE"]
54
  # Use connected components to get building instances
55
- import pdb; pdb.set_trace()
56
  _, labels, _, _ = cv2.connectedComponentsWithStats(
57
  (seg_map == CLASSES["BLDG_FACADE"]).astype(np.uint8), connectivity=4
58
  )
 
52
  # Mapping constructions to buildings
53
  seg_map[seg_map == CLASSES["CONSTRUCTION"]] = CLASSES["BLDG_FACADE"]
54
  # Use connected components to get building instances
 
55
  _, labels, _, _ = cv2.connectedComponentsWithStats(
56
  (seg_map == CLASSES["BLDG_FACADE"]).astype(np.uint8), connectivity=4
57
  )