Skip to content

Commit

Permalink
Finetuning files added
Browse files Browse the repository at this point in the history
  • Loading branch information
scaelles committed Apr 13, 2017
1 parent 7335bfd commit 17f9d2e
Show file tree
Hide file tree
Showing 85 changed files with 919 additions and 2 deletions.
Binary file added DAVIS/Annotations/480p/car-shadow/00000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DAVIS/Annotations/480p/car-shadow/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DAVIS/Annotations/480p/car-shadow/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DAVIS/Annotations/480p/car-shadow/00003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DAVIS/Annotations/480p/car-shadow/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DAVIS/Annotations/480p/car-shadow/00005.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DAVIS/Annotations/480p/car-shadow/00006.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DAVIS/Annotations/480p/car-shadow/00007.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DAVIS/Annotations/480p/car-shadow/00008.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DAVIS/Annotations/480p/car-shadow/00009.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DAVIS/Annotations/480p/car-shadow/00010.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DAVIS/Annotations/480p/car-shadow/00011.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DAVIS/Annotations/480p/car-shadow/00012.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DAVIS/Annotations/480p/car-shadow/00013.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DAVIS/Annotations/480p/car-shadow/00014.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DAVIS/Annotations/480p/car-shadow/00015.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DAVIS/Annotations/480p/car-shadow/00016.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DAVIS/Annotations/480p/car-shadow/00017.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DAVIS/Annotations/480p/car-shadow/00018.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DAVIS/Annotations/480p/car-shadow/00019.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DAVIS/Annotations/480p/car-shadow/00020.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DAVIS/Annotations/480p/car-shadow/00021.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DAVIS/Annotations/480p/car-shadow/00022.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DAVIS/Annotations/480p/car-shadow/00023.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DAVIS/Annotations/480p/car-shadow/00024.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DAVIS/Annotations/480p/car-shadow/00025.png
Binary file added DAVIS/Annotations/480p/car-shadow/00026.png
Binary file added DAVIS/Annotations/480p/car-shadow/00027.png
Binary file added DAVIS/Annotations/480p/car-shadow/00028.png
Binary file added DAVIS/Annotations/480p/car-shadow/00029.png
Binary file added DAVIS/Annotations/480p/car-shadow/00030.png
Binary file added DAVIS/Annotations/480p/car-shadow/00031.png
Binary file added DAVIS/Annotations/480p/car-shadow/00032.png
Binary file added DAVIS/Annotations/480p/car-shadow/00033.png
Binary file added DAVIS/Annotations/480p/car-shadow/00034.png
Binary file added DAVIS/Annotations/480p/car-shadow/00035.png
Binary file added DAVIS/Annotations/480p/car-shadow/00036.png
Binary file added DAVIS/Annotations/480p/car-shadow/00037.png
Binary file added DAVIS/Annotations/480p/car-shadow/00038.png
Binary file added DAVIS/Annotations/480p/car-shadow/00039.png
Binary file added DAVIS/JPEGImages/480p/car-shadow/00000.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00001.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00002.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00003.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00004.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00005.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00006.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00007.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00008.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00009.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00010.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00011.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00012.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00013.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00014.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00015.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00016.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00017.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00018.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00019.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00020.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00021.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00022.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00023.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00024.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00025.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00026.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00027.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00028.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00029.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00030.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00031.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00032.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00033.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00034.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00035.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00036.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00037.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00038.jpg
Binary file added DAVIS/JPEGImages/480p/car-shadow/00039.jpg
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
# OSVOS: One-Shot Video Object Segmentation (Code coming soon!)
# OSVOS: One-Shot Video Object Segmentation
Check our [project page](http://www.vision.ee.ethz.ch/~cvlsegmentation/osvos) for additional information.
![OSVOS](doc/ims/osvos.png)

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 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%).


This TensorFlow 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).

This TensorFlow code is a posteriori implementation of OSVOS. 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).

### Installation:
1. Clone the OSVOS-TensorFlow repository
```Shell
git clone https://github.com/kmaninis/OSVOS-TensorFlow.git
```
2. Install if necessary the required dependencies:
```
Python 2.7
Tensorflow r1.0 or higher (pip install tensorflow-gpu)
Other python dependencies: PIL (Pillow version), numpy, scipy, matplotlib
```
3. Download the parent model from [here](https://data.vision.ee.ethz.ch/csergi/share/OSVOS/OSVOS_parent_model.zip) (55 MB) and unzip it under `models/` (It should create a folder named 'OSVOS_parent').

4. All the steps to re-train OSVOS are provided in this repository. In case you would like to test with the pre-trained models, you can download them from [here](https://data.vision.ee.ethz.ch/csergi/share/OSVOS/OSVOS_pre-trained_models.zip) (2.2GB) and unzip them under `models/` (It should create a folder for every model).

### Demo online training and testing
1. Edit in file `osvos_demo.py` the 'User defined parameters' (eg. gpu_id, train_model, etc)

2. Run `python osvos_demo.py`

It is possible to work with all sequences of DAVIS just by creating a soft link (`ln -s /path/to/DAVIS/`) in the root folder of the project.

### Citation:
@Inproceedings{Cae+17,
Expand Down
166 changes: 166 additions & 0 deletions dataset.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
"""
Sergi Caelles ([email protected])
This file is part of the OSVOS paper presented in:
Sergi Caelles, Kevis-Kokitsi Maninis, Jordi Pont-Tuset, Laura Leal-Taixe, Daniel Cremers, Luc Van Gool
One-Shot Video Object Segmentation
CVPR 2017
Please consider citing the paper if you use this code.
"""
from PIL import Image
import os
import numpy as np
import sys


class Dataset:
def __init__(self, train_list, test_list, database_root, store_memory=True, data_aug=False):
"""Initialize the Dataset object
Args:
train_list: TXT file or list with the paths of the images to use for training (Images must be between 0 and 255)
test_list: TXT file or list with the paths of the images to use for testing (Images must be between 0 and 255)
database_root: Path to the root of the Database
store_memory: True stores all the training images, False loads at runtime the images
Returns:
"""
if not store_memory and data_aug:
sys.stderr.write('Online data augmentation not supported when the data is not stored in memory!')
sys.exit()
# Define types of data augmentation
data_aug_scales = [0.5, 0.8, 1]
data_aug_flip = True

# Load training images (path) and labels
print('Started loading files...')
if not isinstance(train_list, list) and train_list is not None:
with open(train_list) as t:
train_paths = t.readlines()
elif isinstance(train_list, list):
train_paths = train_list
else:
train_paths = []
if not isinstance(test_list, list) and test_list is not None:
with open(test_list) as t:
test_paths = t.readlines()
elif isinstance(test_list, list):
test_paths = test_list
else:
test_paths = []
self.images_train = []
self.images_train_path = []
self.labels_train = []
self.labels_train_path = []
for idx, line in enumerate(train_paths):
if store_memory:
img = Image.open(os.path.join(database_root, str(line.split()[0])))
label = Image.open(os.path.join(database_root, str(line.split()[1])))
if data_aug:
for scale in data_aug_scales:
img_size = tuple([int(img.size[0] * scale), int(img.size[1] * scale)])
img_sc = img.resize(img_size)
label_sc = label.resize(img_size)
self.images_train.append(np.array(img_sc, dtype=np.uint8))
self.labels_train.append(np.array(label_sc, dtype=np.uint8))
if data_aug_flip:
img_sc_fl = img_sc.transpose(Image.FLIP_LEFT_RIGHT)
label_sc_fl = label_sc.transpose(Image.FLIP_LEFT_RIGHT)
self.images_train.append(np.array(img_sc_fl, dtype=np.uint8))
self.labels_train.append(np.array(label_sc_fl, dtype=np.uint8))
else:
self.images_train.append(np.array(img, dtype=np.uint8))
self.labels_train.append(np.array(label, dtype=np.uint8))
if (idx + 1) % 1000 == 0:
print('Loaded ' + str(idx) + ' train images')
self.images_train_path.append(os.path.join(database_root, str(line.split()[0])))
self.labels_train_path.append(os.path.join(database_root, str(line.split()[1])))
self.images_train_path = np.array(self.images_train_path)
self.labels_train_path = np.array(self.labels_train_path)

# Load testing images (path) and labels
self.images_test = []
self.images_test_path = []
for idx, line in enumerate(test_paths):
if store_memory:
self.images_test.append(np.array(Image.open(os.path.join(database_root, str(line.split()[0]))),
dtype=np.uint8))
if (idx + 1) % 1000 == 0:
print('Loaded ' + str(idx) + ' test images')
self.images_test_path.append(os.path.join(database_root, str(line.split()[0])))
print('Done initializing Dataset')

# Init parameters
self.train_ptr = 0
self.test_ptr = 0
self.train_size = max(len(self.images_train_path), len(self.images_train))
self.test_size = len(self.images_test_path)
self.train_idx = np.arange(self.train_size)
np.random.shuffle(self.train_idx)
self.store_memory = store_memory

def next_batch(self, batch_size, phase):
"""Get next batch of image (path) and labels
Args:
batch_size: Size of the batch
phase: Possible options:'train' or 'test'
Returns in training:
images: List of images paths if store_memory=False, List of Numpy arrays of the images if store_memory=True
labels: List of labels paths if store_memory=False, List of Numpy arrays of the labels if store_memory=True
Returns in testing:
images: None if store_memory=False, Numpy array of the image if store_memory=True
path: List of image paths
"""
if phase == 'train':
if self.train_ptr + batch_size < self.train_size:
idx = np.array(self.train_idx[self.train_ptr:self.train_ptr + batch_size])
if self.store_memory:
images = [self.images_train[l] for l in idx]
labels = [self.labels_train[l] for l in idx]
else:
images = [self.images_train_path[l] for l in idx]
labels = [self.labels_train_path[l] for l in idx]
self.train_ptr += batch_size
else:
old_idx = np.array(self.train_idx[self.train_ptr:])
np.random.shuffle(self.train_idx)
new_ptr = (self.train_ptr + batch_size) % self.train_size
idx = np.array(self.train_idx[:new_ptr])
if self.store_memory:
images_1 = [self.images_train[l] for l in old_idx]
labels_1 = [self.labels_train[l] for l in old_idx]
images_2 = [self.images_train[l] for l in idx]
labels_2 = [self.labels_train[l] for l in idx]
else:
images_1 = [self.images_train_path[l] for l in old_idx]
labels_1 = [self.labels_train_path[l] for l in old_idx]
images_2 = [self.images_train_path[l] for l in idx]
labels_2 = [self.labels_train_path[l] for l in idx]
images = images_1 + images_2
labels = labels_1 + labels_2
self.train_ptr = new_ptr
return images, labels
elif phase == 'test':
images = None
if self.test_ptr + batch_size < self.test_size:
if self.store_memory:
images = self.images_test[self.test_ptr:self.test_ptr + batch_size]
paths = self.images_test_path[self.test_ptr:self.test_ptr + batch_size]
self.test_ptr += batch_size
else:
new_ptr = (self.test_ptr + batch_size) % self.test_size
if self.store_memory:
images = self.images_test[self.test_ptr:] + self.images_test[:new_ptr]
paths = self.images_test_path[self.test_ptr:] + self.images_test_path[:new_ptr]
self.test_ptr = new_ptr
return images, paths
else:
return None, None

def get_train_size(self):
return self.train_size

def get_test_size(self):
return self.test_size

def train_img_size(self):
width, height = Image.open(self.images_train[self.train_ptr]).size
return height, width
4 changes: 4 additions & 0 deletions models/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
Loading

0 comments on commit 17f9d2e

Please sign in to comment.