From 6fb84e4bf2219ff3b5a701282b15fea373fc2251 Mon Sep 17 00:00:00 2001
From: Zhihao Du <neo.dzh@alibaba-inc.com>
Date: 星期四, 03 八月 2023 10:54:27 +0800
Subject: [PATCH] TOLD/SOND: remove typeguard dependency. (#801)
---
funasr/datasets/collate_fn.py | 5 -----
funasr/models/e2e_diar_sond.py | 2 --
funasr/layers/label_aggregation.py | 2 --
funasr/tasks/diar.py | 9 ---------
4 files changed, 0 insertions(+), 18 deletions(-)
diff --git a/funasr/datasets/collate_fn.py b/funasr/datasets/collate_fn.py
index d1ac64a..7ff70a7 100644
--- a/funasr/datasets/collate_fn.py
+++ b/funasr/datasets/collate_fn.py
@@ -6,8 +6,6 @@
import numpy as np
import torch
-from typeguard import check_argument_types
-from typeguard import check_return_type
from funasr.modules.nets_utils import pad_list, pad_list_all_dim
@@ -89,7 +87,6 @@
not_sequence: Collection[str] = (),
max_sample_size=None
):
- assert check_argument_types()
self.float_pad_value = float_pad_value
self.int_pad_value = int_pad_value
self.not_sequence = set(not_sequence)
@@ -120,7 +117,6 @@
) -> Tuple[List[str], Dict[str, torch.Tensor]]:
"""Concatenate ndarray-list to an array and convert to torch.Tensor.
"""
- assert check_argument_types()
uttids = [u for u, _ in data]
data = [d for _, d in data]
@@ -146,7 +142,6 @@
output[key + "_lengths"] = lens
output = (uttids, output)
- assert check_return_type(output)
return output
diff --git a/funasr/layers/label_aggregation.py b/funasr/layers/label_aggregation.py
index 97556d5..e86c296 100644
--- a/funasr/layers/label_aggregation.py
+++ b/funasr/layers/label_aggregation.py
@@ -1,7 +1,6 @@
import torch
from typing import Optional
from typing import Tuple
-from typeguard import check_argument_types
from torch.nn import functional as F
from funasr.modules.nets_utils import make_pad_mask
@@ -86,7 +85,6 @@
self,
hop_length: int = 8,
):
- assert check_argument_types()
super().__init__()
self.hop_length = hop_length
diff --git a/funasr/models/e2e_diar_sond.py b/funasr/models/e2e_diar_sond.py
index fa1fc38..aa6294a 100644
--- a/funasr/models/e2e_diar_sond.py
+++ b/funasr/models/e2e_diar_sond.py
@@ -13,7 +13,6 @@
import numpy as np
import torch
from torch.nn import functional as F
-from typeguard import check_argument_types
from funasr.modules.nets_utils import to_device
from funasr.modules.nets_utils import make_pad_mask
@@ -69,7 +68,6 @@
freeze_encoder: bool = False,
onfly_shuffle_speaker: bool = True,
):
- assert check_argument_types()
super().__init__()
diff --git a/funasr/tasks/diar.py b/funasr/tasks/diar.py
index 2d10435..084b971 100644
--- a/funasr/tasks/diar.py
+++ b/funasr/tasks/diar.py
@@ -13,8 +13,6 @@
import numpy as np
import torch
import yaml
-from typeguard import check_argument_types
-from typeguard import check_return_type
from funasr.datasets.collate_fn import DiarCollateFn
from funasr.datasets.preprocessor import CommonPreprocessor
@@ -341,7 +339,6 @@
[Collection[Tuple[str, Dict[str, np.ndarray]]]],
Tuple[List[str], Dict[str, torch.Tensor]],
]:
- assert check_argument_types()
# NOTE(kamo): int value = 0 is reserved by CTC-blank symbol
return DiarCollateFn(float_pad_value=0.0, int_pad_value=-1)
@@ -349,7 +346,6 @@
def build_preprocess_fn(
cls, args: argparse.Namespace, train: bool
) -> Optional[Callable[[str, Dict[str, np.array]], Dict[str, np.ndarray]]]:
- assert check_argument_types()
if args.use_preprocessor:
retval = CommonPreprocessor(
train=train,
@@ -379,7 +375,6 @@
)
else:
retval = None
- assert check_return_type(retval)
return retval
@classmethod
@@ -398,7 +393,6 @@
cls, train: bool = True, inference: bool = False
) -> Tuple[str, ...]:
retval = ()
- assert check_return_type(retval)
return retval
@classmethod
@@ -438,7 +432,6 @@
@classmethod
def build_model(cls, args: argparse.Namespace):
- assert check_argument_types()
if isinstance(args.token_list, str):
with open(args.token_list, encoding="utf-8") as f:
token_list = [line.rstrip() for line in f]
@@ -546,7 +539,6 @@
initialize(model, args.init)
logging.info(f"Init model parameters with {args.init}.")
- assert check_return_type(model)
return model
# ~~~~~~~~~ The methods below are mainly used for inference ~~~~~~~~~
@@ -569,7 +561,6 @@
device: Device type, "cpu", "cuda", or "cuda:N".
"""
- assert check_argument_types()
if config_file is None:
assert model_file is not None, (
"The argument 'model_file' must be provided "
--
Gitblit v1.9.1