JasonYinnnn commited on
Commit
0963bfd
·
1 Parent(s): b349190

clear cache

Browse files
Files changed (1) hide show
  1. app.py +3 -46
app.py CHANGED
@@ -7,48 +7,6 @@ import gradio as gr
7
  import spaces
8
 
9
  import os
10
- # Hugging Face 相关缓存
11
- os.environ["HF_HOME"] = "/cache_data/.huggingface"
12
- os.environ["HF_HUB_CACHE"] = "/cache_data/.cache/huggingface/hub"
13
- os.environ["HF_DATASETS_CACHE"] = "/cache_data/.cache/huggingface/datasets"
14
- os.environ["TRANSFORMERS_CACHE"] = "/cache_data/.cache/huggingface/hub"
15
-
16
- # PyTorch / Torch Hub / TorchVision / 部分 timm 权重
17
- os.environ["TORCH_HOME"] = "/cache_data/.cache/torch"
18
- os.environ["XDG_CACHE_HOME"] = "/cache_data/.cache"
19
-
20
- # 关键:PyTorch JIT CUDA/C++ 扩展编译缓存目录
21
- os.environ["TORCH_EXTENSIONS_DIR"] = "/cache_data/.cache/torch_extensions"
22
-
23
- os.environ["TMPDIR"] = "/cache_data/bucket/tmp"
24
-
25
-
26
- path = "/cache_data"
27
- print("exists:", os.path.exists(path), flush=True)
28
- print("isdir:", os.path.isdir(path), flush=True)
29
-
30
- try:
31
- print("listdir:", os.listdir(path)[:10], flush=True)
32
- except Exception as e:
33
- print("listdir failed:", repr(e), flush=True)
34
-
35
- try:
36
- test_file = os.path.join(path, "_write_test.txt")
37
- with open(test_file, "w") as f:
38
- f.write("ok")
39
- print("write test ok:", test_file, flush=True)
40
- except Exception as e:
41
- print("write test failed:", repr(e), flush=True)
42
-
43
- os.makedirs(os.environ["HF_HOME"], exist_ok=True)
44
- os.makedirs(os.environ["HF_HUB_CACHE"], exist_ok=True)
45
- os.makedirs(os.environ["HF_DATASETS_CACHE"], exist_ok=True)
46
- os.makedirs(os.environ["TRANSFORMERS_CACHE"], exist_ok=True)
47
- os.makedirs(os.environ["TORCH_HOME"], exist_ok=True)
48
- os.makedirs(os.environ["XDG_CACHE_HOME"], exist_ok=True)
49
- os.makedirs(os.environ["TORCH_EXTENSIONS_DIR"], exist_ok=True)
50
- os.makedirs(os.environ["TMPDIR"], exist_ok=True)
51
-
52
  import uuid
53
  from typing import Any, List, Optional, Union
54
  import cv2
@@ -63,7 +21,6 @@ from huggingface_hub import snapshot_download
63
  from moge.model.v2 import MoGeModel
64
  from transformers import AutoModelForMaskGeneration, AutoProcessor
65
  from scripts.grounding_sam import plot_segmentation, segment
66
- from scripts.check_packages import install_mipsplatting
67
  import copy
68
  import shutil
69
  import time
@@ -74,7 +31,7 @@ MARKDOWN = """
74
  1. Upload an image, and draw bounding boxes for each instance by holding and dragging the mouse. Then click "Run Segmentation" to generate the segmentation result.
75
  2. If you find the generated 3D scene satisfactory, download it by clicking the "Download scene GLB" button, and you can also download each islolated 3D instance.
76
  3. In this implementation, we generate each instances one by one, and update the scene results at the "Generated GLB" area, besides, we display isolated instances below.
77
- 4. It may take some time to download the ckpts, thank you for your patience to wait. We recommend to deploy the demo locally.
78
  """
79
  MAX_SEED = np.iinfo(np.int32).max
80
  TMP_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "tmp")
@@ -88,7 +45,7 @@ generated_object_map = {}
88
 
89
  ############## 3D-Fixer model
90
  model_dir = 'HorizonRobotics/3D-Fixer'
91
- local_dir = "/cache_data/checkpoints/3D-Fixer"
92
  os.makedirs(local_dir, exist_ok=True)
93
  snapshot_download(repo_id=model_dir, local_dir=local_dir)
94
  ############## 3D-Fixer model
@@ -353,7 +310,7 @@ def get_duration(rgb_image, seg_image, seed, randomize_seed,
353
  cfg_interval_end, t_rescale, work_space):
354
  instance_labels = np.unique(np.array(seg_image).reshape(-1, 3), axis=0)
355
  step_duration = 15.0
356
- return instance_labels.shape[0] * step_duration + 75
357
 
358
  @spaces.GPU(duration=get_duration)
359
  def run_generation(
 
7
  import spaces
8
 
9
  import os
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  import uuid
11
  from typing import Any, List, Optional, Union
12
  import cv2
 
21
  from moge.model.v2 import MoGeModel
22
  from transformers import AutoModelForMaskGeneration, AutoProcessor
23
  from scripts.grounding_sam import plot_segmentation, segment
 
24
  import copy
25
  import shutil
26
  import time
 
31
  1. Upload an image, and draw bounding boxes for each instance by holding and dragging the mouse. Then click "Run Segmentation" to generate the segmentation result.
32
  2. If you find the generated 3D scene satisfactory, download it by clicking the "Download scene GLB" button, and you can also download each islolated 3D instance.
33
  3. In this implementation, we generate each instances one by one, and update the scene results at the "Generated GLB" area, besides, we display isolated instances below.
34
+ 4. It may take some time to download the ckpts, and compile the gsplat. Thank you for your patience to wait. We recommend to deploy the demo locally.
35
  """
36
  MAX_SEED = np.iinfo(np.int32).max
37
  TMP_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "tmp")
 
45
 
46
  ############## 3D-Fixer model
47
  model_dir = 'HorizonRobotics/3D-Fixer'
48
+ local_dir = "./checkpoints/3D-Fixer"
49
  os.makedirs(local_dir, exist_ok=True)
50
  snapshot_download(repo_id=model_dir, local_dir=local_dir)
51
  ############## 3D-Fixer model
 
310
  cfg_interval_end, t_rescale, work_space):
311
  instance_labels = np.unique(np.array(seg_image).reshape(-1, 3), axis=0)
312
  step_duration = 15.0
313
+ return instance_labels.shape[0] * step_duration + 120
314
 
315
  @spaces.GPU(duration=get_duration)
316
  def run_generation(