Skip to content

Commit f3dc79f

Browse files
committed
Change the dependencies
1 parent e792578 commit f3dc79f

File tree

4 files changed

+19
-32
lines changed

4 files changed

+19
-32
lines changed

configs/conda_env.yaml

+6-12
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,20 @@
11
name: deeplab-pytorch
2-
channels:
3-
- pytorch
4-
- conda-forge
5-
- defaults
62
dependencies:
7-
# - clang # For MacOS
8-
# - clangxx # For MacOS
93
- click
10-
- cudatoolkit=10.0
11-
- cython
4+
- conda-forge::pydensecrf
5+
- cudatoolkit=10.2
126
- matplotlib
13-
- pydensecrf
14-
- pytorch
7+
- python=3.6
8+
- pytorch::pytorch>1.2.0
9+
- pytorch::torchvision
1510
- pyyaml
1611
- scipy
17-
- torchvision
1812
- tqdm
1913
- pip:
2014
- addict
2115
- black
2216
- joblib
17+
- omegaconf
2318
- opencv-python
24-
- tensorboardX
2519
- tensorflow
2620
- torchnet

demo.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
import torch
1717
import torch.nn as nn
1818
import torch.nn.functional as F
19-
import yaml
20-
from addict import Dict
19+
from omegaconf import OmegaConf
2120

2221
from libs.models import *
2322
from libs.utils import DenseCRF
@@ -139,7 +138,7 @@ def single(config_path, model_path, image_path, cuda, crf):
139138
"""
140139

141140
# Setup
142-
CONFIG = Dict(yaml.load(config_path))
141+
CONFIG = OmegaConf.load(config_path)
143142
device = get_device(cuda)
144143
torch.set_grad_enabled(False)
145144

@@ -207,7 +206,7 @@ def live(config_path, model_path, cuda, crf, camera_id):
207206
"""
208207

209208
# Setup
210-
CONFIG = Dict(yaml.load(config_path))
209+
CONFIG = OmegaConf.load(config_path)
211210
device = get_device(cuda)
212211
torch.set_grad_enabled(False)
213212
torch.backends.cudnn.benchmark = True

libs/models/resnet.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def __init__(self, in_ch, out_ch, stride, dilation, downsample):
6060
self.shortcut = (
6161
_ConvBnReLU(in_ch, out_ch, 1, stride, 0, 1, False)
6262
if downsample
63-
else lambda x: x # identity
63+
else nn.Identity()
6464
)
6565

6666
def forward(self, x):
@@ -110,11 +110,6 @@ def __init__(self, out_ch):
110110
self.add_module("pool", nn.MaxPool2d(3, 2, 1, ceil_mode=True))
111111

112112

113-
class _Flatten(nn.Module):
114-
def forward(self, x):
115-
return x.view(x.size(0), -1)
116-
117-
118113
class ResNet(nn.Sequential):
119114
def __init__(self, n_classes, n_blocks):
120115
super(ResNet, self).__init__()
@@ -125,7 +120,7 @@ def __init__(self, n_classes, n_blocks):
125120
self.add_module("layer4", _ResLayer(n_blocks[2], ch[3], ch[4], 2, 1))
126121
self.add_module("layer5", _ResLayer(n_blocks[3], ch[4], ch[5], 2, 1))
127122
self.add_module("pool5", nn.AdaptiveAvgPool2d(1))
128-
self.add_module("flatten", _Flatten())
123+
self.add_module("flatten", nn.Flatten())
129124
self.add_module("fc", nn.Linear(ch[5], n_classes))
130125

131126

main.py

+8-9
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,14 @@
1717
import torch
1818
import torch.nn as nn
1919
import torch.nn.functional as F
20-
import yaml
21-
from addict import Dict
20+
from omegaconf import OmegaConf
2221
from PIL import Image
23-
from tensorboardX import SummaryWriter
22+
from torch.utils.tensorboard import SummaryWriter
2423
from torchnet.meter import MovingAverageValueMeter
2524
from tqdm import tqdm
2625

2726
from libs.datasets import get_dataset
28-
from libs.models import *
27+
from libs.models import DeepLabV2_ResNet101_MSC
2928
from libs.utils import DenseCRF, PolynomialLR, scores
3029

3130

@@ -110,7 +109,7 @@ def train(config_path, cuda):
110109
"""
111110

112111
# Configuration
113-
CONFIG = Dict(yaml.load(config_path))
112+
CONFIG = OmegaConf.load(config_path)
114113
device = get_device(cuda)
115114
torch.backends.cudnn.benchmark = True
116115

@@ -144,7 +143,7 @@ def train(config_path, cuda):
144143
), 'Currently support only "DeepLabV2_ResNet101_MSC"'
145144

146145
# Model setup
147-
model = eval(CONFIG.MODEL.NAME)(n_classes=CONFIG.DATASET.N_CLASSES)
146+
model = DeepLabV2_ResNet101_MSC(n_classes=CONFIG.DATASET.N_CLASSES)
148147
state_dict = torch.load(CONFIG.MODEL.INIT_MODEL)
149148
print(" Init:", CONFIG.MODEL.INIT_MODEL)
150149
for m in model.base.state_dict().keys():
@@ -236,7 +235,7 @@ def train(config_path, cuda):
236235
labels_ = resize_labels(labels, size=(H, W))
237236
iter_loss += criterion(logit, labels_.to(device))
238237

239-
# Propagate backward (just compute gradients wrt the loss)
238+
# Propagate backward (just compute gradients)
240239
iter_loss /= CONFIG.SOLVER.ITER_SIZE
241240
iter_loss.backward()
242241

@@ -308,7 +307,7 @@ def test(config_path, model_path, cuda):
308307
"""
309308

310309
# Configuration
311-
CONFIG = Dict(yaml.load(config_path))
310+
CONFIG = OmegaConf.load(config_path)
312311
device = get_device(cuda)
313312
torch.set_grad_enabled(False)
314313

@@ -417,7 +416,7 @@ def crf(config_path, n_jobs):
417416
"""
418417

419418
# Configuration
420-
CONFIG = Dict(yaml.load(config_path))
419+
CONFIG = OmegaConf.load(config_path)
421420
torch.set_grad_enabled(False)
422421
print("# jobs:", n_jobs)
423422

0 commit comments

Comments
 (0)