RaynWu2002 commited on
Commit
bd4de0f
·
verified ·
1 Parent(s): 67fd942

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -13
app.py CHANGED
@@ -11,16 +11,16 @@ from net.dornet import Net
11
  from net.dornet_ddp import Net_ddp
12
  import subprocess
13
 
14
- def install_mmcv():
15
- try:
16
- subprocess.run([
17
- "pip", "install", "mmcv-full==1.7.2",
18
- "-f", "https://download.openmmlab.com/mmcv/dist/cu121/torch2.1.0/"
19
- ], check=True)
20
- except subprocess.CalledProcessError as e:
21
- print("Failed to install mmcv-full:", e)
22
-
23
- install_mmcv()
24
  print("=" * 50)
25
  print(f"CUDA available: {torch.cuda.is_available()}")
26
  print(f"torch version: {torch.__version__}")
@@ -30,6 +30,7 @@ print("=" * 50)
30
 
31
  # init
32
  device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
 
33
  net = Net(tiny_model=False).to(device)
34
  model_ckpt_map = {
35
  "RGB-D-D": "./checkpoints/RGBDD.pth",
@@ -37,7 +38,7 @@ model_ckpt_map = {
37
  }
38
 
39
  # load model
40
- @spaces.GPU
41
  def load_model(model_type: str):
42
  global net
43
  ckpt_path = model_ckpt_map[model_type]
@@ -56,7 +57,7 @@ load_model("RGB-D-D")
56
 
57
 
58
  # data process
59
- @spaces.GPU
60
  def preprocess_inputs(rgb_image: Image.Image, lr_depth: Image.Image):
61
  image = np.array(rgb_image.convert("RGB")).astype(np.float32)
62
  h, w, _ = image.shape
@@ -78,7 +79,7 @@ def preprocess_inputs(rgb_image: Image.Image, lr_depth: Image.Image):
78
 
79
 
80
  # model inference
81
- @spaces.GPU
82
  @torch.no_grad()
83
  def infer(rgb_image: Image.Image, lr_depth: Image.Image, model_type: str):
84
  load_model(model_type) # reset weight
 
11
  from net.dornet_ddp import Net_ddp
12
  import subprocess
13
 
14
+ # def install_mmcv():
15
+ # try:
16
+ # subprocess.run([
17
+ # "pip", "install", "mmcv-full==1.7.2",
18
+ # "-f", "https://download.openmmlab.com/mmcv/dist/cu121/torch2.1.0/"
19
+ # ], check=True)
20
+ # except subprocess.CalledProcessError as e:
21
+ # print("Failed to install mmcv-full:", e)
22
+
23
+ # install_mmcv()
24
  print("=" * 50)
25
  print(f"CUDA available: {torch.cuda.is_available()}")
26
  print(f"torch version: {torch.__version__}")
 
30
 
31
  # init
32
  device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
33
+ device = "cpu"
34
  net = Net(tiny_model=False).to(device)
35
  model_ckpt_map = {
36
  "RGB-D-D": "./checkpoints/RGBDD.pth",
 
38
  }
39
 
40
  # load model
41
+ # @spaces.GPU
42
  def load_model(model_type: str):
43
  global net
44
  ckpt_path = model_ckpt_map[model_type]
 
57
 
58
 
59
  # data process
60
+ # @spaces.GPU
61
  def preprocess_inputs(rgb_image: Image.Image, lr_depth: Image.Image):
62
  image = np.array(rgb_image.convert("RGB")).astype(np.float32)
63
  h, w, _ = image.shape
 
79
 
80
 
81
  # model inference
82
+ # @spaces.GPU
83
  @torch.no_grad()
84
  def infer(rgb_image: Image.Image, lr_depth: Image.Image, model_type: str):
85
  load_model(model_type) # reset weight