生成augmentation table

根据augmentation的需求,如augmentation多少个,使用什么样的augmentation等等,生成一个augmentation Table,以供后续使用。

‘’’Write the table of augmentation ID

Author: Kong Haiyang
‘’’
import csv
import numpy as np

filename = ‘/home/kong/400G/augTable.csv’

with open(filename, ‘wb’) as f:
zoom = np.linspace(-0.1, 0.1, 7)
rotate = np.linspace(-20, 20, 7)
moveud = np.linspace(-1, 1, 3)
movelr = np.linspace(-1, 1, 3)
csvwriter = csv.writer(f, delimiter=’,’)
line = []
line.append(‘augID’)
line.append(‘zoomID’)
line.append(‘rotateID’)
line.append(‘moveUDID’)
line.append(‘moveLRID’)
csvwriter.writerow(line)
line[0] = 0
line[1] = 0
line[2] = 0
line[3] = 0
line[4] = 0
csvwriter.writerow(line)
countAug = 1
for i in range(7):
for j in range(7):
for k in range(3):
for l in range(3):
if not(zoom[i] or rotate[j] or moveud[k] or movelr[l]):
continue
line[0] = countAug
line[1] = zoom[i]
line[2] = rotate[j]
line[3] = moveud[k]
line[4] = movelr[l]
csvwriter.writerow(line)
countAug += 1
if countAug == 408:
break
if countAug == 408:
break
if countAug == 408:
break
if countAug == 408:
break