-
Notifications
You must be signed in to change notification settings - Fork 0
/
explore.py
69 lines (61 loc) · 2.59 KB
/
explore.py
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
import os
import glob
import numpy as np
import pandas as pd
from tqdm import tqdm
from config import TRAIN_RAW, BAND_META_DATA
from utils import read_npy_file
if __name__ == '__main__':
if not os.path.exists(BAND_META_DATA):
records = []
bands = []
min = []
max = []
for record_id in tqdm(os.listdir(TRAIN_RAW)):
if record_id != '905857553501724345':
for band in glob.glob(os.path.join(TRAIN_RAW, record_id, 'band_*.npy')):
data = read_npy_file(band)
band_id = (band.split('/')[-1]).split('.')[0]
records.append(record_id)
bands.append(band_id)
min.append(np.min(data))
max.append(np.max(data))
df = pd.DataFrame({'record_id': records, 'band': bands, 'min': min, 'max': max}, index=None)
df.to_csv(BAND_META_DATA)
# record_id = os.listdir(TRAIN_RAW)[0]
# directory = os.path.join(TRAIN_RAW, record_id)
#
# print('Record ID: {}'.format(record_id))
#
# with open(os.path.join(directory, 'band_08.npy'), 'rb') as f:
# band8 = np.load(f)
# with open(os.path.join(directory, 'band_09.npy'), 'rb') as f:
# band9 = np.load(f)
# with open(os.path.join(directory, 'band_10.npy'), 'rb') as f:
# band10 = np.load(f)
# with open(os.path.join(directory, 'band_11.npy'), 'rb') as f:
# band11 = np.load(f)
# with open(os.path.join(directory, 'band_12.npy'), 'rb') as f:
# band12 = np.load(f)
# with open(os.path.join(directory, 'band_13.npy'), 'rb') as f:
# band13 = np.load(f)
# with open(os.path.join(directory, 'band_14.npy'), 'rb') as f:
# band14 = np.load(f)
# with open(os.path.join(directory, 'band_15.npy'), 'rb') as f:
# band15 = np.load(f)
# with open(os.path.join(directory, 'band_16.npy'), 'rb') as f:
# band16 = np.load(f)
# with open(os.path.join(directory, 'human_pixel_masks.npy'), 'rb') as f:
# human_pixel_mask = np.load(f)
# with open(os.path.join(directory, 'human_individual_masks.npy'), 'rb') as f:
# human_individual_mask = np.load(f)
#
# print('Band 8: {}'.format(band8.dtype))
# print('Band 9: {}'.format(band9.dtype))
# print('Band 10: {}'.format(band10.dtype))
# print('Band 11: {}'.format(band11.dtype))
# print('Band 12: {}'.format(band12.dtype))
# print('Band 13: {}'.format(band13.dtype))
# print('Band 14: {}'.format(band14.dtype))
# print('Band 15: {}'.format(band15.dtype))
# print('Band 16: {}'.format(band16.dtype))