提交 c5bf379a 编写于 作者: S Steffy-zxf 提交者: wuzewu

Update the demo text-cls and seq-label (#48)

* Update the demo text-cls and seq-label
上级 2db995f2
......@@ -93,21 +93,25 @@ if __name__ == '__main__':
["不过重在晋趣,略增明人气息,妙在集古有道、不露痕迹罢了。"],
]
results = seq_label_task.predict(data=data)[0]
np_infers = results[0]
np_lens = results[1]
for index, text in enumerate(data):
labels = np_infers.reshape([-1]).astype(
np.int32).tolist()[args.max_seq_len * index:args.max_seq_len *
(index + 1)]
label_str = ""
count = 0
for label_val in labels:
label_str += inv_label_map[label_val]
count += 1
if count == (np_lens[index]):
break
# Drop the label results of CLS and SEP Token
print("%s\tpredict=%s" % (text[0], label_str[1:-1]))
results = seq_label_task.predict(data=data)
for num_batch, batch_results in enumerate(results):
infers = batch_results[0].reshape([-1]).astype(np.int32).tolist()
np_lens = batch_results[1]
for index, np_len in enumerate(np_lens):
labels = infers[index * args.max_seq_len:(index + 1) *
args.max_seq_len]
label_str = ""
count = 0
for label_val in labels:
label_str += inv_label_map[label_val]
count += 1
if count == np_len:
break
# Drop the label results of CLS and SEP Token
print(
"%s\tpredict=%s" %
(data[num_batch * args.batch_size + index][0], label_str[1:-1]))
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册