Skip to content

Commit 096170a

Browse files
committed
feat: register keras custom objects to support load models
1 parent c8d9f06 commit 096170a

File tree

91 files changed

+681
-721
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+681
-721
lines changed

.pre-commit-config.yaml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
repos:
22
- repo: local
33
hooks:
4-
- id: black-formatter-check
5-
name: black-formatter-check
6-
entry: black --check
4+
- id: black-formatter-fix
5+
name: black-formatter-fix
6+
entry: bash -c "for f in $@; do black --verbose $f; done"
7+
language: system
8+
types: [python]
9+
stages: [pre-commit]
10+
fail_fast: true
11+
verbose: true
12+
- id: isort-fix
13+
name: isort-fix
14+
entry: bash -c "for f in $@; do echo -e \"Organize import for file $f\" && isort $f; done"
715
language: system
816
types: [python]
917
stages: [pre-commit]
1018
fail_fast: true
1119
verbose: true
1220
- id: pylint-check
1321
name: pylint-check
14-
entry: pylint --rcfile=.pylintrc -rn -sn
22+
entry: bash -c "for f in $@; do pylint --rcfile=.pylintrc -rn -sn $f; done"
1523
language: system
1624
types: [python]
1725
stages: [pre-commit]

.pylintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ disable=too-few-public-methods,
119119
redefined-outer-name,
120120
consider-using-f-string,
121121
fixme,
122+
unused-variable,
122123

123124
# Enable the message, report, category or checker with the given id(s). You can
124125
# either give multiple identifier separated by comma (,) or put this option

.vscode/settings.json

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
{
2-
"editor.formatOnSave": true,
3-
"python.analysis.fixAll": [
4-
"source.unusedImports",
2+
"[python]": {
3+
"editor.defaultFormatter": "ms-python.black-formatter"
4+
},
5+
"autoDocstring.docstringFormat": "numpy",
6+
"black-formatter.args": [
7+
"--config",
8+
"${workspaceFolder}/pyproject.toml"
9+
],
10+
"black-formatter.path": [
11+
"${interpreter}",
12+
"-m",
13+
"black"
514
],
615
"editor.codeActionsOnSave": {
16+
"source.fixAll": "explicit",
717
"source.organizeImports": "explicit"
818
},
19+
"editor.formatOnSave": true,
920
"isort.args": [
10-
"--profile",
11-
"black",
12-
"--line-length",
13-
"130"
14-
],
15-
"autoDocstring.docstringFormat": "numpy",
16-
"[python]": {
17-
"editor.defaultFormatter": "ms-python.black-formatter",
18-
},
19-
"pylint.path": [
20-
"${interpreter}",
21-
"-m",
22-
"pylint"
21+
"--settings-file",
22+
"${workspaceFolder}/pyproject.toml"
2323
],
2424
"pylint.args": [
2525
"--rcfile=${workspaceFolder}/.pylintrc"
2626
],
27-
"black-formatter.path": [
27+
"pylint.path": [
2828
"${interpreter}",
2929
"-m",
30-
"black"
30+
"pylint"
3131
],
32-
"isort.path": [
33-
"${interpreter}",
34-
"-m",
35-
"isort"
36-
]
32+
"python.analysis.fixAll": [
33+
"source.unusedImports",
34+
"source.convertImportFormat"
35+
],
36+
"python.analysis.importFormat": "absolute"
3737
}

examples/configs/librispeech/data.yml.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ data_config:
66
- {{datadir}}/train-clean-100/transcripts.tsv
77
- {{datadir}}/train-clean-360/transcripts.tsv
88
- {{datadir}}/train-other-500/transcripts.tsv
9+
- {{datadir}}/dev-clean/transcripts.tsv
910
tfrecords_dir: {{datadir}}/tfrecords
1011
shuffle: True
1112
cache: False

examples/inferences/main.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@
1414

1515
import os
1616

17-
import tensorflow as tf
18-
import keras
19-
20-
from tensorflow_asr import schemas, tokenizers
21-
from tensorflow_asr.models import base_model
17+
from tensorflow_asr import keras, schemas, tf, tokenizers
2218
from tensorflow_asr.configs import Config
19+
from tensorflow_asr.models import base_model
2320
from tensorflow_asr.utils import cli_util, data_util, env_util, file_util
2421

22+
env_util.setup_logging()
2523
logger = tf.get_logger()
2624

2725

examples/inferences/tflite.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import tensorflow as tf
1615
import tensorflow_text as tft
1716
from tensorflow.lite.python import interpreter
1817

19-
from tensorflow_asr.utils import cli_util, data_util
18+
from tensorflow_asr import tf
19+
from tensorflow_asr.utils import cli_util, data_util, env_util
2020

21+
env_util.setup_logging()
2122
logger = tf.get_logger()
2223

2324

examples/models/ctc/conformer/char-small.yml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{{decoder_config}}
33

44
model_config:
5-
class_name: tensorflow_asr.models.ctc>Conformer
5+
class_name: tensorflow_asr.models.ctc.conformer>Conformer
66
config:
77
name: conformer
88
speech_config:

examples/models/ctc/conformer/tiny.yml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{{decoder_config}}
33

44
model_config:
5-
class_name: tensorflow_asr.models.ctc>Conformer
5+
class_name: tensorflow_asr.models.ctc.conformer>Conformer
66
config:
77
name: conformer
88
speech_config:

examples/models/ctc/deepspeech2/base.yml.j2

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@
22
{{decoder_config}}
33

44
model_config:
5-
class_name: tensorflow_asr.models.ctc>DeepSpeech2
5+
class_name: tensorflow_asr.models.ctc.deepspeech2>DeepSpeech2
66
config:
77
name: deepspeech2
88
speech_config:
99
sample_rate: 16000
1010
frame_ms: 25
1111
stride_ms: 10
12-
num_feature_bins: 128
13-
feature_type: spectrogram
14-
normalize_zscore: True
12+
nfft: 512
13+
num_feature_bins: 80
14+
feature_type: log_mel_spectrogram
1515
augmentation_config:
1616
feature_augment:
1717
time_masking:
18-
prob: 0.5
18+
prob: 1.0
1919
num_masks: 5
2020
mask_factor: -1 # whole utterance
2121
p_upperbound: 0.05
2222
mask_value: 0
2323
freq_masking:
24-
prob: 0.5
24+
prob: 1.0
2525
num_masks: 1
2626
mask_factor: 27
2727
mask_value: 0
@@ -100,9 +100,9 @@ learning_config:
100100
config:
101101
log_dir: {{modeldir}}/tensorboard
102102
histogram_freq: 0
103-
write_graph: False
103+
write_graph: True
104104
write_images: False
105-
write_steps_per_second: False
105+
write_steps_per_second: True
106106
update_freq: batch
107107
profile_batch: 0
108108

examples/models/ctc/jasper/base.yml.j2

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22
{{decoder_config}}
33

44
model_config:
5-
class_name: tensorflow_asr.models.ctc>Jasper
5+
class_name: tensorflow_asr.models.ctc.jasper>Jasper
66
config:
77
name: jasper
88
speech_config:
99
sample_rate: 16000
1010
frame_ms: 25
1111
stride_ms: 10
12+
nfft: 512
1213
num_feature_bins: 80
1314
feature_type: log_mel_spectrogram
15+
log_base: "10"
1416
dense: True
1517
first_additional_block_channels: 256
1618
first_additional_block_kernels: 11

0 commit comments

Comments
 (0)