Commit 201f2fd1d87181505dafcef1ecafbd6ed2dddf3a
1 parent
5c9c44da
Exists in
master
and in
1 other branch
(ง •̀_•́)ง we're heading for modeling!
Showing
2 changed files
with
71 additions
and
1 deletions
Show diff stats
mdata/ANALYSIS.py
@@ -93,11 +93,28 @@ def anal_0000(): | @@ -93,11 +93,28 @@ def anal_0000(): | ||
93 | df_ILS.hist(column='size',bins=100) | 93 | df_ILS.hist(column='size',bins=100) |
94 | plt.show() | 94 | plt.show() |
95 | 95 | ||
96 | + | ||
97 | + | ||
98 | +def pre_crop(): | ||
99 | + df_ILS = pd.read_csv('../res/file-tag-test.tsv', names=['hash', 'width', 'height', 'size', 'quality','chosen','class'], sep='\t') | ||
100 | + print df_ILS.shape | ||
101 | + print df_ILS[(df_ILS['width'] >= 300) & (df_ILS['height'] >= 300)].shape | ||
102 | + | ||
103 | + # 300x300 4213 0.917 * | ||
104 | + # 200x200 4534 0.987 | ||
105 | + # 400x400 932 0.202 | ||
106 | + | ||
107 | + | ||
108 | + | ||
109 | + | ||
96 | if __name__ == '__main__': | 110 | if __name__ == '__main__': |
97 | # anal_ILSVRC() | 111 | # anal_ILSVRC() |
98 | # anal_ILSVRC_Test() | 112 | # anal_ILSVRC_Test() |
99 | - anal_0000() | 113 | + # anal_0000() |
100 | # print timeit.timeit("anal_ILSVRC()", setup="from __main__ import anal_ILSVRC", number=1) | 114 | # print timeit.timeit("anal_ILSVRC()", setup="from __main__ import anal_ILSVRC", number=1) |
115 | + | ||
116 | + | ||
117 | + pre_crop() | ||
101 | pass | 118 | pass |
102 | 119 | ||
103 | 120 |
@@ -0,0 +1,53 @@ | @@ -0,0 +1,53 @@ | ||
1 | +__author__ = 'chunk' | ||
2 | + | ||
3 | +import os, sys | ||
4 | +from PIL import Image | ||
5 | +from common import * | ||
6 | +import random | ||
7 | + | ||
8 | +base_dir = '/data/hadoop/ImageNet/ILSVRC/ILSVRC2013_DET_val/' | ||
9 | +category = 'Test' | ||
10 | + | ||
11 | + | ||
12 | +def crop_Test(): | ||
13 | + for path, subdirs, files in os.walk(os.path.join(base_dir, category)): | ||
14 | + for name in files: | ||
15 | + image = os.path.join(path, name) | ||
16 | + im = Image.open(image) | ||
17 | + w, h = im.size | ||
18 | + if w < 300 or h < 300: | ||
19 | + continue | ||
20 | + left, upper = random.randint(0, w - 300), random.randint(0, h - 300) | ||
21 | + im = im.crop((left, upper, left + 300, upper + 300)) | ||
22 | + im.save(os.path.join(base_dir, category + '_crop', name)) | ||
23 | + | ||
24 | + | ||
25 | + | ||
26 | +if __name__ == '__main__': | ||
27 | + timer = Timer() | ||
28 | + | ||
29 | + timer.mark() | ||
30 | + crop_Test() | ||
31 | + timer.report() | ||
32 | + | ||
33 | + pass | ||
34 | + | ||
35 | + | ||
36 | + | ||
37 | + | ||
38 | + | ||
39 | + | ||
40 | + | ||
41 | + | ||
42 | + | ||
43 | + | ||
44 | + | ||
45 | + | ||
46 | + | ||
47 | + | ||
48 | + | ||
49 | + | ||
50 | + | ||
51 | + | ||
52 | + | ||
53 | + |