remove redundant parentheses

This commit is contained in:
cneud 2025-10-01 00:38:01 +02:00
parent f2f93e0251
commit 91d2a74ac9
10 changed files with 29 additions and 29 deletions

View file

@ -173,7 +173,7 @@ class sbb_predict:
##if self.weights_dir!=None:
##self.model.load_weights(self.weights_dir)
if (self.task != 'classification' and self.task != 'reading_order'):
if self.task != 'classification' and self.task != 'reading_order':
self.img_height=self.model.layers[len(self.model.layers)-1].output_shape[1]
self.img_width=self.model.layers[len(self.model.layers)-1].output_shape[2]
self.n_classes=self.model.layers[len(self.model.layers)-1].output_shape[3]
@ -560,7 +560,7 @@ class sbb_predict:
if self.image:
res=self.predict(image_dir = self.image)
if (self.task == 'classification' or self.task == 'reading_order'):
if self.task == 'classification' or self.task == 'reading_order':
pass
elif self.task == 'enhancement':
if self.save:
@ -583,7 +583,7 @@ class sbb_predict:
image_dir = os.path.join(self.dir_in, ind_image)
res=self.predict(image_dir)
if (self.task == 'classification' or self.task == 'reading_order'):
if self.task == 'classification' or self.task == 'reading_order':
pass
elif self.task == 'enhancement':
self.save = os.path.join(self.out, f_name+'.png')
@ -664,7 +664,7 @@ def main(image, dir_in, model, patches, save, save_layout, ground_truth, xml_fil
with open(os.path.join(model,'config.json')) as f:
config_params_model = json.load(f)
task = config_params_model['task']
if (task != 'classification' and task != 'reading_order'):
if task != 'classification' and task != 'reading_order':
if image and not save:
print("Error: You used one of segmentation or binarization task with image input but not set -s, you need a filename to save visualized output with -s")
sys.exit(1)

View file

@ -269,10 +269,10 @@ def run(_config, n_classes, n_epochs, input_height,
num_patches = num_patches_x * num_patches_y
if transformer_cnn_first:
if (input_height != (num_patches_y * transformer_patchsize_y * 32) ):
if input_height != (num_patches_y * transformer_patchsize_y * 32):
print("Error: transformer_patchsize_y or transformer_num_patches_xy height value error . input_height should be equal to ( transformer_num_patches_xy height value * transformer_patchsize_y * 32)")
sys.exit(1)
if (input_width != (num_patches_x * transformer_patchsize_x * 32) ):
if input_width != (num_patches_x * transformer_patchsize_x * 32):
print("Error: transformer_patchsize_x or transformer_num_patches_xy width value error . input_width should be equal to ( transformer_num_patches_xy width value * transformer_patchsize_x * 32)")
sys.exit(1)
if (transformer_projection_dim % (transformer_patchsize_y * transformer_patchsize_x)) != 0:
@ -282,10 +282,10 @@ def run(_config, n_classes, n_epochs, input_height,
model = vit_resnet50_unet(n_classes, transformer_patchsize_x, transformer_patchsize_y, num_patches, transformer_mlp_head_units, transformer_layers, transformer_num_heads, transformer_projection_dim, input_height, input_width, task, weight_decay, pretraining)
else:
if (input_height != (num_patches_y * transformer_patchsize_y) ):
if input_height != (num_patches_y * transformer_patchsize_y):
print("Error: transformer_patchsize_y or transformer_num_patches_xy height value error . input_height should be equal to ( transformer_num_patches_xy height value * transformer_patchsize_y)")
sys.exit(1)
if (input_width != (num_patches_x * transformer_patchsize_x) ):
if input_width != (num_patches_x * transformer_patchsize_x):
print("Error: transformer_patchsize_x or transformer_num_patches_xy width value error . input_width should be equal to ( transformer_num_patches_xy width value * transformer_patchsize_x)")
sys.exit(1)
if (transformer_projection_dim % (transformer_patchsize_y * transformer_patchsize_x)) != 0:
@ -297,7 +297,7 @@ def run(_config, n_classes, n_epochs, input_height,
model.summary()
if (task == "segmentation" or task == "binarization"):
if task == "segmentation" or task == "binarization":
if not is_loss_soft_dice and not weighted_loss:
model.compile(loss='categorical_crossentropy',
optimizer=Adam(learning_rate=learning_rate), metrics=['accuracy'])

View file

@ -260,7 +260,7 @@ def generate_data_from_folder_training(path_classes, batchsize, height, width, n
if batchcount>=batchsize:
ret_x = ret_x/255.
yield (ret_x, ret_y)
yield ret_x, ret_y
ret_x= np.zeros((batchsize, height,width, 3)).astype(np.int16)
ret_y= np.zeros((batchsize, n_classes)).astype(np.int16)
batchcount = 0
@ -446,7 +446,7 @@ def generate_arrays_from_folder_reading_order(classes_file_dir, modal_dir, batch
ret_y[batchcount, :] = label_class
batchcount+=1
if batchcount>=batchsize:
yield (ret_x, ret_y)
yield ret_x, ret_y
ret_x= np.zeros((batchsize, height, width, 3))#.astype(np.int16)
ret_y= np.zeros((batchsize, n_classes)).astype(np.int16)
batchcount = 0
@ -464,7 +464,7 @@ def generate_arrays_from_folder_reading_order(classes_file_dir, modal_dir, batch
ret_y[batchcount, :] = label_class
batchcount+=1
if batchcount>=batchsize:
yield (ret_x, ret_y)
yield ret_x, ret_y
ret_x= np.zeros((batchsize, height, width, 3))#.astype(np.int16)
ret_y= np.zeros((batchsize, n_classes)).astype(np.int16)
batchcount = 0