update common pre-commit configs and commit the results of running pre-commit run -a (#12516)

This commit is contained in:
jzhang533 2024-05-29 15:26:09 +08:00 committed by GitHub
parent 6e7a1b871d
commit 24f06d1a1b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
348 changed files with 2971 additions and 2965 deletions

View File

@ -1,26 +1,22 @@
repos: repos:
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: a11d9314b22d8f8c7556443875b731ef05965464 rev: v4.6.0
hooks: hooks:
- id: check-added-large-files
args: ['--maxkb=512']
- id: check-case-conflict
- id: check-merge-conflict - id: check-merge-conflict
- id: check-symlinks - id: check-symlinks
- id: detect-private-key - id: detect-private-key
files: (?!.*paddle)^.*$
- id: end-of-file-fixer - id: end-of-file-fixer
files: \.md$
- id: trailing-whitespace - id: trailing-whitespace
files: \.md$ files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|py|md)$
- repo: https://github.com/Lucas-C/pre-commit-hooks - repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.0.1 rev: v1.5.1
hooks: hooks:
- id: forbid-crlf
files: \.md$
- id: remove-crlf - id: remove-crlf
files: \.md$
- id: forbid-tabs
files: \.md$
- id: remove-tabs - id: remove-tabs
files: \.md$ files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|py|md)$
- repo: local - repo: local
hooks: hooks:
- id: clang-format - id: clang-format
@ -31,7 +27,7 @@ repos:
files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|cuh|proto)$ files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|cuh|proto)$
# For Python files # For Python files
- repo: https://github.com/psf/black.git - repo: https://github.com/psf/black.git
rev: 23.3.0 rev: 24.4.2
hooks: hooks:
- id: black - id: black
files: (.*\.(py|pyi|bzl)|BUILD|.*\.BUILD|WORKSPACE)$ files: (.*\.(py|pyi|bzl)|BUILD|.*\.BUILD|WORKSPACE)$
@ -47,4 +43,3 @@ repos:
- --show-source - --show-source
- --statistics - --statistics
exclude: ^benchmark/|^test_tipc/ exclude: ^benchmark/|^test_tipc/

View File

@ -194,7 +194,9 @@ class InferenceEngine(object):
box_list = [box_list[i] for i, v in enumerate(idx) if v] box_list = [box_list[i] for i, v in enumerate(idx) if v]
score_list = [score_list[i] for i, v in enumerate(idx) if v] score_list = [score_list[i] for i, v in enumerate(idx) if v]
else: else:
idx = box_list.reshape(box_list.shape[0], -1).sum(axis=1) > 0 # 去掉全为0的框 idx = (
box_list.reshape(box_list.shape[0], -1).sum(axis=1) > 0
) # 去掉全为0的框
box_list, score_list = box_list[idx], score_list[idx] box_list, score_list = box_list[idx], score_list[idx]
else: else:
box_list, score_list = [], [] box_list, score_list = [], []

View File

@ -59,4 +59,3 @@ source ${BENCHMARK_ROOT}/scripts/run_model.sh # 在该脚本中会对符合
_set_params $@ _set_params $@
#_train # 如果只想产出训练log,不解析,可取消注释 #_train # 如果只想产出训练log,不解析,可取消注释
_run # 该函数在run_model.sh中,执行时会调用_train; 如果不联调只想要产出训练log可以注掉本行,提交时需打开 _run # 该函数在run_model.sh中,执行时会调用_train; 如果不联调只想要产出训练log可以注掉本行,提交时需打开

View File

@ -34,6 +34,3 @@ for model_mode in ${model_mode_list[@]}; do
done done
done done
done done

View File

@ -173,5 +173,3 @@ Eval:
drop_last: False drop_last: False
batch_size_per_card: 8 batch_size_per_card: 8
num_workers: 8 num_workers: 8

View File

@ -198,9 +198,9 @@ class ArgsParser(ArgumentParser):
lang = "cyrillic" lang = "cyrillic"
elif lang in devanagari_lang: elif lang in devanagari_lang:
lang = "devanagari" lang = "devanagari"
global_config["Global"][ global_config["Global"]["character_dict_path"] = (
"character_dict_path" "ppocr/utils/dict/{}_dict.txt".format(lang)
] = "ppocr/utils/dict/{}_dict.txt".format(lang) )
global_config["Global"]["save_model_dir"] = "./output/rec_{}_lite".format(lang) global_config["Global"]["save_model_dir"] = "./output/rec_{}_lite".format(lang)
global_config["Train"]["dataset"]["label_file_list"] = [ global_config["Train"]["dataset"]["label_file_list"] = [
"train_data/{}_train.txt".format(lang) "train_data/{}_train.txt".format(lang)

View File

@ -114,4 +114,3 @@ Eval:
batch_size_per_card: 128 batch_size_per_card: 128
num_workers: 4 num_workers: 4
use_shared_memory: False use_shared_memory: False

View File

@ -81,4 +81,3 @@ Eval:
drop_last: False drop_last: False
batch_size_per_card: 16 batch_size_per_card: 16
num_workers: 4 num_workers: 4

View File

@ -82,4 +82,3 @@ Eval:
drop_last: False drop_last: False
batch_size_per_card: 16 batch_size_per_card: 16
num_workers: 4 num_workers: 4

View File

@ -6,4 +6,3 @@
/build /build
/captures /captures
.externalNativeBuild .externalNativeBuild

View File

@ -17,4 +17,3 @@
<string name="DET_LONG_SIZE_DEFAULT">960</string> <string name="DET_LONG_SIZE_DEFAULT">960</string>
<string name="SCORE_THRESHOLD_DEFAULT">0.1</string> <string name="SCORE_THRESHOLD_DEFAULT">0.1</string>
</resources> </resources>

View File

@ -11,4 +11,3 @@ FetchContent_Declare(
GIT_TAG main GIT_TAG main
) )
FetchContent_MakeAvailable(extern_Autolog) FetchContent_MakeAvailable(extern_Autolog)

View File

@ -3,4 +3,3 @@
<item android:state_pressed="true" android:drawable="@drawable/btn_settings_pressed"/> <item android:state_pressed="true" android:drawable="@drawable/btn_settings_pressed"/>
<item android:drawable="@drawable/btn_settings_default"/> <item android:drawable="@drawable/btn_settings_default"/>
</selector> </selector>

View File

@ -13,4 +13,3 @@
"use_multiprocess": false, "use_multiprocess": false,
"workers": 2 "workers": 2
} }

View File

@ -13,4 +13,3 @@
"use_multiprocess": false, "use_multiprocess": false,
"workers": 2 "workers": 2
} }

View File

@ -13,4 +13,3 @@
"use_multiprocess": false, "use_multiprocess": false,
"workers": 2 "workers": 2
} }

View File

@ -13,4 +13,3 @@
"use_multiprocess": false, "use_multiprocess": false,
"workers": 2 "workers": 2
} }

View File

@ -13,4 +13,3 @@
"use_multiprocess": false, "use_multiprocess": false,
"workers": 2 "workers": 2
} }

View File

@ -13,4 +13,3 @@
"use_multiprocess": false, "use_multiprocess": false,
"workers": 2 "workers": 2
} }

View File

@ -439,9 +439,9 @@ class DRRGTargets(object):
) )
inner_center_sample_mask = np.zeros_like(center_sample_mask) inner_center_sample_mask = np.zeros_like(center_sample_mask)
inner_center_sample_mask[ inner_center_sample_mask[margin : h - margin, margin : w - margin] = (
margin : h - margin, margin : w - margin center_sample_mask[margin : h - margin, margin : w - margin]
] = center_sample_mask[margin : h - margin, margin : w - margin] )
kernel_size = int(np.clip(max_rand_half_height, 7, 21)) kernel_size = int(np.clip(max_rand_half_height, 7, 21))
inner_center_sample_mask = cv2.erode( inner_center_sample_mask = cv2.erode(
inner_center_sample_mask, np.ones((kernel_size, kernel_size), np.uint8) inner_center_sample_mask, np.ones((kernel_size, kernel_size), np.uint8)

View File

@ -48,10 +48,14 @@ class GenTableMask(object):
in_text = False # 是否遍历到了字符区内 in_text = False # 是否遍历到了字符区内
box_list = [] box_list = []
for i in range(len(project_val_array)): for i in range(len(project_val_array)):
if in_text == False and project_val_array[i] > spilt_threshold: # 进入字符区了 if (
in_text == False and project_val_array[i] > spilt_threshold
): # 进入字符区了
in_text = True in_text = True
start_idx = i start_idx = i
elif project_val_array[i] <= spilt_threshold and in_text == True: # 进入空白区了 elif (
project_val_array[i] <= spilt_threshold and in_text == True
): # 进入空白区了
end_idx = i end_idx = i
in_text = False in_text = False
if end_idx - start_idx <= 2: if end_idx - start_idx <= 2:
@ -95,10 +99,14 @@ class GenTableMask(object):
box_list = [] box_list = []
spilt_threshold = 0 spilt_threshold = 0
for i in range(len(project_val_array)): for i in range(len(project_val_array)):
if in_text == False and project_val_array[i] > spilt_threshold: # 进入字符区了 if (
in_text == False and project_val_array[i] > spilt_threshold
): # 进入字符区了
in_text = True in_text = True
start_idx = i start_idx = i
elif project_val_array[i] <= spilt_threshold and in_text == True: # 进入空白区了 elif (
project_val_array[i] <= spilt_threshold and in_text == True
): # 进入空白区了
end_idx = i end_idx = i
in_text = False in_text = False
if end_idx - start_idx <= 2: if end_idx - start_idx <= 2:

View File

@ -231,9 +231,7 @@ class DKDLoss(nn.Layer):
pred_student = self._cat_mask(pred_student, gt_mask, other_mask) pred_student = self._cat_mask(pred_student, gt_mask, other_mask)
pred_teacher = self._cat_mask(pred_teacher, gt_mask, other_mask) pred_teacher = self._cat_mask(pred_teacher, gt_mask, other_mask)
log_pred_student = paddle.log(pred_student) log_pred_student = paddle.log(pred_student)
tckd_loss = self._kl_div(log_pred_student, pred_teacher) * ( tckd_loss = self._kl_div(log_pred_student, pred_teacher) * (self.temperature**2)
self.temperature**2
)
pred_teacher_part2 = F.softmax( pred_teacher_part2 = F.softmax(
logits_teacher / self.temperature - 1000.0 * gt_mask, axis=1 logits_teacher / self.temperature - 1000.0 * gt_mask, axis=1
) )

View File

@ -113,9 +113,9 @@ class DistillationDMLLoss(DMLLoss):
loss = super().forward(out1, out2) loss = super().forward(out1, out2)
if isinstance(loss, dict): if isinstance(loss, dict):
for key in loss: for key in loss:
loss_dict[ loss_dict["{}_{}_{}_{}".format(key, pair[0], pair[1], idx)] = (
"{}_{}_{}_{}".format(key, pair[0], pair[1], idx) loss[key]
] = loss[key] )
else: else:
loss_dict["{}_{}".format(self.name, idx)] = loss loss_dict["{}_{}".format(self.name, idx)] = loss
else: else:
@ -218,9 +218,9 @@ class DistillationKLDivLoss(KLDivLoss):
loss = super().forward(out1, out2) loss = super().forward(out1, out2)
if isinstance(loss, dict): if isinstance(loss, dict):
for key in loss: for key in loss:
loss_dict[ loss_dict["{}_{}_{}_{}".format(key, pair[0], pair[1], idx)] = (
"{}_{}_{}_{}".format(key, pair[0], pair[1], idx) loss[key]
] = loss[key] )
else: else:
loss_dict["{}_{}".format(self.name, idx)] = loss loss_dict["{}_{}".format(self.name, idx)] = loss
else: else:
@ -329,9 +329,9 @@ class DistillationDKDLoss(DKDLoss):
loss = super().forward(out1, out2) loss = super().forward(out1, out2)
if isinstance(loss, dict): if isinstance(loss, dict):
for key in loss: for key in loss:
loss_dict[ loss_dict["{}_{}_{}_{}".format(key, pair[0], pair[1], idx)] = (
"{}_{}_{}_{}".format(key, pair[0], pair[1], idx) loss[key]
] = loss[key] )
else: else:
loss_dict["{}_{}".format(self.name, idx)] = loss loss_dict["{}_{}".format(self.name, idx)] = loss
else: else:
@ -472,9 +472,9 @@ class DistillationKLDivLoss(KLDivLoss):
loss = super().forward(out1, out2) loss = super().forward(out1, out2)
if isinstance(loss, dict): if isinstance(loss, dict):
for key in loss: for key in loss:
loss_dict[ loss_dict["{}_{}_{}_{}".format(key, pair[0], pair[1], idx)] = (
"{}_{}_{}_{}".format(key, pair[0], pair[1], idx) loss[key]
] = loss[key] )
else: else:
loss_dict["{}_{}".format(self.name, idx)] = loss loss_dict["{}_{}".format(self.name, idx)] = loss
else: else:
@ -583,9 +583,9 @@ class DistillationDKDLoss(DKDLoss):
loss = super().forward(out1, out2) loss = super().forward(out1, out2)
if isinstance(loss, dict): if isinstance(loss, dict):
for key in loss: for key in loss:
loss_dict[ loss_dict["{}_{}_{}_{}".format(key, pair[0], pair[1], idx)] = (
"{}_{}_{}_{}".format(key, pair[0], pair[1], idx) loss[key]
] = loss[key] )
else: else:
loss_dict["{}_{}".format(self.name, idx)] = loss loss_dict["{}_{}".format(self.name, idx)] = loss
else: else:

View File

@ -185,9 +185,11 @@ class ResNet(nn.Layer):
bottleneck_block = self.add_sublayer( bottleneck_block = self.add_sublayer(
conv_name, conv_name,
BottleneckBlock( BottleneckBlock(
num_channels=num_channels[block] num_channels=(
num_channels[block]
if i == 0 if i == 0
else num_filters[block] * 4, else num_filters[block] * 4
),
num_filters=num_filters[block], num_filters=num_filters[block],
stride=2 if i == 0 and block != 0 else 1, stride=2 if i == 0 and block != 0 else 1,
shortcut=shortcut, shortcut=shortcut,
@ -208,9 +210,9 @@ class ResNet(nn.Layer):
basic_block = self.add_sublayer( basic_block = self.add_sublayer(
conv_name, conv_name,
BasicBlock( BasicBlock(
num_channels=num_channels[block] num_channels=(
if i == 0 num_channels[block] if i == 0 else num_filters[block]
else num_filters[block], ),
num_filters=num_filters[block], num_filters=num_filters[block],
stride=2 if i == 0 and block != 0 else 1, stride=2 if i == 0 and block != 0 else 1,
shortcut=shortcut, shortcut=shortcut,

View File

@ -316,9 +316,11 @@ class ResNet_vd(nn.Layer):
bottleneck_block = self.add_sublayer( bottleneck_block = self.add_sublayer(
"bb_%d_%d" % (block, i), "bb_%d_%d" % (block, i),
BottleneckBlock( BottleneckBlock(
in_channels=num_channels[block] in_channels=(
num_channels[block]
if i == 0 if i == 0
else num_filters[block] * 4, else num_filters[block] * 4
),
out_channels=num_filters[block], out_channels=num_filters[block],
stride=2 if i == 0 and block != 0 else 1, stride=2 if i == 0 and block != 0 else 1,
shortcut=shortcut, shortcut=shortcut,
@ -339,9 +341,9 @@ class ResNet_vd(nn.Layer):
basic_block = self.add_sublayer( basic_block = self.add_sublayer(
"bb_%d_%d" % (block, i), "bb_%d_%d" % (block, i),
BasicBlock( BasicBlock(
in_channels=num_channels[block] in_channels=(
if i == 0 num_channels[block] if i == 0 else num_filters[block]
else num_filters[block], ),
out_channels=num_filters[block], out_channels=num_filters[block],
stride=2 if i == 0 and block != 0 else 1, stride=2 if i == 0 and block != 0 else 1,
shortcut=shortcut, shortcut=shortcut,

View File

@ -261,9 +261,11 @@ class ResNet_SAST(nn.Layer):
bottleneck_block = self.add_sublayer( bottleneck_block = self.add_sublayer(
"bb_%d_%d" % (block, i), "bb_%d_%d" % (block, i),
BottleneckBlock( BottleneckBlock(
in_channels=num_channels[block] in_channels=(
num_channels[block]
if i == 0 if i == 0
else num_filters[block] * 4, else num_filters[block] * 4
),
out_channels=num_filters[block], out_channels=num_filters[block],
stride=2 if i == 0 and block != 0 else 1, stride=2 if i == 0 and block != 0 else 1,
shortcut=shortcut, shortcut=shortcut,
@ -284,9 +286,9 @@ class ResNet_SAST(nn.Layer):
basic_block = self.add_sublayer( basic_block = self.add_sublayer(
"bb_%d_%d" % (block, i), "bb_%d_%d" % (block, i),
BasicBlock( BasicBlock(
in_channels=num_channels[block] in_channels=(
if i == 0 num_channels[block] if i == 0 else num_filters[block]
else num_filters[block], ),
out_channels=num_filters[block], out_channels=num_filters[block],
stride=2 if i == 0 and block != 0 else 1, stride=2 if i == 0 and block != 0 else 1,
shortcut=shortcut, shortcut=shortcut,

View File

@ -241,9 +241,11 @@ class ResNet(nn.Layer):
bottleneck_block = self.add_sublayer( bottleneck_block = self.add_sublayer(
"bb_%d_%d" % (block, i), "bb_%d_%d" % (block, i),
BottleneckBlock( BottleneckBlock(
in_channels=num_channels[block] in_channels=(
num_channels[block]
if i == 0 if i == 0
else num_filters[block] * 4, else num_filters[block] * 4
),
out_channels=num_filters[block], out_channels=num_filters[block],
stride=2 if i == 0 and block != 0 else 1, stride=2 if i == 0 and block != 0 else 1,
shortcut=shortcut, shortcut=shortcut,
@ -264,9 +266,9 @@ class ResNet(nn.Layer):
basic_block = self.add_sublayer( basic_block = self.add_sublayer(
"bb_%d_%d" % (block, i), "bb_%d_%d" % (block, i),
BasicBlock( BasicBlock(
in_channels=num_channels[block] in_channels=(
if i == 0 num_channels[block] if i == 0 else num_filters[block]
else num_filters[block], ),
out_channels=num_filters[block], out_channels=num_filters[block],
stride=2 if i == 0 and block != 0 else 1, stride=2 if i == 0 and block != 0 else 1,
shortcut=shortcut, shortcut=shortcut,

View File

@ -364,6 +364,7 @@ class DYMicroBlock(nn.Layer):
if gs1[0] == 0: if gs1[0] == 0:
self.layers = nn.Sequential( self.layers = nn.Sequential(
DepthSpatialSepConv(inp, t1, kernel_size, stride), DepthSpatialSepConv(inp, t1, kernel_size, stride),
(
DYShiftMax( DYShiftMax(
hidden_dim2, hidden_dim2,
hidden_dim2, hidden_dim2,
@ -376,12 +377,16 @@ class DYMicroBlock(nn.Layer):
expansion=False, expansion=False,
) )
if y2 > 0 if y2 > 0
else nn.ReLU6(), else nn.ReLU6()
),
ChannelShuffle(gs1[1]) if shuffle else nn.Sequential(), ChannelShuffle(gs1[1]) if shuffle else nn.Sequential(),
(
ChannelShuffle(hidden_dim2 // 2) ChannelShuffle(hidden_dim2 // 2)
if shuffle and y2 != 0 if shuffle and y2 != 0
else nn.Sequential(), else nn.Sequential()
),
GroupConv(hidden_dim2, oup, (g1, g2)), GroupConv(hidden_dim2, oup, (g1, g2)),
(
DYShiftMax( DYShiftMax(
oup, oup,
oup, oup,
@ -394,15 +399,19 @@ class DYMicroBlock(nn.Layer):
expansion=False, expansion=False,
) )
if y3 > 0 if y3 > 0
else nn.Sequential(), else nn.Sequential()
),
ChannelShuffle(g2) if shuffle else nn.Sequential(), ChannelShuffle(g2) if shuffle else nn.Sequential(),
(
ChannelShuffle(oup // 2) ChannelShuffle(oup // 2)
if shuffle and oup % 2 == 0 and y3 != 0 if shuffle and oup % 2 == 0 and y3 != 0
else nn.Sequential(), else nn.Sequential()
),
) )
elif g2 == 0: elif g2 == 0:
self.layers = nn.Sequential( self.layers = nn.Sequential(
GroupConv(inp, hidden_dim2, gs1), GroupConv(inp, hidden_dim2, gs1),
(
DYShiftMax( DYShiftMax(
hidden_dim2, hidden_dim2,
hidden_dim2, hidden_dim2,
@ -415,11 +424,13 @@ class DYMicroBlock(nn.Layer):
expansion=False, expansion=False,
) )
if y3 > 0 if y3 > 0
else nn.Sequential(), else nn.Sequential()
),
) )
else: else:
self.layers = nn.Sequential( self.layers = nn.Sequential(
GroupConv(inp, hidden_dim2, gs1), GroupConv(inp, hidden_dim2, gs1),
(
DYShiftMax( DYShiftMax(
hidden_dim2, hidden_dim2,
hidden_dim2, hidden_dim2,
@ -432,12 +443,16 @@ class DYMicroBlock(nn.Layer):
expansion=False, expansion=False,
) )
if y1 > 0 if y1 > 0
else nn.ReLU6(), else nn.ReLU6()
),
ChannelShuffle(gs1[1]) if shuffle else nn.Sequential(), ChannelShuffle(gs1[1]) if shuffle else nn.Sequential(),
(
DepthSpatialSepConv(hidden_dim2, (1, 1), kernel_size, stride) DepthSpatialSepConv(hidden_dim2, (1, 1), kernel_size, stride)
if depthsep if depthsep
else DepthConv(hidden_dim2, hidden_dim2, kernel_size, stride), else DepthConv(hidden_dim2, hidden_dim2, kernel_size, stride)
),
nn.Sequential(), nn.Sequential(),
(
DYShiftMax( DYShiftMax(
hidden_dim2, hidden_dim2,
hidden_dim2, hidden_dim2,
@ -450,28 +465,35 @@ class DYMicroBlock(nn.Layer):
expansion=True, expansion=True,
) )
if y2 > 0 if y2 > 0
else nn.ReLU6(), else nn.ReLU6()
),
(
ChannelShuffle(hidden_dim2 // 4) ChannelShuffle(hidden_dim2 // 4)
if shuffle and y1 != 0 and y2 != 0 if shuffle and y1 != 0 and y2 != 0
else nn.Sequential() else (
nn.Sequential()
if y1 == 0 and y2 == 0 if y1 == 0 and y2 == 0
else ChannelShuffle(hidden_dim2 // 2), else ChannelShuffle(hidden_dim2 // 2)
)
),
GroupConv(hidden_dim2, oup, (g1, g2)), GroupConv(hidden_dim2, oup, (g1, g2)),
(
DYShiftMax( DYShiftMax(
oup, oup,
oup, oup,
act_max=2.0, act_max=2.0,
act_relu=False, act_relu=False,
init_a=[1.0, 0.0], init_a=[1.0, 0.0],
reduction=act_reduction // 2 reduction=(
if oup < hidden_dim2 act_reduction // 2 if oup < hidden_dim2 else act_reduction
else act_reduction, ),
init_b=[0.0, 0.0], init_b=[0.0, 0.0],
g=(g1, g2), g=(g1, g2),
expansion=False, expansion=False,
) )
if y3 > 0 if y3 > 0
else nn.Sequential(), else nn.Sequential()
),
ChannelShuffle(g2) if shuffle else nn.Sequential(), ChannelShuffle(g2) if shuffle else nn.Sequential(),
ChannelShuffle(oup // 2) if shuffle and y3 != 0 else nn.Sequential(), ChannelShuffle(oup // 2) if shuffle and y3 != 0 else nn.Sequential(),
) )

View File

@ -35,9 +35,7 @@ class MTB(nn.Layer):
), ),
) )
self.block.add_sublayer("relu_{}".format(i), nn.ReLU()) self.block.add_sublayer("relu_{}".format(i), nn.ReLU())
self.block.add_sublayer( self.block.add_sublayer("bn_{}".format(i), nn.BatchNorm2D(32 * (2**i)))
"bn_{}".format(i), nn.BatchNorm2D(32 * (2**i))
)
def forward(self, images): def forward(self, images):
x = self.block(images) x = self.block(images)

View File

@ -259,9 +259,11 @@ class ResNet(nn.Layer):
bottleneck_block = self.add_sublayer( bottleneck_block = self.add_sublayer(
"bb_%d_%d" % (block, i), "bb_%d_%d" % (block, i),
BottleneckBlock( BottleneckBlock(
in_channels=num_channels[block] in_channels=(
num_channels[block]
if i == 0 if i == 0
else num_filters[block] * 4, else num_filters[block] * 4
),
out_channels=num_filters[block], out_channels=num_filters[block],
stride=stride, stride=stride,
shortcut=shortcut, shortcut=shortcut,
@ -285,9 +287,9 @@ class ResNet(nn.Layer):
basic_block = self.add_sublayer( basic_block = self.add_sublayer(
"bb_%d_%d" % (block, i), "bb_%d_%d" % (block, i),
BasicBlock( BasicBlock(
in_channels=num_channels[block] in_channels=(
if i == 0 num_channels[block] if i == 0 else num_filters[block]
else num_filters[block], ),
out_channels=num_filters[block], out_channels=num_filters[block],
stride=stride, stride=stride,
shortcut=shortcut, shortcut=shortcut,

View File

@ -141,8 +141,7 @@ class GNNLayer(nn.Layer):
) )
residuals.append( residuals.append(
( (
residual residual * cat_nodes[start : start + num**2].reshape([num, num, -1])
* cat_nodes[start : start + num**2].reshape([num, num, -1])
).sum(1) ).sum(1)
) )
start += num**2 start += num**2

View File

@ -341,10 +341,12 @@ class PrePostProcessLayer(nn.Layer):
) )
elif cmd == "d": # add dropout elif cmd == "d": # add dropout
self.functors.append( self.functors.append(
lambda x: F.dropout(x, p=dropout_rate, mode="downscale_in_infer") lambda x: (
F.dropout(x, p=dropout_rate, mode="downscale_in_infer")
if dropout_rate if dropout_rate
else x else x
) )
)
def forward(self, x, residual=None): def forward(self, x, residual=None):
for i, cmd in enumerate(self.process_cmd): for i, cmd in enumerate(self.process_cmd):

View File

@ -150,7 +150,7 @@ class TBSRN(nn.Layer):
upsample_block_num = int(math.log(scale_factor, 2)) upsample_block_num = int(math.log(scale_factor, 2))
self.block1 = nn.Sequential( self.block1 = nn.Sequential(
nn.Conv2D(in_planes, 2 * hidden_units, kernel_size=9, padding=4), nn.Conv2D(in_planes, 2 * hidden_units, kernel_size=9, padding=4),
nn.PReLU() nn.PReLU(),
# nn.ReLU() # nn.ReLU()
) )
self.srb_nums = srb_nums self.srb_nums = srb_nums

View File

@ -1133,9 +1133,11 @@ class VLLabelDecode(BaseRecLabelDecode):
preds_idx = net_out[start_idx:end_idx].topk(1)[1][:, 0].tolist() preds_idx = net_out[start_idx:end_idx].topk(1)[1][:, 0].tolist()
preds_text = "".join( preds_text = "".join(
[ [
(
self.character[idx - 1] self.character[idx - 1]
if idx > 0 and idx <= len(self.character) if idx > 0 and idx <= len(self.character)
else "" else ""
)
for idx in preds_idx for idx in preds_idx
] ]
) )

View File

@ -45,12 +45,16 @@ def build_pre_process_list(args):
pad_op = {"PaddingTableImage": {"size": [args.table_max_len, args.table_max_len]}} pad_op = {"PaddingTableImage": {"size": [args.table_max_len, args.table_max_len]}}
normalize_op = { normalize_op = {
"NormalizeImage": { "NormalizeImage": {
"std": [0.229, 0.224, 0.225] "std": (
[0.229, 0.224, 0.225]
if args.table_algorithm not in ["TableMaster"] if args.table_algorithm not in ["TableMaster"]
else [0.5, 0.5, 0.5], else [0.5, 0.5, 0.5]
"mean": [0.485, 0.456, 0.406] ),
"mean": (
[0.485, 0.456, 0.406]
if args.table_algorithm not in ["TableMaster"] if args.table_algorithm not in ["TableMaster"]
else [0.5, 0.5, 0.5], else [0.5, 0.5, 0.5]
),
"scale": "1./255.", "scale": "1./255.",
"order": "hwc", "order": "hwc",
} }

View File

@ -65,4 +65,3 @@ function status_check(){
echo -e "\033[33m Run failed with command - ${model_name} - ${run_command} - ${log_path} \033[0m" | tee -a ${run_log} echo -e "\033[33m Run failed with command - ${model_name} - ${run_command} - ${log_path} \033[0m" | tee -a ${run_log}
fi fi
} }

View File

@ -49,4 +49,3 @@ inference:tools/infer/predict_det.py
null:null null:null
--benchmark:True --benchmark:True
null:null null:null

View File

@ -108,4 +108,3 @@ Eval:
drop_last: False drop_last: False
batch_size_per_card: 1 # must be 1 batch_size_per_card: 1 # must be 1
num_workers: 2 num_workers: 2

View File

@ -51,4 +51,3 @@ inference:tools/infer/predict_rec.py --rec_char_dict_path=./ppocr/utils/dict90.t
null:null null:null
===========================infer_benchmark_params========================== ===========================infer_benchmark_params==========================
random_infer_input:[{float32,[3,48,160]}] random_infer_input:[{float32,[3,48,160]}]

View File

@ -81,4 +81,3 @@ Eval:
drop_last: False drop_last: False
batch_size_per_card: 16 batch_size_per_card: 16
num_workers: 4 num_workers: 4

View File

@ -1 +0,0 @@

View File

@ -28,4 +28,3 @@ TRAIN:
VALID: VALID:
batch_size: 64 batch_size: 64
num_workers: 4 num_workers: 4

View File

@ -46,4 +46,3 @@ TRAIN:
VALID: VALID:
batch_size: 64 batch_size: 64
num_workers: 4 num_workers: 4

View File

@ -112,7 +112,3 @@ if [ ${MODE} = "lite_train_lite_infer" ] || [ ${MODE} = "whole_train_whole_infer
done done
done done
fi fi

View File

@ -167,5 +167,3 @@ if [ ${MODE} = "whole_infer" ]; then
Count=$(($Count + 1)) Count=$(($Count + 1))
done done
fi fi

View File

@ -155,4 +155,3 @@ if [ ${MODE} = "whole_infer" ]; then
Count=$(($Count + 1)) Count=$(($Count + 1))
done done
fi fi