Skip to content

【Hackathon 7th】Remove parser.add_argument #3878

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

Merged
merged 11 commits into from
Nov 14, 2024
Merged
4 changes: 2 additions & 2 deletions examples/aishell/asr0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ This stage is to transform dygraph to static graph.
If you already have a dynamic graph model, you can run this script:
```bash
source path.sh
./local/export.sh deepspeech2.yaml exp/deepspeech2/checkpoints/avg_1 exp/deepspeech2/checkpoints/avg_1.jit offline
./local/export.sh conf/deepspeech2.yaml exp/deepspeech2/checkpoints/avg_1 exp/deepspeech2/checkpoints/avg_1.jit
```
## Stage 5: Static graph Model Testing
Similar to stage 3, the static graph model can also be tested.
Expand All @@ -190,7 +190,7 @@ Similar to stage 3, the static graph model can also be tested.
```
If you already have exported the static graph, you can run this script:
```bash
CUDA_VISIBLE_DEVICES= ./local/test_export.sh conf/deepspeech2.yaml exp/deepspeech2/checkpoints/avg_1.jit offline
CUDA_VISIBLE_DEVICES= ./local/test_export.sh conf/deepspeech2.yaml conf/tuning/decode.yaml exp/deepspeech2/checkpoints/avg_1.jit
```
## Stage 6: Single Audio File Inference
In some situations, you want to use the trained model to do the inference for the single audio file. You can use stage 5. The code is shown below
Expand Down
3 changes: 0 additions & 3 deletions paddlespeech/s2t/exps/deepspeech2/bin/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ def main(config, args):

if __name__ == "__main__":
parser = default_argument_parser()
# save jit model to
parser.add_argument(
"--export_path", type=str, help="path of the jit model to save")
args = parser.parse_args()
print_arguments(args)

Expand Down
6 changes: 0 additions & 6 deletions paddlespeech/s2t/exps/deepspeech2/bin/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ def main(config, args):

if __name__ == "__main__":
parser = default_argument_parser()
# save asr result to
parser.add_argument(
"--result_file", type=str, help="path of save the asr result")
#load jit model from
parser.add_argument(
"--export_path", type=str, help="path of the jit model to save")
parser.add_argument(
"--enable-auto-log", action="store_true", help="use auto log")
args = parser.parse_args()
Expand Down
4 changes: 0 additions & 4 deletions paddlespeech/s2t/exps/deepspeech2/bin/test_wav.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,6 @@ def main(config, args):

if __name__ == "__main__":
parser = default_argument_parser()
parser.add_argument("--audio_file", type=str, help='audio file path')
# save asr result to
parser.add_argument(
"--result_file", type=str, help="path of save the asr result")
args = parser.parse_args()
print_arguments(args, globals())
if not os.path.isfile(args.audio_file):
Expand Down
5 changes: 4 additions & 1 deletion paddlespeech/s2t/exps/deepspeech2/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,10 @@ def export(self):
self.test_loader, self.config, self.args.checkpoint_path)
infer_model.eval()
static_model = infer_model.export()
logger.info(f"Export code: {static_model.forward.code}")
try:
logger.info(f"Export code: {static_model.forward.code}")
except:
logger.info(f"Fail to print Export code, static_model.forward.code can not be run.")
paddle.jit.save(static_model, self.args.export_path)


Expand Down