From dfa3664a0f56445b023020a0ddb5eedc2780169a Mon Sep 17 00:00:00 2001
From: natanielruiz <nataniel777@hotmail.com>
Date: 星期三, 13 九月 2017 21:38:25 +0800
Subject: [PATCH] Center crop instead of random crop for testing.
---
practice/load_AFLW-Copy1.ipynb | 53 +++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 41 insertions(+), 12 deletions(-)
diff --git a/practice/load_AFLW-Copy1.ipynb b/practice/load_AFLW-Copy1.ipynb
index edac84d..2b6bf67 100644
--- a/practice/load_AFLW-Copy1.ipynb
+++ b/practice/load_AFLW-Copy1.ipynb
@@ -31,7 +31,7 @@
"source": [
"#Change this paths according to your directories\n",
"images_path = \"/Data/nruiz9/data/facial_landmarks/AFLW/aflw/data/flickr/\"\n",
- "storing_path = \"/Data/nruiz9/data/facial_landmarks/AFLW/aflw_cropped/\""
+ "storing_path = \"/Data/nruiz9/data/facial_landmarks/AFLW/aflw_cropped_loose/\""
]
},
{
@@ -40,7 +40,15 @@
"metadata": {
"collapsed": false
},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Done\n"
+ ]
+ }
+ ],
"source": [
"#Image counter\n",
"counter = 1\n",
@@ -92,17 +100,19 @@
" face_h = row[8]\n",
"\n",
" #Error correction\n",
- " if(face_x < 0): face_x = 0\n",
- " if(face_y < 0): face_y = 0\n",
- " if(face_w > image_w): \n",
- " face_w = image_w\n",
- " face_h = image_w\n",
- " if(face_h > image_h): \n",
- " face_h = image_h\n",
- " face_w = image_h\n",
- "\n",
+ " k = 0.35\n",
+ " x_min = face_x - face_w * k * 0.6\n",
+ " x_max = face_x + face_w + face_w * k * 0.6\n",
+ " y_min = face_y - face_h * k * 2\n",
+ " y_max = face_y + face_h + face_h * k * 0.6\n",
+ " \n",
+ " x_min = int(max(0, x_min))\n",
+ " x_max = int(min(image_w, x_max))\n",
+ " y_min = int(max(0, y_min))\n",
+ " y_max = int(min(image_h, y_max))\n",
+ " \n",
" #Crop the face from the image\n",
- " image_cropped = np.copy(image[face_y:face_y+face_h, face_x:face_x+face_w])\n",
+ " image_cropped = np.copy(image[y_min:y_max, x_min:x_max])\n",
" #Uncomment the lines below if you want to rescale the image to a particular size\n",
" to_size = 240\n",
" image_cropped = cv2.resize(image_cropped, (to_size,to_size), interpolation = cv2.INTER_AREA)\n",
@@ -134,6 +144,25 @@
},
{
"cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "test\n"
+ ]
+ }
+ ],
+ "source": [
+ "print 'test'"
+ ]
+ },
+ {
+ "cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
--
Gitblit v1.8.0