Commit ab7eebc7 authored by Jonas Müller's avatar Jonas Müller

check folds for issues

based on time between the creation of the pictures
parent 1c2af4ff
from datetime import datetime
def get_date2(filename):
if filename.startswith('IMG'):
filename = filename[4:]
#return filename[:8] # only dates
if filename == '20190508-WA0026.jpg':
filename = '20190508_123000.jpg'
return filename[:13]
def get_date(filename):
return get_date2(filename)[:-2]
#20190520_120309
def time_diff(date1, date2):
date1 = get_date2(date1)
date2 = get_date2(date2)
d1 = datetime.strptime(date1, '%Y%m%d_%H%M')
d2 = datetime.strptime(date2, '%Y%m%d_%H%M')
tmp = None
if d1 < d2:
tmp = d1
d1 = d2
d2 = tmp
duration = d1 - d2 # For build-in functions
duration_in_s = duration.total_seconds()
return duration_in_s, d1, d2
#if duration_in_s < 600:
# print(duration_in_s)
# print()
num_folds = 5
min_time_diff = 3 * 60 # N minutes --> in seconds
output_path = 'data/cross_validate/'
# Create empty lists for each fold as sublist of folds
folds = []
for i in range(num_folds):
folds.append([])
for i in range(num_folds):
new_dir = output_path + 'fold_' + str(i)
with open(new_dir+'/annotations_test.txt', 'r') as file:
lines = file.readlines()
for line in lines:
filename = line.split(',')[0]
folds[i].append(filename)
for fold in folds:
fold.sort()
print('len', len(fold))
print(fold)
for i in range(len(folds)):
for j in range(i, len(folds)):
if i == j:
continue
min_difference = 60*60*24 # one day in seconds
old = min_difference
element1 = ''
element2 = ''
time1 = ''
time2 = ''
print('Fold', str(i), 'and Fold', str(j))
for elem1 in folds[i]:
for elem2 in folds[j]:
diff, d1, d2 = time_diff(elem1, elem2)
if diff < min_time_diff:
print(str(diff / 60) + " min Zeitdifferenz")
print(str(d1) + " - " + str(d2))
print(elem1 + " - " + elem2)
print()
print()
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment