Permalink
Browse files

Add more pretrained models

  • Loading branch information...
Ming-Yu Liu
Ming-Yu Liu committed Oct 30, 2017
1 parent 4f9fa33 commit d01726adf1c43bcef7217f719f5bd317ca2094c6
Showing with 13 additions and 12 deletions.
  1. +1 −0 USAGE.md
  2. +12 −12 src/datasets/dataset_image.py
View
@@ -80,6 +80,7 @@ pip install tensorboard
6. Intermediate image outputs and model binary files are in <outputs/unit/blondhair>
For more pretrained models, please check out the google drive folder [Pretrained models](https://drive.google.com/open?id=0BwpOatrZwxK6UGtheHgta1F5d28).
#### SVHN2MNIST Adaptation
1. Go to <src> and execute
@@ -45,8 +45,8 @@ def _load_one_image(self, img_name, test=False):
else:
if np.random.rand(1) > 0.5:
img = cv2.flip(img, 1)
x_offset = np.int32(np.random.randint(0, w - self.crop_image_width + 1, 1))
y_offset = np.int32(np.random.randint(0, h - self.crop_image_height + 1, 1))
x_offset = np.int32(np.random.randint(0, w - self.crop_image_width + 1, 1))[0]
y_offset = np.int32(np.random.randint(0, h - self.crop_image_height + 1, 1))[0]
crop_img = img[y_offset:(y_offset + self.crop_image_height), x_offset:(x_offset + self.crop_image_width), :]
return crop_img
@@ -64,8 +64,8 @@ def _load_one_image(self, img_name, test=False):
else:
if np.random.rand(1) > 0.5:
img = cv2.flip(img, 1)
x_offset = np.int32(np.random.randint(0, w - self.crop_image_width + 1, 1))
y_offset = np.int32(np.random.randint(0, h - self.crop_image_height + 1, 1))
x_offset = np.int32(np.random.randint(0, w - self.crop_image_width + 1, 1))[0]
y_offset = np.int32(np.random.randint(0, h - self.crop_image_height + 1, 1))[0]
crop_img = img[y_offset:(y_offset + self.crop_image_height), x_offset:(x_offset + self.crop_image_width), :]
return crop_img
@@ -96,13 +96,13 @@ def _load_one_image(self, img_name, test=False):
img = np.float32(img)
h, w, c = img.shape
if test == True:
x_offset = np.int((w - self.crop_image_width) / 2)
y_offset = np.int((h - self.crop_image_height) / 2)
x_offset = np.int((w - self.crop_image_width) / 2)[0]
y_offset = np.int((h - self.crop_image_height) / 2)[0]
else:
if np.random.rand(1) > 0.5:
img = cv2.flip(img, 1)
x_offset = np.int32(np.random.randint(0, w - self.crop_image_width + 1, 1))
y_offset = np.int32(np.random.randint(0, h - self.crop_image_height + 1, 1))
x_offset = np.int32(np.random.randint(0, w - self.crop_image_width + 1, 1))[0]
y_offset = np.int32(np.random.randint(0, h - self.crop_image_height + 1, 1))[0]
crop_img = img[y_offset:(y_offset + self.crop_image_height), x_offset:(x_offset + self.crop_image_width), :]
return crop_img
@@ -131,13 +131,13 @@ def _load_one_image(self, img_name, test=False):
img = np.float32(img)
h, w, c = img.shape
if test == True:
x_offset = np.int((w - self.crop_image_width) / 2)
y_offset = np.int((h - self.crop_image_height) / 2)
x_offset = np.int((w - self.crop_image_width) / 2)[0]
y_offset = np.int((h - self.crop_image_height) / 2)[0]
else:
if np.random.rand(1) > 0.5:
img = cv2.flip(img, 1)
x_offset = np.int32(np.random.randint(0, w - self.crop_image_width + 1, 1))
y_offset = np.int32(np.random.randint(0, h - self.crop_image_height + 1, 1))
x_offset = np.int32(np.random.randint(0, w - self.crop_image_width + 1, 1))[0]
y_offset = np.int32(np.random.randint(0, h - self.crop_image_height + 1, 1))[0]
crop_img = img[y_offset:(y_offset + self.crop_image_height), x_offset:(x_offset + self.crop_image_width), :]
return crop_img

0 comments on commit d01726a

Please sign in to comment.