Skip to content

Commit 6d83839

Browse files
authored
Merge pull request #216 from monoDriveIO/master
Refactor for pip installation
2 parents 69243f0 + 10f9af6 commit 6d83839

38 files changed

+77
-29
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ ckpt/
44
vis/
55
log/
66
pretrained/
7+
8+
.idea/

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,19 @@ python3 eval_multipro.py --gpus GPUS --cfg config/ade20k-resnet50dilated-ppm_dee
228228
python3 eval_multipro.py --gpus GPUS --cfg config/ade20k-resnet101-upernet.yaml
229229
```
230230

231+
## Integration with other projects
232+
This library can be installed via `pip` to easily integrate with another codebase
233+
```bash
234+
pip install git+https://github.com/CSAILVision/semantic-segmentation-pytorch.git@master
235+
```
236+
237+
Now this library can easily be consumed programmatically. For example
238+
```python
239+
from mit_semseg.config import cfg
240+
from mit_semseg.dataset import TestDataset
241+
from mit_semseg.models import ModelBuilder, SegmentationModule
242+
```
243+
231244
## Reference
232245

233246
If you find the code or pre-trained models useful, please cite the following papers:

eval.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
import torch.nn as nn
1010
from scipy.io import loadmat
1111
# Our libs
12-
from config import cfg
13-
from dataset import ValDataset
14-
from models import ModelBuilder, SegmentationModule
15-
from utils import AverageMeter, colorEncode, accuracy, intersectionAndUnion, setup_logger
16-
from lib.nn import user_scattered_collate, async_copy_to
17-
from lib.utils import as_numpy
12+
from mit_semseg.config import cfg
13+
from mit_semseg.dataset import ValDataset
14+
from mit_semseg.models import ModelBuilder, SegmentationModule
15+
from mit_semseg.utils import AverageMeter, colorEncode, accuracy, intersectionAndUnion, setup_logger
16+
from mit_semseg.lib.nn import user_scattered_collate, async_copy_to
17+
from mit_semseg.lib.utils import as_numpy
1818
from PIL import Image
1919
from tqdm import tqdm
2020

eval_multipro.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
import torch.nn as nn
1111
from scipy.io import loadmat
1212
# Our libs
13-
from config import cfg
14-
from dataset import ValDataset
15-
from models import ModelBuilder, SegmentationModule
16-
from utils import AverageMeter, colorEncode, accuracy, intersectionAndUnion, parse_devices, setup_logger
17-
from lib.nn import user_scattered_collate, async_copy_to
18-
from lib.utils import as_numpy
13+
from mit_semseg.config import cfg
14+
from mit_semseg.dataset import ValDataset
15+
from mit_semseg.models import ModelBuilder, SegmentationModule
16+
from mit_semseg.utils import AverageMeter, colorEncode, accuracy, intersectionAndUnion, parse_devices, setup_logger
17+
from mit_semseg.lib.nn import user_scattered_collate, async_copy_to
18+
from mit_semseg.lib.utils import as_numpy
1919
from PIL import Image
2020
from tqdm import tqdm
2121

mit_semseg/__init__.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""
2+
MIT CSAIL Semantic Segmentation
3+
"""
4+
5+
__version__ = '1.0.0'
File renamed without changes.
File renamed without changes.
File renamed without changes.

mit_semseg/lib/__init__.py

Whitespace-only changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

mit_semseg/lib/nn/modules/tests/__init__.py

Whitespace-only changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

models/hrnet.py renamed to mit_semseg/models/hrnet.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import torch.nn as nn
99
import torch.nn.functional as F
1010
from .utils import load_url
11-
from lib.nn import SynchronizedBatchNorm2d
11+
from mit_semseg.lib.nn import SynchronizedBatchNorm2d
1212

1313
BatchNorm2d = SynchronizedBatchNorm2d
1414
BN_MOMENTUM = 0.1

models/mobilenet.py renamed to mit_semseg/models/mobilenet.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import torch.nn as nn
77
import math
88
from .utils import load_url
9-
from lib.nn import SynchronizedBatchNorm2d
9+
from mit_semseg.lib.nn import SynchronizedBatchNorm2d
1010

1111
BatchNorm2d = SynchronizedBatchNorm2d
1212

models/models.py renamed to mit_semseg/models/models.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import torch
22
import torch.nn as nn
3-
import torchvision
43
from . import resnet, resnext, mobilenet, hrnet
5-
from lib.nn import SynchronizedBatchNorm2d
4+
from mit_semseg.lib.nn import SynchronizedBatchNorm2d
65
BatchNorm2d = SynchronizedBatchNorm2d
76

87

models/resnet.py renamed to mit_semseg/models/resnet.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import torch.nn as nn
22
import math
33
from .utils import load_url
4-
from lib.nn import SynchronizedBatchNorm2d
4+
from mit_semseg.lib.nn import SynchronizedBatchNorm2d
55
BatchNorm2d = SynchronizedBatchNorm2d
66

77

models/resnext.py renamed to mit_semseg/models/resnext.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import torch.nn as nn
22
import math
33
from .utils import load_url
4-
from lib.nn import SynchronizedBatchNorm2d
4+
from mit_semseg.lib.nn import SynchronizedBatchNorm2d
55
BatchNorm2d = SynchronizedBatchNorm2d
66

77

File renamed without changes.
File renamed without changes.

setup.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import setuptools
2+
3+
with open('README.md', 'r') as fh:
4+
long_description = fh.read()
5+
6+
setuptools.setup(
7+
name='mit_semseg',
8+
version='1.0.0',
9+
author='MIT CSAIL',
10+
description='Pytorch implementation for Semantic Segmentation/Scene Parsing on MIT ADE20K dataset',
11+
long_description=long_description,
12+
long_description_content_type='text/markdown',
13+
url='https://github.com/CSAILVision/semantic-segmentation-pytorch',
14+
packages=setuptools.find_packages(),
15+
classifiers=(
16+
'Programming Language :: Python :: 3',
17+
'License :: OSI Approved :: BSD License',
18+
'Operating System :: OS Independent',
19+
),
20+
install_requires=[
21+
'numpy',
22+
'torch>=0.4.1',
23+
'torchvision',
24+
'opencv-python',
25+
'yacs',
26+
'scipy',
27+
'tqdm'
28+
]
29+
)

test.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
from scipy.io import loadmat
1010
import csv
1111
# Our libs
12-
from dataset import TestDataset
13-
from models import ModelBuilder, SegmentationModule
14-
from utils import colorEncode, find_recursive, setup_logger
15-
from lib.nn import user_scattered_collate, async_copy_to
16-
from lib.utils import as_numpy
12+
from mit_semseg.dataset import TestDataset
13+
from mit_semseg.models import ModelBuilder, SegmentationModule
14+
from mit_semseg.utils import colorEncode, find_recursive, setup_logger
15+
from mit_semseg.lib.nn import user_scattered_collate, async_copy_to
16+
from mit_semseg.lib.utils import as_numpy
1717
from PIL import Image
1818
from tqdm import tqdm
19-
from config import cfg
19+
from mit_semseg.config import cfg
2020

2121
colors = loadmat('data/color150.mat')['colors']
2222
names = {}

train.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
import torch
1010
import torch.nn as nn
1111
# Our libs
12-
from config import cfg
13-
from dataset import TrainDataset
14-
from models import ModelBuilder, SegmentationModule
15-
from utils import AverageMeter, parse_devices, setup_logger
16-
from lib.nn import UserScatteredDataParallel, user_scattered_collate, patch_replication_callback
12+
from mit_semseg.config import cfg
13+
from mit_semseg.dataset import TrainDataset
14+
from mit_semseg.models import ModelBuilder, SegmentationModule
15+
from mit_semseg.utils import AverageMeter, parse_devices, setup_logger
16+
from mit_semseg.lib.nn import UserScatteredDataParallel, user_scattered_collate, patch_replication_callback
1717

1818

1919
# train one epoch

0 commit comments

Comments
 (0)