Skip to content

Commit 4cb015b

Browse files
committed
color reconstruction
1 parent 8b68bcd commit 4cb015b

6 files changed

+1677
-0
lines changed

class_15/.ipynb_checkpoints/Conv-Auto_Enc-checkpoint.ipynb

+611
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"cells": [],
3+
"metadata": {},
4+
"nbformat": 4,
5+
"nbformat_minor": 2
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"metadata": {
7+
"collapsed": false
8+
},
9+
"outputs": [
10+
{
11+
"name": "stderr",
12+
"output_type": "stream",
13+
"text": [
14+
"Using TensorFlow backend.\n"
15+
]
16+
}
17+
],
18+
"source": [
19+
"import numpy as np\n",
20+
"import pandas as pd\n",
21+
"import cv2\n",
22+
"import os\n",
23+
"from matplotlib import pyplot as plt\n",
24+
"%matplotlib inline\n",
25+
"\n",
26+
"import keras\n",
27+
"from keras.layers import Dense, Convolution2D, MaxPooling2D, Activation, Flatten\n",
28+
"from keras.layers import Reshape, UpSampling2D, ZeroPadding2D, Input\n",
29+
"from keras.models import Sequential, Model"
30+
]
31+
},
32+
{
33+
"cell_type": "code",
34+
"execution_count": 2,
35+
"metadata": {
36+
"collapsed": false
37+
},
38+
"outputs": [],
39+
"source": [
40+
"data_path = '../../Dataset/JPEGImages/'"
41+
]
42+
},
43+
{
44+
"cell_type": "code",
45+
"execution_count": 7,
46+
"metadata": {
47+
"collapsed": false
48+
},
49+
"outputs": [
50+
{
51+
"name": "stdout",
52+
"output_type": "stream",
53+
"text": [
54+
"4000\n"
55+
]
56+
}
57+
],
58+
"source": [
59+
"ims = os.listdir(data_path)\n",
60+
"\n",
61+
"select_ims = []\n",
62+
"for ix in range(4000):\n",
63+
" if '.jpg' in ims[ix]:\n",
64+
" img = cv2.imread(data_path + ims[ix])\n",
65+
" img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)\n",
66+
" img = cv2.resize(img, (120, 120))\n",
67+
" select_ims.append(img)\n",
68+
"print len(select_ims)"
69+
]
70+
},
71+
{
72+
"cell_type": "code",
73+
"execution_count": 8,
74+
"metadata": {
75+
"collapsed": false
76+
},
77+
"outputs": [
78+
{
79+
"name": "stdout",
80+
"output_type": "stream",
81+
"text": [
82+
"(4000, 320, 320, 3)\n"
83+
]
84+
}
85+
],
86+
"source": [
87+
"data = np.asarray(select_ims)\n",
88+
"print data.shape"
89+
]
90+
},
91+
{
92+
"cell_type": "code",
93+
"execution_count": 9,
94+
"metadata": {
95+
"collapsed": true
96+
},
97+
"outputs": [],
98+
"source": [
99+
"np.save('image_data', data)"
100+
]
101+
}
102+
],
103+
"metadata": {
104+
"kernelspec": {
105+
"display_name": "Python 2",
106+
"language": "python",
107+
"name": "python2"
108+
},
109+
"language_info": {
110+
"codemirror_mode": {
111+
"name": "ipython",
112+
"version": 2
113+
},
114+
"file_extension": ".py",
115+
"mimetype": "text/x-python",
116+
"name": "python",
117+
"nbconvert_exporter": "python",
118+
"pygments_lexer": "ipython2",
119+
"version": "2.7.12"
120+
}
121+
},
122+
"nbformat": 4,
123+
"nbformat_minor": 2
124+
}

0 commit comments

Comments
 (0)