From 0699496ad20c8a44f8316cd71abdc24e679acfec Mon Sep 17 00:00:00 2001 From: mschart Date: Tue, 27 Nov 2018 11:38:41 +0100 Subject: [PATCH 1/5] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 5acace4..77bd1e7 100755 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +FORK OF PREDNET + + # prednet Code and models accompanying [Deep Predictive Coding Networks for Video Prediction and Unsupervised Learning](https://arxiv.org/abs/1605.08104) by Bill Lotter, Gabriel Kreiman, and David Cox. From 6c7808f0af3091383494c93bee5381135c7d563a Mon Sep 17 00:00:00 2001 From: mschart Date: Tue, 27 Nov 2018 11:47:20 +0100 Subject: [PATCH 2/5] Update process_kitti.py --- process_kitti.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/process_kitti.py b/process_kitti.py index aa5c2e6..47a0207 100755 --- a/process_kitti.py +++ b/process_kitti.py @@ -5,7 +5,7 @@ import os import requests from bs4 import BeautifulSoup -import urllib +import urllib.request import numpy as np from scipy.misc import imread, imresize import hickle as hkl @@ -32,22 +32,22 @@ def download_data(): soup = BeautifulSoup(r.content) drive_list = soup.find_all("h3") drive_list = [d.text[:d.text.find(' ')] for d in drive_list] - print "Downloading set: " + c + print( "Downloading set: " + c) c_dir = base_dir + c + '/' if not os.path.exists(c_dir): os.mkdir(c_dir) for i, d in enumerate(drive_list): - print str(i+1) + '/' + str(len(drive_list)) + ": " + d + print( str(i+1) + '/' + str(len(drive_list)) + ": " + d) url = "https://s3.eu-central-1.amazonaws.com/avg-kitti/raw_data/" + d + "/" + d + "_sync.zip" - urllib.urlretrieve(url, filename=c_dir + d + "_sync.zip") + urllib.request.urlretrieve(url, filename=c_dir + d + "_sync.zip") # unzip images def extract_data(): for c in categories: c_dir = os.path.join(DATA_DIR, 'raw/', c + '/') - _, _, zip_files = os.walk(c_dir).next() + zip_files = list(os.walk(c_dir))[-1][-1]#.next() for f in zip_files: - print 'unpacking: ' + f + print( 'unpacking: ' + f) spec_folder = f[:10] + '/' + f[:-4] + '/image_03/data*' command = 'unzip -qq ' + c_dir + f + ' ' + spec_folder + ' -d ' + c_dir + f[:-4] os.system(command) @@ -62,7 +62,7 @@ def process_data(): not_train = splits['val'] + splits['test'] for c in categories: # Randomly assign recordings to training and testing. Cross-validation done across entire recordings. c_dir = os.path.join(DATA_DIR, 'raw', c + '/') - _, folders, _ = os.walk(c_dir).next() + folders= list(os.walk(c_dir))[-1][-2] splits['train'] += [(c, f) for f in folders if (c, f) not in not_train] for split in splits: @@ -70,11 +70,11 @@ def process_data(): source_list = [] # corresponds to recording that image came from for category, folder in splits[split]: im_dir = os.path.join(DATA_DIR, 'raw/', category, folder, folder[:10], folder, 'image_03/data/') - _, _, files = os.walk(im_dir).next() + files = list(os.walk(im_dir))[-1][-1] im_list += [im_dir + f for f in sorted(files)] source_list += [category + '-' + folder] * len(files) - print 'Creating ' + split + ' data: ' + str(len(im_list)) + ' images' + print( 'Creating ' + split + ' data: ' + str(len(im_list)) + ' images') X = np.zeros((len(im_list),) + desired_im_sz + (3,), np.uint8) for i, im_file in enumerate(im_list): im = imread(im_file) From 09a5bc49b8956f88662964796084a80ab3c74380 Mon Sep 17 00:00:00 2001 From: Berk Gercek Date: Wed, 28 Nov 2018 12:37:06 +0100 Subject: [PATCH 3/5] Potential fix for the issue of iterator.next() not being supported in python 3 (see data_utils for __getitem__ workaround) --- .gitignore | 4 ++++ License.txt | 0 data_utils.py | 3 +++ environment.yml | 0 process_kitti.py | 9 +++++---- 5 files changed, 12 insertions(+), 4 deletions(-) mode change 100644 => 100755 .gitignore mode change 100644 => 100755 License.txt mode change 100644 => 100755 environment.yml diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 index 72364f9..2f54e6b --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,10 @@ __pycache__/ # C extensions *.so +# Video and data folders +kitti_data/ +model_data_keras*/ + # Distribution / packaging .Python env/ diff --git a/License.txt b/License.txt old mode 100644 new mode 100755 diff --git a/data_utils.py b/data_utils.py index 863ddbd..ede9b29 100755 --- a/data_utils.py +++ b/data_utils.py @@ -43,6 +43,9 @@ def __init__(self, data_file, source_file, nt, self.N_sequences = len(self.possible_starts) super(SequenceGenerator, self).__init__(len(self.possible_starts), batch_size, shuffle, seed) + def __getitem__(self, null): + return self.next() + def next(self): with self.lock: index_array, current_index, current_batch_size = next(self.index_generator) diff --git a/environment.yml b/environment.yml old mode 100644 new mode 100755 diff --git a/process_kitti.py b/process_kitti.py index 47a0207..1d2f401 100755 --- a/process_kitti.py +++ b/process_kitti.py @@ -7,7 +7,8 @@ from bs4 import BeautifulSoup import urllib.request import numpy as np -from scipy.misc import imread, imresize +from imageio import imread +from scipy.misc import imresize import hickle as hkl from kitti_settings import * @@ -45,7 +46,7 @@ def download_data(): def extract_data(): for c in categories: c_dir = os.path.join(DATA_DIR, 'raw/', c + '/') - zip_files = list(os.walk(c_dir))[-1][-1]#.next() + zip_files = list(os.walk(c_dir, topdown=False))[-1][-1]#.next() for f in zip_files: print( 'unpacking: ' + f) spec_folder = f[:10] + '/' + f[:-4] + '/image_03/data*' @@ -62,7 +63,7 @@ def process_data(): not_train = splits['val'] + splits['test'] for c in categories: # Randomly assign recordings to training and testing. Cross-validation done across entire recordings. c_dir = os.path.join(DATA_DIR, 'raw', c + '/') - folders= list(os.walk(c_dir))[-1][-2] + folders= list(os.walk(c_dir, topdown=False))[-1][-2] splits['train'] += [(c, f) for f in folders if (c, f) not in not_train] for split in splits: @@ -70,7 +71,7 @@ def process_data(): source_list = [] # corresponds to recording that image came from for category, folder in splits[split]: im_dir = os.path.join(DATA_DIR, 'raw/', category, folder, folder[:10], folder, 'image_03/data/') - files = list(os.walk(im_dir))[-1][-1] + files = list(os.walk(im_dir, topdown=False))[-1][-1] im_list += [im_dir + f for f in sorted(files)] source_list += [category + '-' + folder] * len(files) From badb3eb6ec3ee7e6bdb8a5716f17c6d084d9b131 Mon Sep 17 00:00:00 2001 From: Berk Gercek Date: Mon, 3 Dec 2018 15:33:45 +0100 Subject: [PATCH 4/5] Changed small bit to make py3 work --- data_utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/data_utils.py b/data_utils.py index ede9b29..cbcdf81 100755 --- a/data_utils.py +++ b/data_utils.py @@ -48,7 +48,8 @@ def __getitem__(self, null): def next(self): with self.lock: - index_array, current_index, current_batch_size = next(self.index_generator) + current_index = (self.batch_index * self.batch_size) % self.n + index_array, current_batch_size = next(self.index_generator), self.batch_size batch_x = np.zeros((current_batch_size, self.nt) + self.im_shape, np.float32) for i, idx in enumerate(index_array): idx = self.possible_starts[idx] From 6baebee177e0047edfc66fe9cfbf8f8efca52422 Mon Sep 17 00:00:00 2001 From: Berk Gercek Date: Wed, 5 Dec 2018 12:26:33 +0100 Subject: [PATCH 5/5] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 77bd1e7..3b40e9e 100755 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -FORK OF PREDNET +This is a fork of PredNet developed by Bill Lotter, Gabriel Kreiman, and David Cox which has been modified to use Python 3.6 and the most recent stable versions of Tensorflow and Keras. Worth noting that TF is only compatible with CUDA up to 9.0 and the associated CUDNN release. + +Below is the original readme from Bill Lotter's repository. # prednet