|
|
@ -12,7 +12,6 @@
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
# limitations under the License.
|
|
|
|
import argparse
|
|
|
|
import argparse
|
|
|
|
import ast
|
|
|
|
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
import re
|
|
|
|
import re
|
|
|
|
from collections import OrderedDict
|
|
|
|
from collections import OrderedDict
|
|
|
@ -122,10 +121,15 @@ class TextExecutor(BaseExecutor):
|
|
|
|
default=paddle.get_device(),
|
|
|
|
default=paddle.get_device(),
|
|
|
|
help='Choose device to execute model inference.')
|
|
|
|
help='Choose device to execute model inference.')
|
|
|
|
self.parser.add_argument(
|
|
|
|
self.parser.add_argument(
|
|
|
|
|
|
|
|
'-d',
|
|
|
|
'--job_dump_result',
|
|
|
|
'--job_dump_result',
|
|
|
|
type=ast.literal_eval,
|
|
|
|
action='store_true',
|
|
|
|
default=False,
|
|
|
|
|
|
|
|
help='Save job result into file.')
|
|
|
|
help='Save job result into file.')
|
|
|
|
|
|
|
|
self.parser.add_argument(
|
|
|
|
|
|
|
|
'-v',
|
|
|
|
|
|
|
|
'--verbose',
|
|
|
|
|
|
|
|
action='store_true',
|
|
|
|
|
|
|
|
help='Increase logger verbosity of current task.')
|
|
|
|
|
|
|
|
|
|
|
|
def _get_pretrained_path(self, tag: str) -> os.PathLike:
|
|
|
|
def _get_pretrained_path(self, tag: str) -> os.PathLike:
|
|
|
|
"""
|
|
|
|
"""
|
|
|
@ -270,7 +274,9 @@ class TextExecutor(BaseExecutor):
|
|
|
|
ckpt_path = parser_args.ckpt_path
|
|
|
|
ckpt_path = parser_args.ckpt_path
|
|
|
|
punc_vocab = parser_args.punc_vocab
|
|
|
|
punc_vocab = parser_args.punc_vocab
|
|
|
|
device = parser_args.device
|
|
|
|
device = parser_args.device
|
|
|
|
job_dump_result = parser_args.job_dump_result
|
|
|
|
|
|
|
|
|
|
|
|
if not parser_args.verbose:
|
|
|
|
|
|
|
|
self.disable_task_loggers()
|
|
|
|
|
|
|
|
|
|
|
|
task_source = self.get_task_source(parser_args.input)
|
|
|
|
task_source = self.get_task_source(parser_args.input)
|
|
|
|
task_results = OrderedDict()
|
|
|
|
task_results = OrderedDict()
|
|
|
@ -286,7 +292,7 @@ class TextExecutor(BaseExecutor):
|
|
|
|
task_results[id_] = f'{e.__class__.__name__}: {e}'
|
|
|
|
task_results[id_] = f'{e.__class__.__name__}: {e}'
|
|
|
|
|
|
|
|
|
|
|
|
self.process_task_results(parser_args.input, task_results,
|
|
|
|
self.process_task_results(parser_args.input, task_results,
|
|
|
|
job_dump_result)
|
|
|
|
parser_args.job_dump_result)
|
|
|
|
|
|
|
|
|
|
|
|
if has_exceptions:
|
|
|
|
if has_exceptions:
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|