1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Scratch pad"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from glob import glob\n",
"from os.path import join\n",
"from pathlib import Path\n",
"import random\n",
"\n",
"import pandas as pd\n",
"import cv2 as cv\n",
"import numpy as np\n",
"%matplotlib inline\n",
"import matplotlib.pyplot as plt\n",
"\n",
"import sys\n",
"sys.path.append('/work/megapixels_dev/megapixels')\n",
"from app.models.bbox import BBox\n",
"from app.utils import im_utils, file_utils"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"a= [1]"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a[-1]"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [],
"source": [
"fp_filepath = '/data_store_ssd/datasets/people/lfw/metadata/filepath.csv'\n",
"df_filepath = pd.read_csv(fp_filepath)"
]
},
{
"cell_type": "code",
"execution_count": 48,
"metadata": {},
"outputs": [],
"source": [
"image_index = 12467"
]
},
{
"cell_type": "code",
"execution_count": 55,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"12474\n"
]
},
{
"data": {
"text/plain": [
"index 12851\n",
"ext jpg\n",
"fn Vladimir_Putin_0029\n",
"subdir Vladimir_Putin\n",
"Name: 12474, dtype: object"
]
},
"execution_count": 55,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"image_index += 1\n",
"print(image_index)\n",
"df_filepath.iloc[image_index]"
]
},
{
"cell_type": "code",
"execution_count": 56,
"metadata": {},
"outputs": [],
"source": [
"import imutils"
]
},
{
"cell_type": "code",
"execution_count": 57,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Help on function build_montages in module imutils.convenience:\n",
"\n",
"build_montages(image_list, image_shape, montage_shape)\n",
" ---------------------------------------------------------------------------------------------\n",
" author: Kyle Hounslow\n",
" ---------------------------------------------------------------------------------------------\n",
" Converts a list of single images into a list of 'montage' images of specified rows and columns.\n",
" A new montage image is started once rows and columns of montage image is filled.\n",
" Empty space of incomplete montage images are filled with black pixels\n",
" ---------------------------------------------------------------------------------------------\n",
" :param image_list: python list of input images\n",
" :param image_shape: tuple, size each image will be resized to for display (width, height)\n",
" :param montage_shape: tuple, shape of image montage (width, height)\n",
" :return: list of montage images in numpy array format\n",
" ---------------------------------------------------------------------------------------------\n",
" \n",
" example usage:\n",
" \n",
" # load single image\n",
" img = cv2.imread('lena.jpg')\n",
" # duplicate image 25 times\n",
" num_imgs = 25\n",
" img_list = []\n",
" for i in xrange(num_imgs):\n",
" img_list.append(img)\n",
" # convert image list into a montage of 256x256 images tiled in a 5x5 montage\n",
" montages = make_montages_of_images(img_list, (256, 256), (5, 5))\n",
" # iterate through montages and display\n",
" for montage in montages:\n",
" cv2.imshow('montage image', montage)\n",
" cv2.waitKey(0)\n",
" \n",
" ----------------------------------------------------------------------------------------------\n",
"\n"
]
}
],
"source": [
"help(imutils.build_montages)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python [conda env:megapixels]",
"language": "python",
"name": "conda-env-megapixels-py"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
|