Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

310p export bug fix #699

Merged
merged 2 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion mindocr/models/backbones/rec_svtr.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,9 @@ def __init__(

if use_pos_embed:
self.pos_embed = Parameter(
ops.zeros((1, num_patches, embed_dim[0]), ms.float32)
Tensor(
np.zeros((1, num_patches, embed_dim[0]), np.float32), dtype=ms.float32
)
)
else:
self.pos_embed = None
Expand Down
3 changes: 1 addition & 2 deletions mindocr/models/transforms/stn.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ def init_stn(self) -> Tensor:
pass
elif self.activation == "sigmoid":
ctrl_points = -np.log(1.0 / ctrl_points - 1.0)
ctrl_points = Tensor(ctrl_points)
fc2_bias = ops.reshape(ctrl_points, (-1,))
fc2_bias = Tensor(np.reshape(ctrl_points, (-1,)))
return fc2_bias

def construct(self, x: Tensor) -> Tuple[Tensor, Tensor]:
Expand Down
6 changes: 3 additions & 3 deletions mindocr/models/transforms/tps_spatial_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def __init__(

# register precomputed matrices
self.inverse_kernel = Tensor(inverse_kernel, dtype=ms.float32)
self.padding_matrix = ops.zeros((1, 3, 2), ms.float32)
self.padding_matrix = Tensor(np.zeros((1, 3, 2), np.float32), dtype=ms.float32)
self.target_coordinate_repr = Tensor(target_coordinate_repr, dtype=ms.float32)
self.target_control_points = Tensor(target_control_points, dtype=ms.float32)

Expand All @@ -119,8 +119,8 @@ def construct(

padding_matrix = ops.tile(self.padding_matrix, (batch_size, 1, 1))
Y = ops.concat([source_control_points, padding_matrix], axis=1)
mapping_matrix = ops.matmul(self.inverse_kernel, Y)
source_coordinate = ops.matmul(self.target_coordinate_repr, mapping_matrix)
mapping_matrix = ops.matmul(self.inverse_kernel.expand_dims(0), Y)
source_coordinate = ops.matmul(self.target_coordinate_repr.expand_dims(0), mapping_matrix)
grid = ops.reshape(
source_coordinate,
(-1, self.target_height, self.target_width, 2),
Expand Down
2 changes: 1 addition & 1 deletion mindocr/models/utils/abinet_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ def __init__(self, d_model=512, dropout=0.9, max_len=5000):
pe[:, 0::2] = np.sin(position * div_term)
pe[:, 1::2] = np.cos(position * div_term)
pe = np.expand_dims(pe, 0)
pe = np.transpose(pe, (1, 0, 2))
pe = ms.Tensor(pe).astype(dtype=ms.float32)
pe = pe.transpose(1, 0, 2)
self.pe = ms.Parameter(pe, name="pe1", requires_grad=False)

def construct(self, x):
Expand Down
2 changes: 1 addition & 1 deletion tools/data_for_export_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@
"master_resnet31": {"model_name": "master_resnet31", "data_shape_h_w": [32, 100]},
"cls_mobilenet_v3_small_100_model": {"model_name": "cls_mobilenet_v3_small_100_model", "data_shape_h_w": [48, 192]},
"crnn_resnet34": {"model_name": "crnn_resnet34", "data_shape_h_w": [32, 100]},
"crnn_resnet34_ch": {"model_name": "crnn_resnet34_ch", "data_shape_h_w": [32, 100]},
"crnn_resnet34_ch": {"model_name": "crnn_resnet34_ch", "data_shape_h_w": [32, 320]},
"crnn_vgg7": {"model_name": "crnn_vgg7", "data_shape_h_w": [32, 100]},
"dbnet_mobilenetv3": {"model_name": "dbnet_mobilenetv3", "data_shape_h_w": [736, 1280]},
"dbnet_resnet18": {"model_name": "dbnet_resnet18", "data_shape_h_w": [736, 1280]},
Expand Down
2 changes: 1 addition & 1 deletion tools/export_convert_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def convert_mindir(self, model, info, input_file, config_file, force=False):
else:
log = f"{converted_model_path}.mindir exists and it will be overwritten if exported successfully."
subprocess.call(f"echo {log}".split(), stdout=self.log_handle, stderr=self.log_handle)
os.remove(converted_model_path)
os.remove(f"{converted_model_path}.mindir")
print(log)
command = (
f"{self.convert_tool} --fmk=MINDIR --modelFile={input_file} --outputFile={converted_model_path}"
Expand Down
Loading