diff --git a/.gitignore b/.gitignore index 9b7e192..de930fb 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ /resources/pascalVocData/ /results/ /selectivesearch/ +.idea diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/fastRCNN/utils36_win64/.gitignore b/fastRCNN/utils36_win64/.gitignore new file mode 100644 index 0000000..4b8a745 --- /dev/null +++ b/fastRCNN/utils36_win64/.gitignore @@ -0,0 +1,2 @@ +*.c +*.so diff --git a/fastRCNN/utils36_win64/__init__.py b/fastRCNN/utils36_win64/__init__.py new file mode 100644 index 0000000..7ba6a65 --- /dev/null +++ b/fastRCNN/utils36_win64/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------- +# Fast R-CNN +# Copyright (c) 2015 Microsoft +# Licensed under The MIT License [see LICENSE for details] +# Written by Ross Girshick +# -------------------------------------------------------- diff --git a/fastRCNN/utils36_win64/blob.py b/fastRCNN/utils36_win64/blob.py new file mode 100644 index 0000000..1c31642 --- /dev/null +++ b/fastRCNN/utils36_win64/blob.py @@ -0,0 +1,45 @@ +# -------------------------------------------------------- +# Fast R-CNN +# Copyright (c) 2015 Microsoft +# Licensed under The MIT License [see LICENSE for details] +# Written by Ross Girshick +# -------------------------------------------------------- + +"""Blob helper functions.""" + +import numpy as np +import cv2 + +def im_list_to_blob(ims): + """Convert a list of images into a network input. + + Assumes images are already prepared (means subtracted, BGR order, ...). + """ + max_shape = np.array([im.shape for im in ims]).max(axis=0) + num_images = len(ims) + blob = np.zeros((num_images, max_shape[0], max_shape[1], 3), + dtype=np.float32) + for i in xrange(num_images): + im = ims[i] + blob[i, 0:im.shape[0], 0:im.shape[1], :] = im + # Move channels (axis 3) to axis 1 + # Axis order will become: (batch elem, channel, height, width) + channel_swap = (0, 3, 1, 2) + blob = blob.transpose(channel_swap) + return blob + +def prep_im_for_blob(im, pixel_means, target_size, max_size): + """Mean subtract and scale an image for use in a blob.""" + im = im.astype(np.float32, copy=False) + im -= pixel_means + im_shape = im.shape + im_size_min = np.min(im_shape[0:2]) + im_size_max = np.max(im_shape[0:2]) + im_scale = float(target_size) / float(im_size_min) + # Prevent the biggest axis from being more than MAX_SIZE + if np.round(im_scale * im_size_max) > max_size: + im_scale = float(max_size) / float(im_size_max) + im = cv2.resize(im, None, None, fx=im_scale, fy=im_scale, + interpolation=cv2.INTER_LINEAR) + + return im, im_scale diff --git a/fastRCNN/utils36_win64/cython_bbox.pyd b/fastRCNN/utils36_win64/cython_bbox.pyd new file mode 100644 index 0000000..194e7b1 Binary files /dev/null and b/fastRCNN/utils36_win64/cython_bbox.pyd differ diff --git a/fastRCNN/utils36_win64/timer.py b/fastRCNN/utils36_win64/timer.py new file mode 100644 index 0000000..dacc942 --- /dev/null +++ b/fastRCNN/utils36_win64/timer.py @@ -0,0 +1,32 @@ +# -------------------------------------------------------- +# Fast R-CNN +# Copyright (c) 2015 Microsoft +# Licensed under The MIT License [see LICENSE for details] +# Written by Ross Girshick +# -------------------------------------------------------- + +import time + +class Timer(object): + """A simple timer.""" + def __init__(self): + self.total_time = 0. + self.calls = 0 + self.start_time = 0. + self.diff = 0. + self.average_time = 0. + + def tic(self): + # using time.time instead of time.clock because time time.clock + # does not normalize for multithreading + self.start_time = time.time() + + def toc(self, average=True): + self.diff = time.time() - self.start_time + self.total_time += self.diff + self.calls += 1 + self.average_time = self.total_time / self.calls + if average: + return self.average_time + else: + return self.diff