mirror of
https://github.com/AntoineHX/smart_augmentation.git
synced 2025-05-04 20:20:46 +02:00
Support taille arbitraire de sets dans Dataugv6
This commit is contained in:
parent
6f9cb2cd68
commit
f8cc38dd6b
4 changed files with 2176 additions and 2155 deletions
|
@ -709,17 +709,38 @@ class Data_augV6(nn.Module): #Optimisation sequentielle
|
||||||
self._fixed_mag = fixed_mag
|
self._fixed_mag = fixed_mag
|
||||||
|
|
||||||
self._TF_set_size=3
|
self._TF_set_size=3
|
||||||
#if self._TF_set_size>self._nb_tf:
|
self._fixed_TF=[0]
|
||||||
# print("Warning : TF sets size higher than number of TF. Reducing set size to %d"%self._nb_tf)
|
assert self._TF_set_size>=len(self._fixed_TF)
|
||||||
# self._TF_set_size=self._nb_tf
|
|
||||||
assert self._nb_tf>=self._TF_set_size
|
if self._TF_set_size>self._nb_tf:
|
||||||
self._TF_sets=[]
|
print("Warning : TF sets size higher than number of TF. Reducing set size to %d"%self._nb_tf)
|
||||||
for i in range(1,self._nb_tf):
|
self._TF_set_size=self._nb_tf
|
||||||
for j in range(i,self._nb_tf):
|
|
||||||
if i!=j:
|
## Genenerate TF sets ##
|
||||||
self._TF_sets+=[torch.tensor([0, i, j])]
|
if self._TF_set_size==len(self._fixed_TF):
|
||||||
#print(self._TF_sets)
|
print("Warning : using only fixed set of TF : ", self._fixed_TF)
|
||||||
#self._TF_sets=[torch.tensor([0, i, j]) for i in range(1,self._nb_tf)] #All VS Identity
|
self._TF_sets=torch.tensor([self._fixed_TF])
|
||||||
|
else:
|
||||||
|
def generate_TF_sets(n_TF, set_size, idx_prefix=[]):
|
||||||
|
TF_sets=[]
|
||||||
|
print(set_size, idx_prefix)
|
||||||
|
if len(idx_prefix)!=0:
|
||||||
|
if set_size>2:
|
||||||
|
for i in range(idx_prefix[-1]+1, n_TF):
|
||||||
|
TF_sets += generate_TF_sets(n_TF=n_TF, set_size=set_size-1, idx_prefix=idx_prefix+[i])
|
||||||
|
else:
|
||||||
|
#if i not in idx_prefix:
|
||||||
|
TF_sets+=[torch.tensor(idx_prefix+[i]) for i in range(idx_prefix[-1]+1, n_TF)]
|
||||||
|
elif set_size>1:
|
||||||
|
for i in range(0, n_TF):
|
||||||
|
TF_sets += generate_TF_sets(n_TF=n_TF, set_size=set_size, idx_prefix=[i])
|
||||||
|
else:
|
||||||
|
TF_sets+=[torch.tensor([i]) for i in range(0, n_TF)]
|
||||||
|
return TF_sets
|
||||||
|
|
||||||
|
self._TF_sets=generate_TF_sets(self._nb_tf, self._TF_set_size, self._fixed_TF)
|
||||||
|
|
||||||
|
## Plan TF learning schedule ##
|
||||||
self._TF_schedule = [list(range(len(self._TF_sets))) for _ in range(self._N_seqTF)]
|
self._TF_schedule = [list(range(len(self._TF_sets))) for _ in range(self._N_seqTF)]
|
||||||
for n_tf in range(self._N_seqTF) :
|
for n_tf in range(self._N_seqTF) :
|
||||||
TF.random.shuffle(self._TF_schedule[n_tf])
|
TF.random.shuffle(self._TF_schedule[n_tf])
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 268 KiB After Width: | Height: | Size: 282 KiB |
File diff suppressed because it is too large
Load diff
|
@ -10,17 +10,17 @@ tf_names = [
|
||||||
'FlipLR',
|
'FlipLR',
|
||||||
'Rotate',
|
'Rotate',
|
||||||
'TranslateX',
|
'TranslateX',
|
||||||
'TranslateY',
|
#'TranslateY',
|
||||||
'ShearX',
|
#'ShearX',
|
||||||
'ShearY',
|
#'ShearY',
|
||||||
|
|
||||||
## Color TF (Expect image in the range of [0, 1]) ##
|
## Color TF (Expect image in the range of [0, 1]) ##
|
||||||
'Contrast',
|
#'Contrast',
|
||||||
'Color',
|
#'Color',
|
||||||
'Brightness',
|
#'Brightness',
|
||||||
'Sharpness',
|
#'Sharpness',
|
||||||
'Posterize',
|
#'Posterize',
|
||||||
'Solarize', #=>Image entre [0,1] #Pas opti pour des batch
|
#'Solarize', #=>Image entre [0,1] #Pas opti pour des batch
|
||||||
|
|
||||||
#Color TF (Common mag scale)
|
#Color TF (Common mag scale)
|
||||||
#'+Contrast',
|
#'+Contrast',
|
||||||
|
@ -44,10 +44,10 @@ tf_names = [
|
||||||
#'BadTranslateY',
|
#'BadTranslateY',
|
||||||
#'BadTranslateY_neg',
|
#'BadTranslateY_neg',
|
||||||
|
|
||||||
'BadColor',
|
#'BadColor',
|
||||||
'BadSharpness',
|
#'BadSharpness',
|
||||||
'BadContrast',
|
#'BadContrast',
|
||||||
'BadBrightness',
|
#'BadBrightness',
|
||||||
|
|
||||||
#Non fonctionnel
|
#Non fonctionnel
|
||||||
#'Auto_Contrast', #Pas opti pour des batch (Super lent)
|
#'Auto_Contrast', #Pas opti pour des batch (Super lent)
|
||||||
|
@ -91,11 +91,11 @@ if __name__ == "__main__":
|
||||||
print('-'*9)
|
print('-'*9)
|
||||||
'''
|
'''
|
||||||
#### Augmented Model ####
|
#### Augmented Model ####
|
||||||
'''
|
#'''
|
||||||
t0 = time.process_time()
|
t0 = time.process_time()
|
||||||
tf_dict = {k: TF.TF_dict[k] for k in tf_names}
|
tf_dict = {k: TF.TF_dict[k] for k in tf_names}
|
||||||
#tf_dict = TF.TF_dict
|
#tf_dict = TF.TF_dict
|
||||||
aug_model = Augmented_model(Data_augV6(TF_dict=tf_dict, N_TF=3, mix_dist=0.0, fixed_prob=False, fixed_mag=True, shared_mag=True), LeNet(3,10)).to(device)
|
aug_model = Augmented_model(Data_augV6(TF_dict=tf_dict, N_TF=1, mix_dist=0.0, fixed_prob=False, fixed_mag=True, shared_mag=True), LeNet(3,10)).to(device)
|
||||||
#aug_model = Augmented_model(Data_augV5(TF_dict=tf_dict, N_TF=2, mix_dist=0.5, fixed_mag=True, shared_mag=True), WideResNet(num_classes=10, wrn_size=160)).to(device)
|
#aug_model = Augmented_model(Data_augV5(TF_dict=tf_dict, N_TF=2, mix_dist=0.5, fixed_mag=True, shared_mag=True), WideResNet(num_classes=10, wrn_size=160)).to(device)
|
||||||
#aug_model = Augmented_model(RandAug(TF_dict=tf_dict, N_TF=2), LeNet(3,10)).to(device)
|
#aug_model = Augmented_model(RandAug(TF_dict=tf_dict, N_TF=2), LeNet(3,10)).to(device)
|
||||||
print(str(aug_model), 'on', device_name)
|
print(str(aug_model), 'on', device_name)
|
||||||
|
@ -116,9 +116,9 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
print('Execution Time : %.00f '%(time.process_time() - t0))
|
print('Execution Time : %.00f '%(time.process_time() - t0))
|
||||||
print('-'*9)
|
print('-'*9)
|
||||||
'''
|
|
||||||
#### TF tests ####
|
|
||||||
#'''
|
#'''
|
||||||
|
#### TF tests ####
|
||||||
|
'''
|
||||||
res_folder="res/brutus-tests/"
|
res_folder="res/brutus-tests/"
|
||||||
epochs= 150
|
epochs= 150
|
||||||
inner_its = [1]
|
inner_its = [1]
|
||||||
|
@ -168,4 +168,4 @@ if __name__ == "__main__":
|
||||||
#plot_resV2(log, fig_name=res_folder+filename, param_names=tf_names)
|
#plot_resV2(log, fig_name=res_folder+filename, param_names=tf_names)
|
||||||
print('-'*9)
|
print('-'*9)
|
||||||
|
|
||||||
#'''
|
'''
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue