Skip to content

Commit 41d2a10

Browse files
author
kmaninis
committed
clean repo for public release
1 parent 75cb754 commit 41d2a10

25 files changed

+156
-1852
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
mypath.py
21
.idea/
32
*.gv
43
*.pdf
54
models/*
65
runs/*
76
*.pth
87
*.pyc
9-
path.py
108
params.py
119
*.mat
1210
*.txt

README.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,45 @@
1-
# OSVOS-PyTorch
1+
# OSVOS: One-Shot Video Object Segmentation
2+
Check our [project page](http://www.vision.ee.ethz.ch/~cvlsegmentation/osvos) for additional information.
3+
![OSVOS](doc/ims/osvos.png)
4+
5+
OSVOS is a method that tackles the task of semi-supervised video object segmentation. It is based on a fully-convolutional neural network architecture that is able to successively transfer generic semantic information, learned on ImageNet, to the task of foreground segmentation, and finally to learning the appearance of a single annotated object of the test sequence (hence one-shot). Experiments on DAVIS 2016 show that OSVOS is faster than currently available techniques and improves the state of the art by a significant margin (79.8% vs 68.0%).
6+
7+
8+
This PyTorch code is a posteriori implementation of OSVOS and it does not contain the boundary snapping branch. The results published in the paper were obtained using the Caffe version that can be found at [OSVOS-caffe](https://github.com/kmaninis/OSVOS-caffe). TensorFlow implementation is also available at [OSVOS-TensorFlow](https://github.com/scaelles/OSVOS-TensorFlow).
9+
10+
11+
### Installation:
12+
1. Clone the OSVOS-PyTorch repository
13+
```Shell
14+
git clone https://github.com/kmaninis/OSVOS-PyTorch.git
15+
```
16+
2. Install - if necessary - the required dependencies:
17+
18+
- Python (tested with Anaconda 2.7 and 3.6)
19+
- PyTorch (`conda install pytorch torchvision -c pytorch` - tested with PyTorch 0.3, CUDA 8.0)
20+
- Other python dependencies: numpy, scipy, matplotlib, opencv-python
21+
- Optionally, install tensorboard (`pip install tensorboard tensorboardx`)
22+
3. Edit the paths in mypath.py
23+
24+
### Online training and testing
25+
1. Download the [parent model](https://data.vision.ee.ethz.ch/kmaninis/share/OSVOS/Downloads/models/pth_parent_model.zip) (55 MB), and unzip it under `models/`.
26+
2. Edit in file `osvos_demo.py` the 'User defined parameters' (eg. gpu_id, etc).
27+
3. Run `python train_online.py`.
28+
29+
### Training the parent network (optional)
30+
1. All the training sequences of DAVIS 2016 are required to train the parent model, thus download them from [here](https://graphics.ethz.ch/Downloads/Data/Davis/DAVIS-data.zip).
31+
2. Download the [VGG model](https://data.vision.ee.ethz.ch/kmaninis/share/OSVOS/Downloads/models/vgg_mat.zip) (55 MB) pretrained on ImageNet, and unzip it under `models/`.
32+
3. Edit the 'User defined parameters' (eg. gpu_id) in file `train_parent.py`.
33+
4. Run `train_parent.py`. This step takes 20 hours to train (Titan-X Pascal).
34+
35+
Enjoy!
36+
37+
### Citation:
38+
@Inproceedings{Cae+17,
39+
Title = {One-Shot Video Object Segmentation},
40+
Author = {S. Caelles and K.K. Maninis and J. Pont-Tuset and L. Leal-Taix\'e and D. Cremers and L. {Van Gool}},
41+
Booktitle = {Computer Vision and Pattern Recognition (CVPR)},
42+
Year = {2017}
43+
}
44+
If you encounter any problems with the code, want to report bugs, etc. please contact us at {kmaninis, scaelles}[at]vision[dot]ee[dot]ethz[dot]ch.
45+

cluster/script.sh

Lines changed: 0 additions & 19 deletions
This file was deleted.

cluster/wrapper.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

dataloaders/coco.py

Lines changed: 0 additions & 183 deletions
This file was deleted.

dataloaders/custom_transforms.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,26 @@ def __call__(self, sample):
2929
(self.scales[1] - self.scales[0]) / 2 + 1
3030
elif type(self.rots) == list:
3131
# Fixed range of scales and rotations
32-
rot = self.rots[random.randint(0, len(self.rots)-1)]
33-
sc = self.scales[random.randint(0, len(self.scales) - 1)]
32+
rot = self.rots[random.randint(0, len(self.rots))]
33+
sc = self.scales[random.randint(0, len(self.scales))]
3434

3535
for elem in sample.keys():
36+
if 'fname' in elem:
37+
continue
38+
3639
tmp = sample[elem]
3740

3841
h, w = tmp.shape[:2]
3942
center = (w / 2, h / 2)
43+
assert(center != 0) # Strange behaviour warpAffine
4044
M = cv2.getRotationMatrix2D(center, rot, sc)
4145

42-
if tmp.ndim==2:
46+
if ((tmp == 0) | (tmp == 1)).all():
4347
flagval = cv2.INTER_NEAREST
4448
else:
4549
flagval = cv2.INTER_CUBIC
46-
4750
tmp = cv2.warpAffine(tmp, M, (w, h), flags=flagval)
4851

49-
if tmp.min() < 0.0:
50-
tmp = tmp - tmp.min()
51-
52-
if tmp.max() > 1.0:
53-
tmp = tmp / tmp.max()
54-
5552
sample[elem] = tmp
5653

5754
return sample
@@ -71,9 +68,11 @@ def __call__(self, sample):
7168
sc = self.scales[random.randint(0, len(self.scales) - 1)]
7269

7370
for elem in sample.keys():
71+
if 'fname' in elem:
72+
continue
7473
tmp = sample[elem]
7574

76-
if tmp.ndim==2:
75+
if tmp.ndim == 2:
7776
flagval = cv2.INTER_NEAREST
7877
else:
7978
flagval = cv2.INTER_CUBIC
@@ -92,6 +91,8 @@ def __call__(self, sample):
9291

9392
if random.random() < 0.5:
9493
for elem in sample.keys():
94+
if 'fname' in elem:
95+
continue
9596
tmp = sample[elem]
9697
tmp = cv2.flip(tmp, flipCode=1)
9798
sample[elem] = tmp
@@ -105,6 +106,8 @@ class ToTensor(object):
105106
def __call__(self, sample):
106107

107108
for elem in sample.keys():
109+
if 'fname' in elem:
110+
continue
108111
tmp = sample[elem]
109112

110113
if tmp.ndim == 2:
@@ -117,4 +120,4 @@ def __call__(self, sample):
117120
tmp = tmp.transpose((2, 0, 1))
118121
sample[elem] = torch.from_numpy(tmp)
119122

120-
return sample
123+
return sample

0 commit comments

Comments
 (0)