-
Notifications
You must be signed in to change notification settings - Fork 2
/
utils.py
33 lines (30 loc) · 1.01 KB
/
utils.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
# Copyright 2020 by He Peng (sdythp@gmail.com).
# All rights reserved.
# Licensed under the MIT License.
from collections import defaultdict
import os
def parse_file_info(file_info_path):
"""
:param file_info_path: file info path
:return: dict:
all: all the images
offshore: the offshore images
inshore: the inshore images
3: 3m sar resolution
1: 1m sar resolution
"""
assert os.path.exists(file_info_path), "File info not exists"
with open(file_info_path, 'r', encoding='utf-8') as f:
# Skip first comment line
ret = defaultdict(list)
for line in f:
if line.startswith('#'):
continue
fileinfo = line.strip().split(' ')
filename = fileinfo[0]
shore = fileinfo[3]
resolution = fileinfo[4]
ret['all'].append(filename)
ret[shore].append(filename)
ret[resolution].append(filename)
return ret