From d6b6c6ffe469eaa8ff98234a62b5badd281d5873 Mon Sep 17 00:00:00 2001
From: wuzewu
Date: Thu, 27 May 2021 19:45:11 +0800
Subject: [PATCH] Fix travis-ci issue.
---
.travis.yml | 1 +
README_ch.md | 4 +-
demo/audio_classification/predict.py | 19 +-
demo/audio_classification/train.py | 9 +-
demo/autoaug/README.md | 13 +-
demo/autoaug/hub_fitter.py | 42 +-
demo/autoaug/paddlehub_utils/reader.py | 94 +-
demo/autoaug/paddlehub_utils/trainer.py | 33 +-
demo/autoaug/search.py | 21 +-
demo/autoaug/train.py | 47 +-
demo/colorization/predict.py | 2 +-
demo/colorization/train.py | 7 +-
demo/semantic_segmentation/README.md | 4 +-
demo/semantic_segmentation/predict.py | 2 +-
demo/sequence_labeling/predict.py | 5 +-
demo/sequence_labeling/train.py | 31 +-
demo/style_transfer/README.md | 2 +-
demo/style_transfer/predict.py | 2 +-
demo/style_transfer/train.py | 2 +-
demo/text_classification/README.md | 1 -
demo/text_classification/embedding/predict.py | 19 +-
demo/text_classification/embedding/train.py | 11 +-
demo/text_classification/train.py | 18 +-
demo/text_matching/train.py | 9 +-
docs/docs_ch/figures.md | 3 -
.../PANNs/cnn10/module.py | 35 +-
.../PANNs/cnn10/network.py | 26 +-
.../PANNs/cnn14/module.py | 35 +-
.../PANNs/cnn14/network.py | 26 +-
.../audio_classification/PANNs/cnn6/module.py | 35 +-
.../PANNs/cnn6/network.py | 13 +-
.../user_guided_colorization/data_feed.py | 14 +-
.../user_guided_colorization/module.py | 1 +
.../Image_gan/style_transfer/msgnet/module.py | 30 +-
.../resnet50_vd_imagenet_ssld/label_list.txt | 2 +-
.../resnet50_vd_imagenet_ssld/module.py | 15 +-
.../meter_readings/barometer_reader/README.md | 16 +-
.../meter_readings/barometer_reader/module.py | 84 +-
.../instance_segmentation/solov2/README.md | 1 -
.../instance_segmentation/solov2/data_feed.py | 90 +-
.../instance_segmentation/solov2/module.py | 49 +-
.../instance_segmentation/solov2/processor.py | 16 +-
.../openpose_body_estimation/module.py | 36 +-
.../openpose_body_estimation/processor.py | 4 +-
.../openpose_hands_estimation/module.py | 58 +-
.../openpose_hands_estimation/processor.py | 7 +-
.../ExtremeC3_Portrait_Segmentation/module.py | 17 +-
.../SINet_Portrait_Segmentation/module.py | 15 +-
.../deeplabv3p_resnet50_voc/layers.py | 88 +-
.../deeplabv3p_resnet50_voc/module.py | 45 +-
.../deeplabv3p_resnet50_voc/resnet.py | 43 +-
.../ocrnet_hrnetw18_voc/hrnet.py | 136 +--
.../ocrnet_hrnetw18_voc/layers.py | 96 +-
.../ocrnet_hrnetw18_voc/module.py | 45 +-
.../language_model/bert-base-cased/README.md | 2 +-
.../language_model/bert-base-cased/module.py | 24 +-
.../bert-base-chinese/README.md | 2 +-
.../bert-base-chinese/module.py | 28 +-
.../bert-base-multilingual-cased/README.md | 2 +-
.../bert-base-multilingual-cased/module.py | 31 +-
.../bert-base-multilingual-uncased/README.md | 2 +-
.../bert-base-multilingual-uncased/module.py | 31 +-
.../bert-base-uncased/README.md | 2 +-
.../bert-base-uncased/module.py | 24 +-
.../language_model/bert-large-cased/README.md | 2 +-
.../language_model/bert-large-cased/module.py | 24 +-
.../bert-large-uncased/README.md | 2 +-
.../bert-large-uncased/module.py | 24 +-
.../language_model/chinese_bert_wwm/README.md | 4 +-
.../language_model/chinese_bert_wwm/module.py | 31 +-
.../chinese_bert_wwm_ext/README.md | 2 +-
.../chinese_bert_wwm_ext/module.py | 31 +-
.../chinese_electra_base/README.md | 4 +-
.../chinese_electra_base/module.py | 28 +-
.../chinese_electra_small/README.md | 2 +-
.../chinese_electra_small/module.py | 28 +-
.../language_model/electra_base/README.md | 2 +-
.../language_model/electra_base/module.py | 31 +-
.../language_model/electra_large/README.md | 2 +-
.../language_model/electra_large/module.py | 31 +-
.../language_model/electra_small/README.md | 2 +-
.../language_model/electra_small/module.py | 31 +-
modules/text/language_model/ernie/README.md | 2 +-
modules/text/language_model/ernie/module.py | 24 +-
.../text/language_model/ernie_tiny/README.md | 2 +-
.../text/language_model/ernie_tiny/module.py | 24 +-
.../ernie_v2_eng_base/README.md | 2 +-
.../ernie_v2_eng_base/module.py | 28 +-
.../ernie_v2_eng_large/README.md | 2 +-
.../ernie_v2_eng_large/module.py | 28 +-
modules/text/language_model/rbt3/README.md | 2 +-
modules/text/language_model/rbt3/module.py | 28 +-
modules/text/language_model/rbtl3/README.md | 2 +-
modules/text/language_model/rbtl3/module.py | 28 +-
.../roberta-wwm-ext-large/README.md | 2 +-
.../roberta-wwm-ext-large/module.py | 28 +-
.../language_model/roberta-wwm-ext/README.md | 2 +-
.../language_model/roberta-wwm-ext/module.py | 28 +-
.../text/language_model/simnet_bow/module.py | 69 +-
.../text_generation/Rumor_prediction/dict.txt | 2 +-
.../Rumor_prediction/module.py | 49 +-
.../ernie_gen_leave/model/decode.py | 122 +--
.../ernie_gen_leave/model/file_utils.py | 5 +-
.../ernie_gen_leave/model/modeling_ernie.py | 128 +--
.../model/modeling_ernie_gen.py | 27 +-
.../ernie_gen_leave/model/tokenizing_ernie.py | 22 +-
.../text_generation/ernie_gen_leave/module.py | 33 +-
.../text_generation/ernie_gen_leave/test.py | 2 +-
.../text/text_generation/plato-mini/module.py | 42 +-
.../unified_transformer-12L-cn-luge/module.py | 42 +-
.../unified_transformer-12L-cn/module.py | 42 +-
.../DriverStatusRecognition/__init__.py | 1 -
.../DriverStatusRecognition/module.py | 37 +-
.../SnakeIdentification/__init__.py | 1 -
.../SnakeIdentification/module.py | 37 +-
.../SpinalNet_Gemstones/gem_dataset.py | 19 +-
.../spinalnet_res101_gemstone/module.py | 89 +-
.../spinalnet_res50_gemstone/module.py | 89 +-
.../spinalnet_vgg16_gemstone/module.py | 47 +-
.../food_classification/__init__.py | 1 -
.../food_classification/module.py | 37 +-
.../marine_biometrics/__init__.py | 1 -
.../marine_biometrics/module.py | 40 +-
.../WatermeterSegmentation/__init__.py | 1 -
.../WatermeterSegmentation/module.py | 75 +-
.../README.md | 2 +-
.../module.py | 17 +-
.../text_generation/GPT2_Base_CN/README.md | 6 +-
.../text_generation/GPT2_Base_CN/module.py | 51 +-
.../text_generation/GPT2_CPM_LM/README.md | 6 +-
.../text_generation/GPT2_CPM_LM/module.py | 60 +-
.../video/Video_editing/SkyAR/__init__.py | 1 -
.../video/Video_editing/SkyAR/module.py | 49 +-
.../video/Video_editing/SkyAR/rain.py | 4 +-
.../video/Video_editing/SkyAR/skybox.py | 67 +-
.../video/Video_editing/SkyAR/skyfilter.py | 41 +-
.../video/Video_editing/SkyAR/utils.py | 22 +-
paddlehub/compat/module/module_desc_pb2.py | 900 +++++++++---------
paddlehub/datasets/base_audio_dataset.py | 29 +-
paddlehub/datasets/base_nlp_dataset.py | 8 +-
paddlehub/datasets/base_seg_dataset.py | 34 +-
paddlehub/datasets/esc50.py | 28 +-
paddlehub/datasets/lcqmc.py | 2 +-
paddlehub/datasets/opticdiscseg.py | 16 +-
paddlehub/datasets/pascalvoc.py | 4 +
paddlehub/finetune/trainer.py | 5 +-
paddlehub/module/cv_module.py | 151 ++-
paddlehub/utils/download.py | 1 -
paddlehub/utils/utils.py | 17 +-
paddlehub/vision/segmentation_transforms.py | 61 +-
paddlehub/vision/transforms.py | 20 +-
tests/test_module.py | 12 +-
152 files changed, 1919 insertions(+), 2895 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index fdb117ee..4468bd7d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -27,6 +27,7 @@ install:
else
pip install --upgrade paddlepaddle;
pip install -r requirements.txt;
+ pip install yapf==0.26.0
fi
notifications:
diff --git a/README_ch.md b/README_ch.md
index 45f63613..7e783918 100644
--- a/README_ch.md
+++ b/README_ch.md
@@ -127,9 +127,9 @@
如扫码失败,请添加微信15704308458,并备注“Hub”,运营同学会邀请您入群。
-
+
## 快速开始
-
+
```python
diff --git a/demo/audio_classification/predict.py b/demo/audio_classification/predict.py
index 850b949e..389a986f 100644
--- a/demo/audio_classification/predict.py
+++ b/demo/audio_classification/predict.py
@@ -26,21 +26,20 @@ parser.add_argument("--wav", type=str, required=True, help="Audio file to infer.
parser.add_argument("--sr", type=int, default=44100, help="Sample rate of inference audio.")
parser.add_argument("--model_type", type=str, default='panns_cnn14', help="Select model to to inference.")
parser.add_argument("--topk", type=int, default=1, help="Show top k results of prediction labels.")
-parser.add_argument("--checkpoint",
- type=str,
- default='./checkpoint/best_model/model.pdparams',
- help="Checkpoint of model.")
+parser.add_argument(
+ "--checkpoint", type=str, default='./checkpoint/best_model/model.pdparams', help="Checkpoint of model.")
args = parser.parse_args()
if __name__ == '__main__':
label_map = {idx: label for idx, label in enumerate(ESC50.label_list)}
- model = hub.Module(name=args.model_type,
- version='1.0.0',
- task='sound-cls',
- num_class=ESC50.num_class,
- label_map=label_map,
- load_checkpoint=args.checkpoint)
+ model = hub.Module(
+ name=args.model_type,
+ version='1.0.0',
+ task='sound-cls',
+ num_class=ESC50.num_class,
+ label_map=label_map,
+ load_checkpoint=args.checkpoint)
data = [librosa.load(args.wav, sr=args.sr)[0]]
result = model.predict(data, sample_rate=args.sr, batch_size=1, feat_type='mel', use_gpu=True)
diff --git a/demo/audio_classification/train.py b/demo/audio_classification/train.py
index 98f2d6fd..21650f35 100644
--- a/demo/audio_classification/train.py
+++ b/demo/audio_classification/train.py
@@ -22,10 +22,11 @@ from paddlehub.datasets import ESC50
parser = argparse.ArgumentParser(__doc__)
parser.add_argument("--num_epoch", type=int, default=50, help="Number of epoches for fine-tuning.")
-parser.add_argument("--use_gpu",
- type=ast.literal_eval,
- default=True,
- help="Whether use GPU for fine-tuning, input should be True or False")
+parser.add_argument(
+ "--use_gpu",
+ type=ast.literal_eval,
+ default=True,
+ help="Whether use GPU for fine-tuning, input should be True or False")
parser.add_argument("--learning_rate", type=float, default=5e-5, help="Learning rate used to train with warmup.")
parser.add_argument("--batch_size", type=int, default=16, help="Total examples' number in batch for training.")
parser.add_argument("--checkpoint_dir", type=str, default='./checkpoint', help="Directory to model checkpoint")
diff --git a/demo/autoaug/README.md b/demo/autoaug/README.md
index 4b9c1e93..8d5e4f7f 100644
--- a/demo/autoaug/README.md
+++ b/demo/autoaug/README.md
@@ -73,7 +73,7 @@ auto-augment软件包目前支持Paddle的图像分类任务和物体检测任
- train_img_prefix:str. 训练集数据路径前缀
-- train_ann_file:str, 训练集数据描述文件,
+- train_ann_file:str, 训练集数据描述文件,
- val_img_prefix:str, 验证集数据路径前缀
@@ -83,7 +83,7 @@ auto-augment软件包目前支持Paddle的图像分类任务和物体检测任
- delimiter: "," 数据描述文件采用的分隔符
-
+
#### resource_config(资源配置)
@@ -91,7 +91,7 @@ auto-augment软件包目前支持Paddle的图像分类任务和物体检测任
- cpu: float, 表示每个搜索进程的cpu分配资源,run_mode=="ray"模式下支持小数分配
-
+
#### algo_config(算法配置)
@@ -128,7 +128,7 @@ auto-augment软件包目前支持Paddle的图像分类任务和物体检测任
支持1,2模式混合定议
-
+
##### 图像分类算子
@@ -173,8 +173,3 @@ bash search.sh
cd PaddleHub/demo/autaug/
bash train.sh
```
-
-
-
-
-
diff --git a/demo/autoaug/hub_fitter.py b/demo/autoaug/hub_fitter.py
index 3b7887f5..afecfcae 100755
--- a/demo/autoaug/hub_fitter.py
+++ b/demo/autoaug/hub_fitter.py
@@ -23,6 +23,7 @@ logger = log.get_logger(level=logging.INFO)
import auto_augment
auto_augment_path = auto_augment.__file__
+
class HubFitterClassifer(object):
"""Trains an instance of the Model class."""
@@ -43,8 +44,7 @@ class HubFitterClassifer(object):
# `import paddle`. Otherwise, it would not take any effect.
set_paddle_flags(
# enable GC to save memory
- FLAGS_fraction_of_gpu_memory_to_use=hparams.resource_config.gpu,
- )
+ FLAGS_fraction_of_gpu_memory_to_use=hparams.resource_config.gpu, )
import paddle
import paddlehub as hub
from paddlehub_utils.trainer import CustomTrainer
@@ -63,23 +63,18 @@ class HubFitterClassifer(object):
paddle.disable_static(paddle.CUDAPlace(paddle.distributed.get_rank()))
train_dataset, eval_dataset = _init_loader(self.hparams)
- model = hub.Module(name=hparams["task_config"]["classifier"]["model_name"], label_list=self.class_to_id_dict.keys(), load_checkpoint=None)
-
- optimizer = paddle.optimizer.Adam(
- learning_rate=0.001, parameters=model.parameters())
- trainer = CustomTrainer(
- model=model,
- optimizer=optimizer,
- checkpoint_dir='img_classification_ckpt')
+ model = hub.Module(
+ name=hparams["task_config"]["classifier"]["model_name"],
+ label_list=self.class_to_id_dict.keys(),
+ load_checkpoint=None)
+
+ optimizer = paddle.optimizer.Adam(learning_rate=0.001, parameters=model.parameters())
+ trainer = CustomTrainer(model=model, optimizer=optimizer, checkpoint_dir='img_classification_ckpt')
self.model = model
self.optimizer = optimizer
trainer.init_train_and_eval(
- train_dataset,
- epochs=100,
- batch_size=32,
- eval_dataset=eval_dataset,
- save_interval=1)
+ train_dataset, epochs=100, batch_size=32, eval_dataset=eval_dataset, save_interval=1)
self.trainer = trainer
def _fit_param(self, show: bool = False) -> None:
@@ -123,8 +118,7 @@ class HubFitterClassifer(object):
"""
self.hparams = new_hparams
- self.trainer.train_loader.dataset.reset_policy(
- new_hparams.search_space)
+ self.trainer.train_loader.dataset.reset_policy(new_hparams.search_space)
return None
def save_model(self, checkpoint_dir: str, step: Optional[str] = None) -> str:
@@ -134,8 +128,7 @@ class HubFitterClassifer(object):
step: If provided, creates a checkpoint with the given step
number, instead of overwriting the existing checkpoints.
"""
- checkpoint_path = os.path.join(checkpoint_dir,
- 'epoch') + '-' + str(step)
+ checkpoint_path = os.path.join(checkpoint_dir, 'epoch') + '-' + str(step)
logger.info('Saving model checkpoint to {}'.format(checkpoint_path))
self.trainer.save_model(os.path.join(checkpoint_path, "checkpoint"))
@@ -145,8 +138,7 @@ class HubFitterClassifer(object):
"""Loads a checkpoint with the architecture structure stored in the name."""
ckpt_path = os.path.join(checkpoint_path, "checkpoint")
self.trainer.load_model(ckpt_path)
- logger.info(
- 'Loaded child model checkpoint from {}'.format(checkpoint_path))
+ logger.info('Loaded child model checkpoint from {}'.format(checkpoint_path))
def eval_child_model(self, mode: str, pass_id: int = 0) -> dict:
"""Evaluate the child model.
@@ -204,10 +196,7 @@ class HubFitterClassifer(object):
"""Trains the model `m` for one epoch."""
start_time = time.time()
train_acc = self.train_one_epoch(curr_epoch)
- logger.info(
- 'Epoch:{} time(min): {}'.format(
- curr_epoch,
- (time.time() - start_time) / 60.0))
+ logger.info('Epoch:{} time(min): {}'.format(curr_epoch, (time.time() - start_time) / 60.0))
return train_acc
def _compute_final_accuracies(self, iteration: int) -> dict:
@@ -228,8 +217,7 @@ class HubFitterClassifer(object):
self._fit_param()
train_acc = self._run_training_loop(epoch)
valid_acc = self.eval_child_model(mode="val", pass_id=epoch)
- logger.info('valid acc: {}'.format(
- valid_acc))
+ logger.info('valid acc: {}'.format(valid_acc))
all_metric = {}
all_metric.update(train_acc)
all_metric.update(valid_acc)
diff --git a/demo/autoaug/paddlehub_utils/reader.py b/demo/autoaug/paddlehub_utils/reader.py
index 6b36419e..0ee9311d 100644
--- a/demo/autoaug/paddlehub_utils/reader.py
+++ b/demo/autoaug/paddlehub_utils/reader.py
@@ -13,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-
# -*- coding: utf-8 -*-
# *******************************************************************************
#
@@ -36,8 +35,7 @@ import paddlehub.vision.transforms as transforms
from PIL import ImageFile
from auto_augment.autoaug.transform.autoaug_transform import AutoAugTransform
ImageFile.LOAD_TRUNCATED_IMAGES = True
-__imagenet_stats = {'mean': [0.485, 0.456, 0.406],
- 'std': [0.229, 0.224, 0.225]}
+__imagenet_stats = {'mean': [0.485, 0.456, 0.406], 'std': [0.229, 0.224, 0.225]}
class PbaAugment(object):
@@ -45,14 +43,13 @@ class PbaAugment(object):
pytorch 分类 PbaAugment transform
"""
- def __init__(
- self,
- input_size: int = 224,
- scale_size: int = 256,
- normalize: Optional[list] = None,
- pre_transform: bool = True,
- stage: str = "search",
- **kwargs) -> None:
+ def __init__(self,
+ input_size: int = 224,
+ scale_size: int = 256,
+ normalize: Optional[list] = None,
+ pre_transform: bool = True,
+ stage: str = "search",
+ **kwargs) -> None:
"""
Args:
@@ -64,27 +61,20 @@ class PbaAugment(object):
"""
if normalize is None:
- normalize = {
- 'mean': [
- 0.485, 0.456, 0.406], 'std': [
- 0.229, 0.224, 0.225]}
+ normalize = {'mean': [0.485, 0.456, 0.406], 'std': [0.229, 0.224, 0.225]}
policy = kwargs["policy"]
assert stage in ["search", "train"]
train_epochs = kwargs["hp_policy_epochs"]
- self.auto_aug_transform = AutoAugTransform.create(
- policy, stage=stage, train_epochs=train_epochs)
+ self.auto_aug_transform = AutoAugTransform.create(policy, stage=stage, train_epochs=train_epochs)
#self.auto_aug_transform = PbtAutoAugmentClassiferTransform(conf)
if pre_transform:
self.pre_transform = transforms.Resize(input_size)
self.post_transform = transforms.Compose(
- transforms=[
- transforms.Permute(),
- transforms.Normalize(**normalize, channel_first=True)
- ],
- channel_first = False
- )
+ transforms=[transforms.Permute(),
+ transforms.Normalize(**normalize, channel_first=True)],
+ channel_first=False)
self.cur_epoch = 0
def set_epoch(self, indx: int) -> None:
@@ -164,15 +154,14 @@ class PicReader(paddle.io.Dataset):
PicReader
"""
- def __init__(
- self,
- root_path: str,
- list_file: str,
- meta: bool = False,
- transform: Optional[callable] = None,
- class_to_id_dict: Optional[dict] = None,
- cache_img: bool = False,
- **kwargs) -> None:
+ def __init__(self,
+ root_path: str,
+ list_file: str,
+ meta: bool = False,
+ transform: Optional[callable] = None,
+ class_to_id_dict: Optional[dict] = None,
+ cache_img: bool = False,
+ **kwargs) -> None:
"""
Args:
@@ -222,8 +211,7 @@ class PicReader(paddle.io.Dataset):
img = cv2.resize(img, (scale_size, scale_size))
self.cache_img_buff[image_path] = img
except BaseException:
- print("img_path:{} can not by cv2".format(
- image_path).format(image_path))
+ print("img_path:{} can not by cv2".format(image_path).format(image_path))
pass
@@ -265,9 +253,7 @@ class PicReader(paddle.io.Dataset):
with open(self.list_file) as f:
lines = f.read().splitlines()
- print(
- "PicReader:: found {} picture in `{}'".format(
- len(lines), self.list_file))
+ print("PicReader:: found {} picture in `{}'".format(len(lines), self.list_file))
for i, line in enumerate(lines):
record = re.split(delimiter, line)
# record = line.split()
@@ -401,20 +387,12 @@ def _read_classes(csv_file: str) -> dict:
class_name = row.strip()
# print(class_id, class_name)
except ValueError:
- six.raise_from(
- ValueError(
- 'line {}: format should be \'class_name\''.format(line)),
- None)
+ six.raise_from(ValueError('line {}: format should be \'class_name\''.format(line)), None)
- class_id = _parse(
- line,
- int,
- 'line {}: malformed class ID: {{}}'.format(line))
+ class_id = _parse(line, int, 'line {}: malformed class ID: {{}}'.format(line))
if class_name in result:
- raise ValueError(
- 'line {}: duplicate class name: \'{}\''.format(
- line, class_name))
+ raise ValueError('line {}: duplicate class name: \'{}\''.format(line, class_name))
result[class_name] = class_id
return result
@@ -439,10 +417,7 @@ def _init_loader(hparams: dict, TrainTransform=None) -> tuple:
epochs = hparams.task_config.classifier.epochs
no_cache_img = hparams.task_config.classifier.get("no_cache_img", False)
- normalize = {
- 'mean': [
- 0.485, 0.456, 0.406], 'std': [
- 0.229, 0.224, 0.225]}
+ normalize = {'mean': [0.485, 0.456, 0.406], 'std': [0.229, 0.224, 0.225]}
if TrainTransform is None:
TrainTransform = PbaAugment(
@@ -453,10 +428,7 @@ def _init_loader(hparams: dict, TrainTransform=None) -> tuple:
hp_policy_epochs=epochs,
)
delimiter = hparams.data_config.delimiter
- kwargs = dict(
- conf=hparams,
- delimiter=delimiter
- )
+ kwargs = dict(conf=hparams, delimiter=delimiter)
if hparams.task_config.classifier.use_class_map:
class_to_id_dict = _read_classes(label_list=hparams.data_config.label_list)
@@ -475,13 +447,11 @@ def _init_loader(hparams: dict, TrainTransform=None) -> tuple:
list_file=val_list,
transform=transforms.Compose(
transforms=[
- transforms.Resize(
- (224,
- 224)),
+ transforms.Resize((224, 224)),
transforms.Permute(),
- transforms.Normalize(
- **normalize, channel_first=True)],
- channel_first = False),
+ transforms.Normalize(**normalize, channel_first=True)
+ ],
+ channel_first=False),
class_to_id_dict=class_to_id_dict,
cache_img=not no_cache_img,
**kwargs)
diff --git a/demo/autoaug/paddlehub_utils/trainer.py b/demo/autoaug/paddlehub_utils/trainer.py
index c8e55a9b..1e26237c 100644
--- a/demo/autoaug/paddlehub_utils/trainer.py
+++ b/demo/autoaug/paddlehub_utils/trainer.py
@@ -18,25 +18,23 @@ from paddle.distributed import ParallelEnv
from paddlehub.utils.log import logger
from paddlehub.utils.utils import Timer
+
class CustomTrainer(Trainer):
def __init__(self, **kwargs) -> None:
super(CustomTrainer, self).__init__(**kwargs)
def init_train_and_eval(self,
- train_dataset: paddle.io.Dataset,
- epochs: int = 1,
- batch_size: int = 1,
- num_workers: int = 0,
- eval_dataset: paddle.io.Dataset = None,
- log_interval: int = 10,
- save_interval: int = 10) -> None:
+ train_dataset: paddle.io.Dataset,
+ epochs: int = 1,
+ batch_size: int = 1,
+ num_workers: int = 0,
+ eval_dataset: paddle.io.Dataset = None,
+ log_interval: int = 10,
+ save_interval: int = 10) -> None:
self.batch_sampler, self.train_loader = self.init_train(train_dataset, batch_size, num_workers)
self.eval_loader = self.init_evaluate(eval_dataset, batch_size, num_workers)
- def init_train(self,
- train_dataset: paddle.io.Dataset,
- batch_size: int = 1,
- num_workers: int = 0) -> tuple:
+ def init_train(self, train_dataset: paddle.io.Dataset, batch_size: int = 1, num_workers: int = 0) -> tuple:
use_gpu = True
place = paddle.CUDAPlace(ParallelEnv().dev_id) if use_gpu else paddle.CPUPlace()
paddle.disable_static(place)
@@ -47,7 +45,8 @@ class CustomTrainer(Trainer):
train_dataset, batch_sampler=batch_sampler, places=place, num_workers=num_workers, return_list=True)
return batch_sampler, loader
- def train_one_epoch(self, loader: paddle.io.DataLoader, timer: Timer, current_epoch: int, epochs: int, log_interval: int, steps_per_epoch: int) -> None:
+ def train_one_epoch(self, loader: paddle.io.DataLoader, timer: Timer, current_epoch: int, epochs: int,
+ log_interval: int, steps_per_epoch: int) -> None:
avg_loss = 0
avg_metrics = defaultdict(int)
self.model.train()
@@ -70,15 +69,13 @@ class CustomTrainer(Trainer):
if self.use_vdl:
self.log_writer.add_scalar(tag='TRAIN/loss', step=timer.current_step, value=avg_loss)
- print_msg = 'Epoch={}/{}, Step={}/{}'.format(current_epoch, epochs, batch_idx + 1,
- steps_per_epoch)
+ print_msg = 'Epoch={}/{}, Step={}/{}'.format(current_epoch, epochs, batch_idx + 1, steps_per_epoch)
print_msg += ' loss={:.4f}'.format(avg_loss)
for metric, value in avg_metrics.items():
value /= log_interval
if self.use_vdl:
- self.log_writer.add_scalar(
- tag='TRAIN/{}'.format(metric), step=timer.current_step, value=value)
+ self.log_writer.add_scalar(tag='TRAIN/{}'.format(metric), step=timer.current_step, value=value)
print_msg += ' {}={:.4f}'.format(metric, value)
print_msg += ' lr={:.6f} step/sec={:.2f} | ETA {}'.format(lr, timer.timing, timer.eta)
@@ -139,9 +136,7 @@ class CustomTrainer(Trainer):
self.save_model(best_model_path)
self._save_metrics()
- metric_msg = [
- '{}={:.4f}'.format(metric, value) for metric, value in self.best_metrics.items()
- ]
+ metric_msg = ['{}={:.4f}'.format(metric, value) for metric, value in self.best_metrics.items()]
metric_msg = ' '.join(metric_msg)
logger.eval('Saving best model to {} [best {}]'.format(best_model_path, metric_msg))
diff --git a/demo/autoaug/search.py b/demo/autoaug/search.py
index 4e6d290a..1169fb7c 100755
--- a/demo/autoaug/search.py
+++ b/demo/autoaug/search.py
@@ -1,4 +1,3 @@
-
from auto_augment.autoaug.experiment.experiment import AutoAugExperiment
from auto_augment.autoaug.utils.yaml_config import get_config
from hub_fitter import HubFitterClassifer
@@ -9,14 +8,21 @@ logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
parser = argparse.ArgumentParser()
-parser.add_argument("--config",help="config file",)
-parser.add_argument("--workspace",default=None, help="work_space",)
-
+parser.add_argument(
+ "--config",
+ help="config file",
+)
+parser.add_argument(
+ "--workspace",
+ default=None,
+ help="work_space",
+)
def main():
search_test()
+
def search_test():
args = parser.parse_args()
config = args.config
@@ -38,14 +44,13 @@ def search_test():
resource_config=resource_config,
data_config=data_config,
search_space=search_space,
- fitter=HubFitterClassifer
- )
+ fitter=HubFitterClassifer)
result = exper.search() # 开始搜索任务
policy = result.get_best_policy() # 最佳策略获取, policy格式见 搜索结果应用格式
print("policy is:{}".format(policy))
dump_path = os.path.join(workspace, "auto_aug_config.json")
- result.dump_best_policy(
- path=dump_path)
+ result.dump_best_policy(path=dump_path)
+
if __name__ == "__main__":
main()
diff --git a/demo/autoaug/train.py b/demo/autoaug/train.py
index 2b1f3d53..f35c8c33 100644
--- a/demo/autoaug/train.py
+++ b/demo/autoaug/train.py
@@ -24,9 +24,20 @@ logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
parser = argparse.ArgumentParser()
-parser.add_argument("--config",help="config file",)
-parser.add_argument("--workspace",default=None, help="work_space",)
-parser.add_argument("--policy",default=None, help="data aug policy",)
+parser.add_argument(
+ "--config",
+ help="config file",
+)
+parser.add_argument(
+ "--workspace",
+ default=None,
+ help="work_space",
+)
+parser.add_argument(
+ "--policy",
+ default=None,
+ help="data aug policy",
+)
if __name__ == '__main__':
args = parser.parse_args()
@@ -39,10 +50,7 @@ if __name__ == '__main__':
input_size = task_config.classifier.input_size
scale_size = task_config.classifier.scale_size
- normalize = {
- 'mean': [
- 0.485, 0.456, 0.406], 'std': [
- 0.229, 0.224, 0.225]}
+ normalize = {'mean': [0.485, 0.456, 0.406], 'std': [0.229, 0.224, 0.225]}
epochs = task_config.classifier.epochs
policy = args.policy
@@ -50,13 +58,11 @@ if __name__ == '__main__':
print("use normal train transform")
TrainTransform = transforms.Compose(
transforms=[
- transforms.Resize(
- (input_size,
- input_size)),
+ transforms.Resize((input_size, input_size)),
transforms.Permute(),
- transforms.Normalize(
- **normalize, channel_first=True)],
- channel_first = False)
+ transforms.Normalize(**normalize, channel_first=True)
+ ],
+ channel_first=False)
else:
TrainTransform = PbaAugment(
input_size=input_size,
@@ -64,17 +70,12 @@ if __name__ == '__main__':
normalize=normalize,
policy=policy,
hp_policy_epochs=epochs,
- stage="train"
- )
+ stage="train")
train_dataset, eval_dataset = _init_loader(config, TrainTransform=TrainTransform)
class_to_id_dict = _read_classes(config.data_config.label_list)
- model = hub.Module(name=config.task_config.classifier.model_name, label_list=class_to_id_dict.keys(), load_checkpoint=None)
+ model = hub.Module(
+ name=config.task_config.classifier.model_name, label_list=class_to_id_dict.keys(), load_checkpoint=None)
- optimizer = paddle.optimizer.Adam(
- learning_rate=0.001, parameters=model.parameters())
- trainer = CustomTrainer(
- model=model,
- optimizer=optimizer,
- checkpoint_dir='img_classification_ckpt')
+ optimizer = paddle.optimizer.Adam(learning_rate=0.001, parameters=model.parameters())
+ trainer = CustomTrainer(model=model, optimizer=optimizer, checkpoint_dir='img_classification_ckpt')
trainer.train(train_dataset, epochs=epochs, batch_size=32, eval_dataset=eval_dataset, save_interval=10)
-
diff --git a/demo/colorization/predict.py b/demo/colorization/predict.py
index 23041d3f..025363f4 100644
--- a/demo/colorization/predict.py
+++ b/demo/colorization/predict.py
@@ -4,4 +4,4 @@ import paddlehub as hub
if __name__ == '__main__':
model = hub.Module(name='user_guided_colorization', load_checkpoint='/PATH/TO/CHECKPOINT')
model.set_config(prob=0.1)
- result = model.predict(images=['house.png'])
\ No newline at end of file
+ result = model.predict(images=['house.png'])
diff --git a/demo/colorization/train.py b/demo/colorization/train.py
index 77aed92b..7a797419 100644
--- a/demo/colorization/train.py
+++ b/demo/colorization/train.py
@@ -6,9 +6,10 @@ from paddlehub.datasets import Canvas
if __name__ == '__main__':
- transform = T.Compose([T.Resize((256, 256), interpolation='NEAREST'),
- T.RandomPaddingCrop(crop_size=176),
- T.RGB2LAB()], to_rgb=True)
+ transform = T.Compose(
+ [T.Resize((256, 256), interpolation='NEAREST'),
+ T.RandomPaddingCrop(crop_size=176),
+ T.RGB2LAB()], to_rgb=True)
color_set = Canvas(transform=transform, mode='train')
model = hub.Module(name='user_guided_colorization', load_checkpoint='/PATH/TO/CHECKPOINT')
diff --git a/demo/semantic_segmentation/README.md b/demo/semantic_segmentation/README.md
index 7caf2ae8..e70fb3a7 100644
--- a/demo/semantic_segmentation/README.md
+++ b/demo/semantic_segmentation/README.md
@@ -56,7 +56,7 @@ trainer = Trainer(model, optimizer, checkpoint_dir='test_ckpt_img_ocr', use_gpu=
* `learning_rate`: 全局学习率。
* `parameters`: 待优化模型参数。
-
+
#### 运行配置
`Trainer` 主要控制Fine-tune的训练,包含以下可控制的参数:
@@ -159,5 +159,3 @@ https://github.com/PaddlePaddle/PaddleSeg
paddlepaddle >= 2.0.0
paddlehub >= 2.0.0
-
-
diff --git a/demo/semantic_segmentation/predict.py b/demo/semantic_segmentation/predict.py
index a991f48c..c8de5af1 100644
--- a/demo/semantic_segmentation/predict.py
+++ b/demo/semantic_segmentation/predict.py
@@ -3,4 +3,4 @@ import paddlehub as hub
if __name__ == '__main__':
model = hub.Module(name='ocrnet_hrnetw18_voc', num_classes=2, pretrained='/PATH/TO/CHECKPOINT')
- model.predict(images=["N0007.jpg"], visualization=True)
\ No newline at end of file
+ model.predict(images=["N0007.jpg"], visualization=True)
diff --git a/demo/sequence_labeling/predict.py b/demo/sequence_labeling/predict.py
index 13a5e505..4e291348 100644
--- a/demo/sequence_labeling/predict.py
+++ b/demo/sequence_labeling/predict.py
@@ -24,9 +24,7 @@ if __name__ == '__main__':
'华裔作家韩素音女士曾三次到大足,称“大足石窟是一座未被开发的金矿”。',
]
data = [[split_char.join(text)] for text in text_a]
- label_map = {
- idx: label for idx, label in enumerate(label_list)
- }
+ label_map = {idx: label for idx, label in enumerate(label_list)}
model = hub.Module(
name='ernie_tiny',
@@ -39,4 +37,3 @@ if __name__ == '__main__':
results = model.predict(data=data, max_seq_len=128, batch_size=1, use_gpu=True)
for idx, text in enumerate(text_a):
print(f'Text:\n{text} \nLable: \n{", ".join(results[idx][1:len(text)+1])} \n')
-
diff --git a/demo/sequence_labeling/train.py b/demo/sequence_labeling/train.py
index b9acbf0a..6db38c9a 100644
--- a/demo/sequence_labeling/train.py
+++ b/demo/sequence_labeling/train.py
@@ -21,7 +21,11 @@ import argparse
parser = argparse.ArgumentParser(__doc__)
parser.add_argument("--num_epoch", type=int, default=3, help="Number of epoches for fine-tuning.")
-parser.add_argument("--use_gpu", type=ast.literal_eval, default=True, help="Whether use GPU for fine-tuning, input should be True or False")
+parser.add_argument(
+ "--use_gpu",
+ type=ast.literal_eval,
+ default=True,
+ help="Whether use GPU for fine-tuning, input should be True or False")
parser.add_argument("--learning_rate", type=float, default=5e-5, help="Learning rate used to train with warmup.")
parser.add_argument("--max_seq_len", type=int, default=128, help="Number of words of the longest seqence.")
parser.add_argument("--batch_size", type=int, default=32, help="Total examples' number in batch for training.")
@@ -30,36 +34,21 @@ parser.add_argument("--save_interval", type=int, default=1, help="Save checkpoin
args = parser.parse_args()
-
if __name__ == '__main__':
label_list = MSRA_NER.label_list
- label_map = {
- idx: label for idx, label in enumerate(label_list)
- }
+ label_map = {idx: label for idx, label in enumerate(label_list)}
model = hub.Module(
name='ernie_tiny',
version='2.0.1',
task='token-cls',
- label_map=label_map, # Required for token classification task
+ label_map=label_map, # Required for token classification task
)
tokenizer = model.get_tokenizer()
- train_dataset = MSRA_NER(
- tokenizer=tokenizer,
- max_seq_len=args.max_seq_len,
- mode='train'
- )
- dev_dataset = MSRA_NER(
- tokenizer=tokenizer,
- max_seq_len=args.max_seq_len,
- mode='dev'
- )
- test_dataset = MSRA_NER(
- tokenizer=tokenizer,
- max_seq_len=args.max_seq_len,
- mode='test'
- )
+ train_dataset = MSRA_NER(tokenizer=tokenizer, max_seq_len=args.max_seq_len, mode='train')
+ dev_dataset = MSRA_NER(tokenizer=tokenizer, max_seq_len=args.max_seq_len, mode='dev')
+ test_dataset = MSRA_NER(tokenizer=tokenizer, max_seq_len=args.max_seq_len, mode='test')
optimizer = paddle.optimizer.AdamW(learning_rate=args.learning_rate, parameters=model.parameters())
trainer = hub.Trainer(model, optimizer, checkpoint_dir=args.checkpoint_dir, use_gpu=args.use_gpu)
diff --git a/demo/style_transfer/README.md b/demo/style_transfer/README.md
index 7b737129..d0518489 100644
--- a/demo/style_transfer/README.md
+++ b/demo/style_transfer/README.md
@@ -61,7 +61,7 @@ Paddle2.0rc提供了多种优化器选择,如`SGD`, `Adam`, `Adamax`等,详
* `learning_rate`: 全局学习率。默认为1e-4;
* `parameters`: 待优化模型参数。
-
+
#### 运行配置
`Trainer` 主要控制Fine-tune的训练,包含以下可控制的参数:
diff --git a/demo/style_transfer/predict.py b/demo/style_transfer/predict.py
index 7a8e9344..4714bce3 100644
--- a/demo/style_transfer/predict.py
+++ b/demo/style_transfer/predict.py
@@ -3,4 +3,4 @@ import paddlehub as hub
if __name__ == '__main__':
model = hub.Module(name='msgnet', load_checkpoint="/PATH/TO/CHECKPOINT")
- result = model.predict(origin=["venice-boat.jpg"], style="candy.jpg", visualization=True, save_path ='style_tranfer')
\ No newline at end of file
+ result = model.predict(origin=["venice-boat.jpg"], style="candy.jpg", visualization=True, save_path='style_tranfer')
diff --git a/demo/style_transfer/train.py b/demo/style_transfer/train.py
index 54ee0fda..ae46c36c 100644
--- a/demo/style_transfer/train.py
+++ b/demo/style_transfer/train.py
@@ -11,4 +11,4 @@ if __name__ == "__main__":
styledata = MiniCOCO(transform)
optimizer = paddle.optimizer.Adam(learning_rate=0.0001, parameters=model.parameters())
trainer = Trainer(model, optimizer, checkpoint_dir='test_style_ckpt')
- trainer.train(styledata, epochs=101, batch_size=4, log_interval=10, save_interval=10)
\ No newline at end of file
+ trainer.train(styledata, epochs=101, batch_size=4, log_interval=10, save_interval=10)
diff --git a/demo/text_classification/README.md b/demo/text_classification/README.md
index 4d0de6e4..904349a8 100644
--- a/demo/text_classification/README.md
+++ b/demo/text_classification/README.md
@@ -166,4 +166,3 @@ for idx, text in enumerate(data):
```
参数配置正确后,请执行脚本`python predict.py`, 加载模型具体可参见[加载](https://www.paddlepaddle.org.cn/documentation/docs/zh/2.0-rc/api/paddle/framework/io/load_cn.html#load)。
-
diff --git a/demo/text_classification/embedding/predict.py b/demo/text_classification/embedding/predict.py
index 18f90ee2..344475e8 100644
--- a/demo/text_classification/embedding/predict.py
+++ b/demo/text_classification/embedding/predict.py
@@ -19,17 +19,19 @@ from model import BoWModel
import ast
import argparse
-
parser = argparse.ArgumentParser(__doc__)
parser.add_argument("--hub_embedding_name", type=str, default='w2v_baidu_encyclopedia_target_word-word_dim300', help="")
parser.add_argument("--max_seq_len", type=int, default=128, help="Number of words of the longest seqence.")
parser.add_argument("--batch_size", type=int, default=64, help="Total examples' number in batch for training.")
parser.add_argument("--checkpoint", type=str, default='./checkpoint/best_model/model.pdparams', help="Model checkpoint")
-parser.add_argument("--use_gpu", type=ast.literal_eval, default=True, help="Whether use GPU for fine-tuning, input should be True or False")
+parser.add_argument(
+ "--use_gpu",
+ type=ast.literal_eval,
+ default=True,
+ help="Whether use GPU for fine-tuning, input should be True or False")
args = parser.parse_args()
-
if __name__ == '__main__':
# Data to be prdicted
data = [
@@ -44,12 +46,9 @@ if __name__ == '__main__':
embedder = hub.Module(name=args.hub_embedding_name)
tokenizer = embedder.get_tokenizer()
- model = BoWModel(
- embedder=embedder,
- tokenizer=tokenizer,
- load_checkpoint=args.checkpoint,
- label_map=label_map)
+ model = BoWModel(embedder=embedder, tokenizer=tokenizer, load_checkpoint=args.checkpoint, label_map=label_map)
- results = model.predict(data, max_seq_len=args.max_seq_len, batch_size=args.batch_size, use_gpu=args.use_gpu, return_result=False)
+ results = model.predict(
+ data, max_seq_len=args.max_seq_len, batch_size=args.batch_size, use_gpu=args.use_gpu, return_result=False)
for idx, text in enumerate(data):
- print('Data: {} \t Lable: {}'.format(text[0], results[idx]))
+ print('Data: {} \t Lable: {}'.format(text[0], results[idx]))
diff --git a/demo/text_classification/embedding/train.py b/demo/text_classification/embedding/train.py
index ee7bbaa9..cddb464b 100644
--- a/demo/text_classification/embedding/train.py
+++ b/demo/text_classification/embedding/train.py
@@ -21,7 +21,6 @@ from model import BoWModel
import ast
import argparse
-
parser = argparse.ArgumentParser(__doc__)
parser.add_argument("--hub_embedding_name", type=str, default='w2v_baidu_encyclopedia_target_word-word_dim300', help="")
parser.add_argument("--num_epoch", type=int, default=10, help="Number of epoches for fine-tuning.")
@@ -30,11 +29,14 @@ parser.add_argument("--max_seq_len", type=int, default=128, help="Number of word
parser.add_argument("--batch_size", type=int, default=64, help="Total examples' number in batch for training.")
parser.add_argument("--checkpoint_dir", type=str, default='./checkpoint', help="Directory to model checkpoint")
parser.add_argument("--save_interval", type=int, default=5, help="Save checkpoint every n epoch.")
-parser.add_argument("--use_gpu", type=ast.literal_eval, default=True, help="Whether use GPU for fine-tuning, input should be True or False")
+parser.add_argument(
+ "--use_gpu",
+ type=ast.literal_eval,
+ default=True,
+ help="Whether use GPU for fine-tuning, input should be True or False")
args = parser.parse_args()
-
if __name__ == '__main__':
embedder = hub.Module(name=args.hub_embedding_name)
tokenizer = embedder.get_tokenizer()
@@ -44,8 +46,7 @@ if __name__ == '__main__':
test_dataset = ChnSentiCorp(tokenizer=tokenizer, max_seq_len=args.max_seq_len, mode='test')
model = BoWModel(embedder=embedder)
- optimizer = paddle.optimizer.AdamW(
- learning_rate=args.learning_rate, parameters=model.parameters())
+ optimizer = paddle.optimizer.AdamW(learning_rate=args.learning_rate, parameters=model.parameters())
trainer = hub.Trainer(model, optimizer, checkpoint_dir=args.checkpoint_dir, use_gpu=args.use_gpu)
trainer.train(
train_dataset,
diff --git a/demo/text_classification/train.py b/demo/text_classification/train.py
index ad4075c3..f54001c0 100644
--- a/demo/text_classification/train.py
+++ b/demo/text_classification/train.py
@@ -21,7 +21,11 @@ import argparse
parser = argparse.ArgumentParser(__doc__)
parser.add_argument("--num_epoch", type=int, default=3, help="Number of epoches for fine-tuning.")
-parser.add_argument("--use_gpu", type=ast.literal_eval, default=True, help="Whether use GPU for fine-tuning, input should be True or False")
+parser.add_argument(
+ "--use_gpu",
+ type=ast.literal_eval,
+ default=True,
+ help="Whether use GPU for fine-tuning, input should be True or False")
parser.add_argument("--learning_rate", type=float, default=5e-5, help="Learning rate used to train with warmup.")
parser.add_argument("--max_seq_len", type=int, default=128, help="Number of words of the longest seqence.")
parser.add_argument("--batch_size", type=int, default=32, help="Total examples' number in batch for training.")
@@ -33,15 +37,11 @@ args = parser.parse_args()
if __name__ == '__main__':
model = hub.Module(name='ernie_tiny', version='2.0.1', task='seq-cls')
- train_dataset = ChnSentiCorp(
- tokenizer=model.get_tokenizer(), max_seq_len=args.max_seq_len, mode='train')
- dev_dataset = ChnSentiCorp(
- tokenizer=model.get_tokenizer(), max_seq_len=args.max_seq_len, mode='dev')
- test_dataset = ChnSentiCorp(
- tokenizer=model.get_tokenizer(), max_seq_len=args.max_seq_len, mode='test')
+ train_dataset = ChnSentiCorp(tokenizer=model.get_tokenizer(), max_seq_len=args.max_seq_len, mode='train')
+ dev_dataset = ChnSentiCorp(tokenizer=model.get_tokenizer(), max_seq_len=args.max_seq_len, mode='dev')
+ test_dataset = ChnSentiCorp(tokenizer=model.get_tokenizer(), max_seq_len=args.max_seq_len, mode='test')
- optimizer = paddle.optimizer.AdamW(
- learning_rate=args.learning_rate, parameters=model.parameters())
+ optimizer = paddle.optimizer.AdamW(learning_rate=args.learning_rate, parameters=model.parameters())
trainer = hub.Trainer(model, optimizer, checkpoint_dir=args.checkpoint_dir, use_gpu=args.use_gpu)
trainer.train(
train_dataset,
diff --git a/demo/text_matching/train.py b/demo/text_matching/train.py
index ddbebb32..e5295bdc 100644
--- a/demo/text_matching/train.py
+++ b/demo/text_matching/train.py
@@ -21,7 +21,11 @@ import argparse
parser = argparse.ArgumentParser(__doc__)
parser.add_argument("--num_epoch", type=int, default=10, help="Number of epoches for fine-tuning.")
-parser.add_argument("--use_gpu", type=ast.literal_eval, default=True, help="Whether use GPU for fine-tuning, input should be True or False")
+parser.add_argument(
+ "--use_gpu",
+ type=ast.literal_eval,
+ default=True,
+ help="Whether use GPU for fine-tuning, input should be True or False")
parser.add_argument("--learning_rate", type=float, default=5e-5, help="Learning rate used to train with warmup.")
parser.add_argument("--max_seq_len", type=int, default=64, help="Number of words of the longest seqence.")
parser.add_argument("--batch_size", type=int, default=128, help="Total examples' number in batch for training.")
@@ -38,8 +42,7 @@ if __name__ == '__main__':
dev_dataset = LCQMC(tokenizer=tokenizer, max_seq_len=args.max_seq_len, mode='dev')
test_dataset = LCQMC(tokenizer=tokenizer, max_seq_len=args.max_seq_len, mode='test')
- optimizer = paddle.optimizer.AdamW(
- learning_rate=args.learning_rate, parameters=model.parameters())
+ optimizer = paddle.optimizer.AdamW(learning_rate=args.learning_rate, parameters=model.parameters())
trainer = hub.Trainer(model, optimizer, checkpoint_dir=args.checkpoint_dir, use_gpu=args.use_gpu)
trainer.train(
train_dataset,
diff --git a/docs/docs_ch/figures.md b/docs/docs_ch/figures.md
index 1a413526..883099f0 100644
--- a/docs/docs_ch/figures.md
+++ b/docs/docs_ch/figures.md
@@ -93,6 +93,3 @@ $ hub serving start -m chinese_ocr_db_crnn_mobile
* 如需在线快速体验,请点击[PaddleHub教程合集](https://aistudio.baidu.com/aistudio/projectdetail/231146),可使用AI Studio平台提供的GPU算力进行快速尝试。
-
-
-
diff --git a/modules/audio/audio_classification/PANNs/cnn10/module.py b/modules/audio/audio_classification/PANNs/cnn10/module.py
index bcbd3515..4a45bbe8 100644
--- a/modules/audio/audio_classification/PANNs/cnn10/module.py
+++ b/modules/audio/audio_classification/PANNs/cnn10/module.py
@@ -27,21 +27,22 @@ from paddlehub.module.module import moduleinfo
from paddlehub.utils.log import logger
-@moduleinfo(name="panns_cnn10",
- version="1.0.0",
- summary="",
- author="Baidu",
- author_email="",
- type="audio/sound_classification",
- meta=AudioClassifierModule)
+@moduleinfo(
+ name="panns_cnn10",
+ version="1.0.0",
+ summary="",
+ author="Baidu",
+ author_email="",
+ type="audio/sound_classification",
+ meta=AudioClassifierModule)
class PANN(nn.Layer):
def __init__(
- self,
- task: str,
- num_class: int = None,
- label_map: Dict = None,
- load_checkpoint: str = None,
- **kwargs,
+ self,
+ task: str,
+ num_class: int = None,
+ label_map: Dict = None,
+ load_checkpoint: str = None,
+ **kwargs,
):
super(PANN, self).__init__()
@@ -52,15 +53,15 @@ class PANN(nn.Layer):
self.num_class = num_class
if task == 'sound-cls':
- self.cnn10 = CNN10(extract_embedding=True,
- checkpoint=os.path.join(MODULE_HOME, 'panns_cnn10', 'cnn10.pdparams'))
+ self.cnn10 = CNN10(
+ extract_embedding=True, checkpoint=os.path.join(MODULE_HOME, 'panns_cnn10', 'cnn10.pdparams'))
self.dropout = nn.Dropout(0.1)
self.fc = nn.Linear(self.cnn10.emb_size, num_class)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
else:
- self.cnn10 = CNN10(extract_embedding=False,
- checkpoint=os.path.join(MODULE_HOME, 'panns_cnn10', 'cnn10.pdparams'))
+ self.cnn10 = CNN10(
+ extract_embedding=False, checkpoint=os.path.join(MODULE_HOME, 'panns_cnn10', 'cnn10.pdparams'))
self.task = task
if load_checkpoint is not None and os.path.isfile(load_checkpoint):
diff --git a/modules/audio/audio_classification/PANNs/cnn10/network.py b/modules/audio/audio_classification/PANNs/cnn10/network.py
index 79800384..959f40cf 100644
--- a/modules/audio/audio_classification/PANNs/cnn10/network.py
+++ b/modules/audio/audio_classification/PANNs/cnn10/network.py
@@ -25,18 +25,20 @@ class ConvBlock(nn.Layer):
def __init__(self, in_channels, out_channels):
super(ConvBlock, self).__init__()
- self.conv1 = nn.Conv2D(in_channels=in_channels,
- out_channels=out_channels,
- kernel_size=(3, 3),
- stride=(1, 1),
- padding=(1, 1),
- bias_attr=False)
- self.conv2 = nn.Conv2D(in_channels=out_channels,
- out_channels=out_channels,
- kernel_size=(3, 3),
- stride=(1, 1),
- padding=(1, 1),
- bias_attr=False)
+ self.conv1 = nn.Conv2D(
+ in_channels=in_channels,
+ out_channels=out_channels,
+ kernel_size=(3, 3),
+ stride=(1, 1),
+ padding=(1, 1),
+ bias_attr=False)
+ self.conv2 = nn.Conv2D(
+ in_channels=out_channels,
+ out_channels=out_channels,
+ kernel_size=(3, 3),
+ stride=(1, 1),
+ padding=(1, 1),
+ bias_attr=False)
self.bn1 = nn.BatchNorm2D(out_channels)
self.bn2 = nn.BatchNorm2D(out_channels)
diff --git a/modules/audio/audio_classification/PANNs/cnn14/module.py b/modules/audio/audio_classification/PANNs/cnn14/module.py
index f558d6f7..eb0efc31 100644
--- a/modules/audio/audio_classification/PANNs/cnn14/module.py
+++ b/modules/audio/audio_classification/PANNs/cnn14/module.py
@@ -27,21 +27,22 @@ from paddlehub.module.module import moduleinfo
from paddlehub.utils.log import logger
-@moduleinfo(name="panns_cnn14",
- version="1.0.0",
- summary="",
- author="Baidu",
- author_email="",
- type="audio/sound_classification",
- meta=AudioClassifierModule)
+@moduleinfo(
+ name="panns_cnn14",
+ version="1.0.0",
+ summary="",
+ author="Baidu",
+ author_email="",
+ type="audio/sound_classification",
+ meta=AudioClassifierModule)
class PANN(nn.Layer):
def __init__(
- self,
- task: str,
- num_class: int = None,
- label_map: Dict = None,
- load_checkpoint: str = None,
- **kwargs,
+ self,
+ task: str,
+ num_class: int = None,
+ label_map: Dict = None,
+ load_checkpoint: str = None,
+ **kwargs,
):
super(PANN, self).__init__()
@@ -52,15 +53,15 @@ class PANN(nn.Layer):
self.num_class = num_class
if task == 'sound-cls':
- self.cnn14 = CNN14(extract_embedding=True,
- checkpoint=os.path.join(MODULE_HOME, 'panns_cnn14', 'cnn14.pdparams'))
+ self.cnn14 = CNN14(
+ extract_embedding=True, checkpoint=os.path.join(MODULE_HOME, 'panns_cnn14', 'cnn14.pdparams'))
self.dropout = nn.Dropout(0.1)
self.fc = nn.Linear(self.cnn14.emb_size, num_class)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
else:
- self.cnn14 = CNN14(extract_embedding=False,
- checkpoint=os.path.join(MODULE_HOME, 'panns_cnn14', 'cnn14.pdparams'))
+ self.cnn14 = CNN14(
+ extract_embedding=False, checkpoint=os.path.join(MODULE_HOME, 'panns_cnn14', 'cnn14.pdparams'))
self.task = task
if load_checkpoint is not None and os.path.isfile(load_checkpoint):
diff --git a/modules/audio/audio_classification/PANNs/cnn14/network.py b/modules/audio/audio_classification/PANNs/cnn14/network.py
index 4342a7cf..e8062566 100644
--- a/modules/audio/audio_classification/PANNs/cnn14/network.py
+++ b/modules/audio/audio_classification/PANNs/cnn14/network.py
@@ -25,18 +25,20 @@ class ConvBlock(nn.Layer):
def __init__(self, in_channels, out_channels):
super(ConvBlock, self).__init__()
- self.conv1 = nn.Conv2D(in_channels=in_channels,
- out_channels=out_channels,
- kernel_size=(3, 3),
- stride=(1, 1),
- padding=(1, 1),
- bias_attr=False)
- self.conv2 = nn.Conv2D(in_channels=out_channels,
- out_channels=out_channels,
- kernel_size=(3, 3),
- stride=(1, 1),
- padding=(1, 1),
- bias_attr=False)
+ self.conv1 = nn.Conv2D(
+ in_channels=in_channels,
+ out_channels=out_channels,
+ kernel_size=(3, 3),
+ stride=(1, 1),
+ padding=(1, 1),
+ bias_attr=False)
+ self.conv2 = nn.Conv2D(
+ in_channels=out_channels,
+ out_channels=out_channels,
+ kernel_size=(3, 3),
+ stride=(1, 1),
+ padding=(1, 1),
+ bias_attr=False)
self.bn1 = nn.BatchNorm2D(out_channels)
self.bn2 = nn.BatchNorm2D(out_channels)
diff --git a/modules/audio/audio_classification/PANNs/cnn6/module.py b/modules/audio/audio_classification/PANNs/cnn6/module.py
index 7c8b8718..360cccf2 100644
--- a/modules/audio/audio_classification/PANNs/cnn6/module.py
+++ b/modules/audio/audio_classification/PANNs/cnn6/module.py
@@ -27,21 +27,22 @@ from paddlehub.module.module import moduleinfo
from paddlehub.utils.log import logger
-@moduleinfo(name="panns_cnn6",
- version="1.0.0",
- summary="",
- author="Baidu",
- author_email="",
- type="audio/sound_classification",
- meta=AudioClassifierModule)
+@moduleinfo(
+ name="panns_cnn6",
+ version="1.0.0",
+ summary="",
+ author="Baidu",
+ author_email="",
+ type="audio/sound_classification",
+ meta=AudioClassifierModule)
class PANN(nn.Layer):
def __init__(
- self,
- task: str,
- num_class: int = None,
- label_map: Dict = None,
- load_checkpoint: str = None,
- **kwargs,
+ self,
+ task: str,
+ num_class: int = None,
+ label_map: Dict = None,
+ load_checkpoint: str = None,
+ **kwargs,
):
super(PANN, self).__init__()
@@ -52,15 +53,15 @@ class PANN(nn.Layer):
self.num_class = num_class
if task == 'sound-cls':
- self.cnn6 = CNN6(extract_embedding=True,
- checkpoint=os.path.join(MODULE_HOME, 'panns_cnn6', 'cnn6.pdparams'))
+ self.cnn6 = CNN6(
+ extract_embedding=True, checkpoint=os.path.join(MODULE_HOME, 'panns_cnn6', 'cnn6.pdparams'))
self.dropout = nn.Dropout(0.1)
self.fc = nn.Linear(self.cnn6.emb_size, num_class)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
else:
- self.cnn6 = CNN6(extract_embedding=False,
- checkpoint=os.path.join(MODULE_HOME, 'panns_cnn6', 'cnn6.pdparams'))
+ self.cnn6 = CNN6(
+ extract_embedding=False, checkpoint=os.path.join(MODULE_HOME, 'panns_cnn6', 'cnn6.pdparams'))
self.task = task
if load_checkpoint is not None and os.path.isfile(load_checkpoint):
diff --git a/modules/audio/audio_classification/PANNs/cnn6/network.py b/modules/audio/audio_classification/PANNs/cnn6/network.py
index 1f7c005d..88fadaad 100644
--- a/modules/audio/audio_classification/PANNs/cnn6/network.py
+++ b/modules/audio/audio_classification/PANNs/cnn6/network.py
@@ -25,12 +25,13 @@ class ConvBlock5x5(nn.Layer):
def __init__(self, in_channels, out_channels):
super(ConvBlock5x5, self).__init__()
- self.conv1 = nn.Conv2D(in_channels=in_channels,
- out_channels=out_channels,
- kernel_size=(5, 5),
- stride=(1, 1),
- padding=(2, 2),
- bias_attr=False)
+ self.conv1 = nn.Conv2D(
+ in_channels=in_channels,
+ out_channels=out_channels,
+ kernel_size=(5, 5),
+ stride=(1, 1),
+ padding=(2, 2),
+ bias_attr=False)
self.bn1 = nn.BatchNorm2D(out_channels)
def forward(self, x, pool_size=(2, 2), pool_type='avg'):
diff --git a/modules/image/Image_editing/colorization/user_guided_colorization/data_feed.py b/modules/image/Image_editing/colorization/user_guided_colorization/data_feed.py
index 2efe9478..0c628eb1 100644
--- a/modules/image/Image_editing/colorization/user_guided_colorization/data_feed.py
+++ b/modules/image/Image_editing/colorization/user_guided_colorization/data_feed.py
@@ -18,6 +18,7 @@ class ColorizeHint:
hint(np.ndarray): hint images
mask(np.ndarray): mask images
"""
+
def __init__(self, percent: float, num_points: int = None, samp: str = 'normal', use_avg: bool = True):
self.percent = percent
self.num_points = num_points
@@ -52,11 +53,9 @@ class ColorizeHint:
# add color point
if self.use_avg:
# embed()
- hint[nn, :, h:h + P, w:w + P] = np.mean(np.mean(data[nn, :, h:h + P, w:w + P],
- axis=2,
- keepdims=True),
- axis=1,
- keepdims=True).reshape(1, C, 1, 1)
+ hint[nn, :, h:h + P, w:w + P] = np.mean(
+ np.mean(data[nn, :, h:h + P, w:w + P], axis=2, keepdims=True), axis=1, keepdims=True).reshape(
+ 1, C, 1, 1)
else:
hint[nn, :, h:h + P, w:w + P] = data[nn, :, h:h + P, w:w + P]
mask[nn, :, h:h + P, w:w + P] = 1
@@ -82,6 +81,7 @@ class ColorizePreprocess:
data(dict):The preprocessed data for colorization.
"""
+
def __init__(self,
ab_thresh: float = 0.,
p: float = 0.,
@@ -113,8 +113,8 @@ class ColorizePreprocess:
data['B'] = data_lab[:, 1:, :, :]
if self.ab_thresh > 0: # mask out grayscale images
thresh = 1. * self.ab_thresh / 110
- mask = np.sum(np.abs(np.max(np.max(data['B'], axis=3), axis=2) - np.min(np.min(data['B'], axis=3), axis=2)),
- axis=1)
+ mask = np.sum(
+ np.abs(np.max(np.max(data['B'], axis=3), axis=2) - np.min(np.min(data['B'], axis=3), axis=2)), axis=1)
mask = (mask >= thresh)
data['A'] = data['A'][mask, :, :, :]
data['B'] = data['B'][mask, :, :, :]
diff --git a/modules/image/Image_editing/colorization/user_guided_colorization/module.py b/modules/image/Image_editing/colorization/user_guided_colorization/module.py
index 13b75c35..c74bdf8d 100644
--- a/modules/image/Image_editing/colorization/user_guided_colorization/module.py
+++ b/modules/image/Image_editing/colorization/user_guided_colorization/module.py
@@ -40,6 +40,7 @@ class UserGuidedColorization(nn.Layer):
load_checkpoint (str): Pretrained checkpoint path.
"""
+
def __init__(self, use_tanh: bool = True, load_checkpoint: str = None):
super(UserGuidedColorization, self).__init__()
self.input_nc = 4
diff --git a/modules/image/Image_gan/style_transfer/msgnet/module.py b/modules/image/Image_gan/style_transfer/msgnet/module.py
index 4230d11a..c8068c6d 100644
--- a/modules/image/Image_gan/style_transfer/msgnet/module.py
+++ b/modules/image/Image_gan/style_transfer/msgnet/module.py
@@ -14,6 +14,7 @@ from paddlehub.module.cv_module import StyleTransferModule
class GramMatrix(nn.Layer):
"""Calculate gram matrix"""
+
def forward(self, y):
(b, ch, h, w) = y.shape
features = y.reshape((b, ch, w * h))
@@ -24,6 +25,7 @@ class GramMatrix(nn.Layer):
class ConvLayer(nn.Layer):
"""Basic conv layer with reflection padding layer"""
+
def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int):
super(ConvLayer, self).__init__()
pad = int(np.floor(kernel_size / 2))
@@ -51,6 +53,7 @@ class UpsampleConvLayer(nn.Layer):
Return:
img(paddle.Tensor): UpsampleConvLayer output.
"""
+
def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int, upsample=None):
super(UpsampleConvLayer, self).__init__()
self.upsample = upsample
@@ -85,6 +88,7 @@ class Bottleneck(nn.Layer):
Return:
img(paddle.Tensor): Bottleneck output.
"""
+
def __init__(self,
inplanes: int,
planes: int,
@@ -98,8 +102,8 @@ class Bottleneck(nn.Layer):
self.residual_layer = nn.Conv2D(inplanes, planes * self.expansion, kernel_size=1, stride=stride)
conv_block = (norm_layer(inplanes), nn.ReLU(), nn.Conv2D(inplanes, planes, kernel_size=1, stride=1),
norm_layer(planes), nn.ReLU(), ConvLayer(planes, planes, kernel_size=3, stride=stride),
- norm_layer(planes), nn.ReLU(), nn.Conv2D(planes, planes * self.expansion, kernel_size=1,
- stride=1))
+ norm_layer(planes), nn.ReLU(), nn.Conv2D(
+ planes, planes * self.expansion, kernel_size=1, stride=1))
self.conv_block = nn.Sequential(*conv_block)
def forward(self, x: paddle.Tensor):
@@ -125,14 +129,12 @@ class UpBottleneck(nn.Layer):
Return:
img(paddle.Tensor): UpBottleneck output.
"""
+
def __init__(self, inplanes: int, planes: int, stride: int = 2, norm_layer: nn.Layer = nn.BatchNorm2D):
super(UpBottleneck, self).__init__()
self.expansion = 4
- self.residual_layer = UpsampleConvLayer(inplanes,
- planes * self.expansion,
- kernel_size=1,
- stride=1,
- upsample=stride)
+ self.residual_layer = UpsampleConvLayer(
+ inplanes, planes * self.expansion, kernel_size=1, stride=1, upsample=stride)
conv_block = []
conv_block += [norm_layer(inplanes), nn.ReLU(), nn.Conv2D(inplanes, planes, kernel_size=1, stride=1)]
conv_block += [
@@ -163,6 +165,7 @@ class Inspiration(nn.Layer):
Return:
img(paddle.Tensor): UpBottleneck output.
"""
+
def __init__(self, C: int, B: int = 1):
super(Inspiration, self).__init__()
@@ -179,8 +182,8 @@ class Inspiration(nn.Layer):
self.P = paddle.bmm(self.weight.expand_as(self.G), self.G)
x = paddle.bmm(
- self.P.transpose((0, 2, 1)).expand((X.shape[0], self.C, self.C)), X.reshape(
- (X.shape[0], X.shape[1], -1))).reshape(X.shape)
+ self.P.transpose((0, 2, 1)).expand((X.shape[0], self.C, self.C)), X.reshape((X.shape[0], X.shape[1],
+ -1))).reshape(X.shape)
return x
def __repr__(self):
@@ -190,6 +193,7 @@ class Inspiration(nn.Layer):
class Vgg16(nn.Layer):
""" First four layers from Vgg16."""
+
def __init__(self):
super(Vgg16, self).__init__()
self.conv1_1 = nn.Conv2D(3, 64, kernel_size=3, stride=1, padding=1)
@@ -264,12 +268,8 @@ class MSGNet(nn.Layer):
Return:
img(paddle.Tensor): MSGNet output.
"""
- def __init__(self,
- input_nc=3,
- output_nc=3,
- ngf=128,
- n_blocks=6,
- norm_layer=nn.InstanceNorm2D,
+
+ def __init__(self, input_nc=3, output_nc=3, ngf=128, n_blocks=6, norm_layer=nn.InstanceNorm2D,
load_checkpoint=None):
super(MSGNet, self).__init__()
self.gram = GramMatrix()
diff --git a/modules/image/classification/resnet50_vd_imagenet_ssld/label_list.txt b/modules/image/classification/resnet50_vd_imagenet_ssld/label_list.txt
index ec7b4903..52baabc6 100644
--- a/modules/image/classification/resnet50_vd_imagenet_ssld/label_list.txt
+++ b/modules/image/classification/resnet50_vd_imagenet_ssld/label_list.txt
@@ -997,4 +997,4 @@ earthstar
hen-of-the-woods
bolete
ear
-toilet tissue
\ No newline at end of file
+toilet tissue
diff --git a/modules/image/classification/resnet50_vd_imagenet_ssld/module.py b/modules/image/classification/resnet50_vd_imagenet_ssld/module.py
index 40e750aa..c5bb6f63 100644
--- a/modules/image/classification/resnet50_vd_imagenet_ssld/module.py
+++ b/modules/image/classification/resnet50_vd_imagenet_ssld/module.py
@@ -193,8 +193,8 @@ class ResNet50_vd(nn.Layer):
label_list = []
label_file = os.path.join(self.directory, 'label_list.txt')
files = open(label_file)
- for line in files.readlines():
- line=line.strip('\n')
+ for line in files.readlines():
+ line = line.strip('\n')
label_list.append(line)
self.labels = label_list
class_dim = len(self.labels)
@@ -246,9 +246,14 @@ class ResNet50_vd(nn.Layer):
self.model_dict = paddle.load(checkpoint)
self.set_dict(self.model_dict)
print("load pretrained checkpoint success")
-
+
def transforms(self, images: Union[str, np.ndarray]):
- transforms = T.Compose([T.Resize((256, 256)), T.CenterCrop(224), T.Normalize(mean=[0.485, 0.456, 0.406], std = [0.229, 0.224, 0.225])], to_rgb=True)
+ transforms = T.Compose([
+ T.Resize((256, 256)),
+ T.CenterCrop(224),
+ T.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
+ ],
+ to_rgb=True)
return transforms(images)
def forward(self, inputs: paddle.Tensor):
@@ -261,4 +266,4 @@ class ResNet50_vd(nn.Layer):
feature = self.pool2d_avg(y)
y = paddle.reshape(feature, shape=[-1, self.pool2d_avg_channels])
y = self.out(y)
- return y, feature
\ No newline at end of file
+ return y, feature
diff --git a/modules/image/industrial_application/meter_readings/barometer_reader/README.md b/modules/image/industrial_application/meter_readings/barometer_reader/README.md
index dc117833..aa66c33d 100644
--- a/modules/image/industrial_application/meter_readings/barometer_reader/README.md
+++ b/modules/image/industrial_application/meter_readings/barometer_reader/README.md
@@ -12,13 +12,13 @@ $ hub run barometer_reader --input_path "/PATH/TO/IMAGE"
## API
```python
-def predict(self,
- im_file: Union[str, np.ndarray],
- score_threshold: float = 0.5,
- seg_batch_size: int = 2,
- erode_kernel: int = 4,
- use_erode: bool = True,
- visualization: bool = False,
+def predict(self,
+ im_file: Union[str, np.ndarray],
+ score_threshold: float = 0.5,
+ seg_batch_size: int = 2,
+ erode_kernel: int = 4,
+ use_erode: bool = True,
+ visualization: bool = False,
save_dir: str ='output'):
```
@@ -111,5 +111,3 @@ paddlepaddle >= 2.0.0
paddlehub >= 2.0.0
paddlex >= 1.3.0
-
-
diff --git a/modules/image/industrial_application/meter_readings/barometer_reader/module.py b/modules/image/industrial_application/meter_readings/barometer_reader/module.py
index 115abaf4..34a4f5fa 100644
--- a/modules/image/industrial_application/meter_readings/barometer_reader/module.py
+++ b/modules/image/industrial_application/meter_readings/barometer_reader/module.py
@@ -12,7 +12,6 @@ import paddle.nn as nn
from paddlex.seg import transforms as T
from paddlehub.module.module import moduleinfo, runnable, serving
-
METER_SHAPE = 512
CIRCLE_CENTER = [256, 256]
CIRCLE_RADIUS = 250
@@ -44,26 +43,28 @@ def cv2_to_base64(image: np.ndarray):
return base64.b64encode(data.tostring()).decode('utf8')
-@moduleinfo(name="barometer_reader",
- type="CV/image_editing",
- author="paddlepaddle",
- author_email="",
- summary="meter_reader implements the detection and automatic reading of traditional mechanical pointer meters based on Meter detection and pointer segmentation.",
- version="1.0.0")
+@moduleinfo(
+ name="barometer_reader",
+ type="CV/image_editing",
+ author="paddlepaddle",
+ author_email="",
+ summary=
+ "meter_reader implements the detection and automatic reading of traditional mechanical pointer meters based on Meter detection and pointer segmentation.",
+ version="1.0.0")
class BarometerReader(nn.Layer):
def __init__(self):
super(BarometerReader, self).__init__()
self.detector = pdx.load_model(os.path.join(self.directory, 'meter_det_inference_model'))
self.segmenter = pdx.load_model(os.path.join(self.directory, 'meter_seg_inference_model'))
self.seg_transform = T.Compose([T.Normalize()])
-
+
def read_process(self, label_maps: np.ndarray):
line_images = self.creat_line_image(label_maps)
scale_data, pointer_data = self.convert_1d_data(line_images)
self.scale_mean_filtration(scale_data)
result = self.get_meter_reader(scale_data, pointer_data)
return result
-
+
def creat_line_image(self, meter_image: np.ndarray):
line_image = np.zeros((LINE_HEIGHT, LINE_WIDTH), dtype=np.uint8)
for row in range(LINE_HEIGHT):
@@ -121,8 +122,7 @@ class BarometerReader(nn.Layer):
if pointer_flag:
if pointer_data[i] == 0 and pointer_data[i + 1] == 0:
one_pointer_end = i - 1
- pointer_location = (
- one_pointer_start + one_pointer_end) / 2
+ pointer_location = (one_pointer_start + one_pointer_end) / 2
one_pointer_start = 0
one_pointer_end = 0
pointer_flag = False
@@ -135,20 +135,19 @@ class BarometerReader(nn.Layer):
if scale_location[i] <= pointer_location and pointer_location < scale_location[i + 1]:
scales = i + (pointer_location - scale_location[i]) / (
scale_location[i + 1] - scale_location[i] + 1e-05) + 1
- ratio = (pointer_location - scale_location[0]) / (
- scale_location[scale_num - 1] - scale_location[0] + 1e-05)
+ ratio = (pointer_location - scale_location[0]) / (scale_location[scale_num - 1] - scale_location[0] + 1e-05)
result = {'scale_num': scale_num, 'scales': scales, 'ratio': ratio}
return result
-
- def predict(self,
- im_file: Union[str, np.ndarray],
- score_threshold: float = 0.5,
- seg_batch_size: int = 2,
- erode_kernel: int = 4,
- use_erode: bool = True,
- visualization: bool = False,
- save_dir: str ='output'):
-
+
+ def predict(self,
+ im_file: Union[str, np.ndarray],
+ score_threshold: float = 0.5,
+ seg_batch_size: int = 2,
+ erode_kernel: int = 4,
+ use_erode: bool = True,
+ visualization: bool = False,
+ save_dir: str = 'output'):
+
if isinstance(im_file, str):
im = cv2.imread(im_file).astype('float32')
else:
@@ -168,21 +167,15 @@ class BarometerReader(nn.Layer):
xmax = min(im.shape[1], int(xmin + w - 1))
ymax = min(im.shape[0], int(ymin + h - 1))
sub_image = im[ymin:(ymax + 1), xmin:(xmax + 1), :]
-
+
# Resize the image with shape (METER_SHAPE, METER_SHAPE)
meter_shape = sub_image.shape
scale_x = float(METER_SHAPE) / float(meter_shape[1])
scale_y = float(METER_SHAPE) / float(meter_shape[0])
- meter_meter = cv2.resize(
- sub_image,
- None,
- None,
- fx=scale_x,
- fy=scale_y,
- interpolation=cv2.INTER_LINEAR)
+ meter_meter = cv2.resize(sub_image, None, None, fx=scale_x, fy=scale_y, interpolation=cv2.INTER_LINEAR)
meter_meter = meter_meter.astype('float32')
resized_meters.append(meter_meter)
-
+
meter_num = len(resized_meters)
seg_results = list()
for i in range(0, meter_num, seg_batch_size):
@@ -190,22 +183,20 @@ class BarometerReader(nn.Layer):
meter_images = list()
for j in range(i, im_size):
meter_images.append(resized_meters[j - i])
-
- result = self.segmenter.batch_predict(
- transforms=self.seg_transform,
- img_file_list=meter_images)
+
+ result = self.segmenter.batch_predict(transforms=self.seg_transform, img_file_list=meter_images)
if use_erode:
kernel = np.ones((erode_kernel, erode_kernel), np.uint8)
for i in range(len(result)):
result[i]['label_map'] = cv2.erode(result[i]['label_map'], kernel)
seg_results.extend(result)
-
+
results = list()
for i, seg_result in enumerate(seg_results):
result = self.read_process(seg_result['label_map'])
results.append(result)
-
+
meter_values = list()
for i, result in enumerate(results):
if result['scale_num'] > TYPE_THRESHOLD:
@@ -222,9 +213,9 @@ class BarometerReader(nn.Layer):
visual_results.append(res)
if visualization:
pdx.det.visualize(im_file, visual_results, -1, save_dir=save_dir)
-
+
return visual_results
-
+
@serving
def serving_method(self, image: str, **kwargs):
"""
@@ -239,7 +230,7 @@ class BarometerReader(nn.Layer):
result['category'] = str(result['category'])
res.append(result)
return res
-
+
@runnable
def run_cmd(self, argvs: list):
"""
@@ -250,21 +241,16 @@ class BarometerReader(nn.Layer):
prog='hub run {}'.format(self.name),
usage='%(prog)s',
add_help=True)
- self.arg_input_group = self.parser.add_argument_group(
- title="Input options", description="Input data. Required")
+ self.arg_input_group = self.parser.add_argument_group(title="Input options", description="Input data. Required")
self.arg_config_group = self.parser.add_argument_group(
- title="Config options",
- description=
- "Run configuration for controlling module behavior, not required.")
+ title="Config options", description="Run configuration for controlling module behavior, not required.")
self.add_module_input_arg()
args = self.parser.parse_args(argvs)
results = self.predict(im_file=args.input_path)
return results
-
def add_module_input_arg(self):
"""
Add the command input options.
"""
- self.arg_input_group.add_argument(
- '--input_path', type=str, help="path to image.")
+ self.arg_input_group.add_argument('--input_path', type=str, help="path to image.")
diff --git a/modules/image/instance_segmentation/solov2/README.md b/modules/image/instance_segmentation/solov2/README.md
index 60c8d811..a80f6ba4 100644
--- a/modules/image/instance_segmentation/solov2/README.md
+++ b/modules/image/instance_segmentation/solov2/README.md
@@ -116,4 +116,3 @@ https://github.com/PaddlePaddle/PaddleDetection
paddlepaddle >= 2.0.0
paddlehub >= 2.0.0
-
diff --git a/modules/image/instance_segmentation/solov2/data_feed.py b/modules/image/instance_segmentation/solov2/data_feed.py
index 3e2a28b5..7d34afe8 100644
--- a/modules/image/instance_segmentation/solov2/data_feed.py
+++ b/modules/image/instance_segmentation/solov2/data_feed.py
@@ -42,38 +42,28 @@ def visualize_box_mask(im, results, labels=None, mask_resolution=14, threshold=0
im (PIL.Image.Image): visualized image
"""
if not labels:
- labels = ['background', 'person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus',
- 'train', 'truck', 'boat', 'traffic light', 'fire', 'hydrant', 'stop sign', 'parking meter',
- 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe',
- 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball',
- 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket', 'bottle',
- 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange',
- 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch', 'potted plant', 'bed',
- 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone', 'microwave',
- 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear',
- 'hair drier', 'toothbrush']
+ labels = [
+ 'background', 'person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat',
+ 'traffic light', 'fire', 'hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse',
+ 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie',
+ 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove',
+ 'skateboard', 'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl',
+ 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair',
+ 'couch', 'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard',
+ 'cell phone', 'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors',
+ 'teddy bear', 'hair drier', 'toothbrush'
+ ]
if isinstance(im, str):
im = Image.open(im).convert('RGB')
else:
im = cv2.cvtColor(im, cv2.COLOR_BGR2RGB)
im = Image.fromarray(im)
if 'masks' in results and 'boxes' in results:
- im = draw_mask(
- im,
- results['boxes'],
- results['masks'],
- labels,
- resolution=mask_resolution)
+ im = draw_mask(im, results['boxes'], results['masks'], labels, resolution=mask_resolution)
if 'boxes' in results:
im = draw_box(im, results['boxes'], labels)
if 'segm' in results:
- im = draw_segm(
- im,
- results['segm'],
- results['label'],
- results['score'],
- labels,
- threshold=threshold)
+ im = draw_segm(im, results['segm'], results['label'], results['score'], labels, threshold=threshold)
return im
@@ -200,28 +190,19 @@ def draw_box(im, np_boxes, labels):
color = tuple(clsid2color[clsid])
# draw bbox
- draw.line(
- [(xmin, ymin), (xmin, ymax), (xmax, ymax), (xmax, ymin),
- (xmin, ymin)],
- width=draw_thickness,
- fill=color)
+ draw.line([(xmin, ymin), (xmin, ymax), (xmax, ymax), (xmax, ymin), (xmin, ymin)],
+ width=draw_thickness,
+ fill=color)
# draw label
text = "{} {:.4f}".format(labels[clsid], score)
tw, th = draw.textsize(text)
- draw.rectangle(
- [(xmin + 1, ymin - th), (xmin + tw + 1, ymin)], fill=color)
+ draw.rectangle([(xmin + 1, ymin - th), (xmin + tw + 1, ymin)], fill=color)
draw.text((xmin + 1, ymin - th), text, fill=(255, 255, 255))
return im
-def draw_segm(im,
- np_segms,
- np_label,
- np_score,
- labels,
- threshold=0.5,
- alpha=0.7):
+def draw_segm(im, np_segms, np_label, np_score, labels, threshold=0.5, alpha=0.7):
"""
Draw segmentation on image.
"""
@@ -250,28 +231,17 @@ def draw_segm(im,
sum_y = np.sum(mask, axis=1)
y = np.where(sum_y > 0.5)[0]
x0, x1, y0, y1 = x[0], x[-1], y[0], y[-1]
- cv2.rectangle(im, (x0, y0), (x1, y1),
- tuple(color_mask.astype('int32').tolist()), 1)
+ cv2.rectangle(im, (x0, y0), (x1, y1), tuple(color_mask.astype('int32').tolist()), 1)
bbox_text = '%s %.2f' % (labels[clsid], score)
t_size = cv2.getTextSize(bbox_text, 0, 0.3, thickness=1)[0]
- cv2.rectangle(im, (x0, y0), (x0 + t_size[0], y0 - t_size[1] - 3),
- tuple(color_mask.astype('int32').tolist()), -1)
- cv2.putText(
- im,
- bbox_text, (x0, y0 - 2),
- cv2.FONT_HERSHEY_SIMPLEX,
- 0.3, (0, 0, 0),
- 1,
- lineType=cv2.LINE_AA)
-
+ cv2.rectangle(im, (x0, y0), (x0 + t_size[0], y0 - t_size[1] - 3), tuple(color_mask.astype('int32').tolist()),
+ -1)
+ cv2.putText(im, bbox_text, (x0, y0 - 2), cv2.FONT_HERSHEY_SIMPLEX, 0.3, (0, 0, 0), 1, lineType=cv2.LINE_AA)
+
return Image.fromarray(im.astype('uint8'))
-def load_predictor(model_dir,
- run_mode='fluid',
- batch_size=1,
- use_gpu=False,
- min_subgraph_size=3):
+def load_predictor(model_dir, run_mode='fluid', batch_size=1, use_gpu=False, min_subgraph_size=3):
"""set AnalysisConfig, generate AnalysisPredictor
Args:
model_dir (str): root path of __model__ and __params__
@@ -282,20 +252,16 @@ def load_predictor(model_dir,
ValueError: predict by TensorRT need use_gpu == True.
"""
if not use_gpu and not run_mode == 'fluid':
- raise ValueError(
- "Predict by TensorRT mode: {}, expect use_gpu==True, but use_gpu == {}"
- .format(run_mode, use_gpu))
+ raise ValueError("Predict by TensorRT mode: {}, expect use_gpu==True, but use_gpu == {}".format(
+ run_mode, use_gpu))
if run_mode == 'trt_int8':
- raise ValueError("TensorRT int8 mode is not supported now, "
- "please use trt_fp32 or trt_fp16 instead.")
+ raise ValueError("TensorRT int8 mode is not supported now, " "please use trt_fp32 or trt_fp16 instead.")
precision_map = {
'trt_int8': fluid.core.AnalysisConfig.Precision.Int8,
'trt_fp32': fluid.core.AnalysisConfig.Precision.Float32,
'trt_fp16': fluid.core.AnalysisConfig.Precision.Half
}
- config = fluid.core.AnalysisConfig(
- os.path.join(model_dir, '__model__'),
- os.path.join(model_dir, '__params__'))
+ config = fluid.core.AnalysisConfig(os.path.join(model_dir, '__model__'), os.path.join(model_dir, '__params__'))
if use_gpu:
# initial GPU memory(M), device ID
config.enable_use_gpu(100, 0)
diff --git a/modules/image/instance_segmentation/solov2/module.py b/modules/image/instance_segmentation/solov2/module.py
index 006ea94f..52030031 100644
--- a/modules/image/instance_segmentation/solov2/module.py
+++ b/modules/image/instance_segmentation/solov2/module.py
@@ -33,20 +33,16 @@ class Detector(object):
threshold (float): threshold to reserve the result for output.
"""
- def __init__(self,
- min_subgraph_size: int = 60,
- use_gpu=False,
- threshold: float = 0.5):
+ def __init__(self, min_subgraph_size: int = 60, use_gpu=False, threshold: float = 0.5):
model_dir = os.path.join(self.directory, 'solov2_r50_fpn_1x')
- self.predictor = D.load_predictor(
- model_dir,
- min_subgraph_size=min_subgraph_size,
- use_gpu=use_gpu)
- self.compose = [P.Resize(max_size=1333),
- P.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
- P.Permute(),
- P.PadStride(stride=32)]
+ self.predictor = D.load_predictor(model_dir, min_subgraph_size=min_subgraph_size, use_gpu=use_gpu)
+ self.compose = [
+ P.Resize(max_size=1333),
+ P.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
+ P.Permute(),
+ P.PadStride(stride=32)
+ ]
def transform(self, im: Union[str, np.ndarray]):
im, im_info = P.preprocess(im, self.compose)
@@ -61,17 +57,14 @@ class Detector(object):
for box in np_boxes:
print('class_id:{:d}, confidence:{:.4f},'
'left_top:[{:.2f},{:.2f}],'
- ' right_bottom:[{:.2f},{:.2f}]'.format(
- int(box[0]), box[1], box[2], box[3], box[4], box[5]))
+ ' right_bottom:[{:.2f},{:.2f}]'.format(int(box[0]), box[1], box[2], box[3], box[4], box[5]))
results['boxes'] = np_boxes
if np_masks is not None:
np_masks = np_masks[expect_boxes, :, :, :]
results['masks'] = np_masks
return results
- def predict(self,
- image: Union[str, np.ndarray],
- threshold: float = 0.5):
+ def predict(self, image: Union[str, np.ndarray], threshold: float = 0.5):
'''
Args:
image (str/np.ndarray): path of image/ np.ndarray read by cv2
@@ -117,12 +110,9 @@ class DetectorSOLOv2(Detector):
use_gpu (bool): whether use gpu
threshold (float): threshold to reserve the result for output.
"""
- def __init__(self,
- use_gpu: bool = False,
- threshold: float = 0.5):
- super(DetectorSOLOv2, self).__init__(
- use_gpu=use_gpu,
- threshold=threshold)
+
+ def __init__(self, use_gpu: bool = False, threshold: float = 0.5):
+ super(DetectorSOLOv2, self).__init__(use_gpu=use_gpu, threshold=threshold)
def predict(self,
image: Union[str, np.ndarray],
@@ -135,7 +125,7 @@ class DetectorSOLOv2(Detector):
threshold (float): threshold of predicted box' score
visualization (bool): Whether to save visualization result.
save_dir (str): save path.
-
+
'''
inputs, im_info = self.transform(image)
@@ -148,14 +138,11 @@ class DetectorSOLOv2(Detector):
self.predictor.zero_copy_run()
output_names = self.predictor.get_output_names()
- np_label = self.predictor.get_output_tensor(output_names[
- 0]).copy_to_cpu()
- np_score = self.predictor.get_output_tensor(output_names[
- 1]).copy_to_cpu()
- np_segms = self.predictor.get_output_tensor(output_names[
- 2]).copy_to_cpu()
+ np_label = self.predictor.get_output_tensor(output_names[0]).copy_to_cpu()
+ np_score = self.predictor.get_output_tensor(output_names[1]).copy_to_cpu()
+ np_segms = self.predictor.get_output_tensor(output_names[2]).copy_to_cpu()
output = dict(segm=np_segms, label=np_label, score=np_score)
-
+
if visualization:
if not os.path.exists(save_dir):
os.makedirs(save_dir)
diff --git a/modules/image/instance_segmentation/solov2/processor.py b/modules/image/instance_segmentation/solov2/processor.py
index a6a92d9f..0de87f5a 100644
--- a/modules/image/instance_segmentation/solov2/processor.py
+++ b/modules/image/instance_segmentation/solov2/processor.py
@@ -78,20 +78,13 @@ class Resize(object):
im_channel = im.shape[2]
im_scale_x, im_scale_y = self.generate_scale(im)
if self.use_cv2:
- im = cv2.resize(
- im,
- None,
- None,
- fx=im_scale_x,
- fy=im_scale_y,
- interpolation=self.interp)
+ im = cv2.resize(im, None, None, fx=im_scale_x, fy=im_scale_y, interpolation=self.interp)
else:
resize_w = int(im_scale_x * float(im.shape[1]))
resize_h = int(im_scale_y * float(im.shape[0]))
if self.max_size != 0:
- raise TypeError(
- 'If you set max_size to cap the maximum size of image,'
- 'please set use_cv2 to True to resize the image.')
+ raise TypeError('If you set max_size to cap the maximum size of image,'
+ 'please set use_cv2 to True to resize the image.')
im = im.astype('uint8')
im = Image.fromarray(im)
im = im.resize((int(resize_w), int(resize_h)), self.interp)
@@ -99,8 +92,7 @@ class Resize(object):
# padding im when image_shape fixed by infer_cfg.yml
if self.max_size != 0 and self.image_shape is not None:
- padding_im = np.zeros(
- (self.max_size, self.max_size, im_channel), dtype=np.float32)
+ padding_im = np.zeros((self.max_size, self.max_size, im_channel), dtype=np.float32)
im_h, im_w = im.shape[:2]
padding_im[:im_h, :im_w, :] = im
im = padding_im
diff --git a/modules/image/keypoint_detection/openpose_body_estimation/module.py b/modules/image/keypoint_detection/openpose_body_estimation/module.py
index 6df85ccb..bccd3c81 100644
--- a/modules/image/keypoint_detection/openpose_body_estimation/module.py
+++ b/modules/image/keypoint_detection/openpose_body_estimation/module.py
@@ -206,11 +206,8 @@ class BodyPoseModel(nn.Layer):
img_name = str(time.time()) + '.png'
save_path = os.path.join(save_path, img_name)
cv2.imwrite(save_path, canvas)
-
- results = {
- 'candidate': candidate,
- 'subset': subset,
- 'data': canvas}
+
+ results = {'candidate': candidate, 'subset': subset, 'data': canvas}
return results
@@ -221,11 +218,11 @@ class BodyPoseModel(nn.Layer):
"""
images_decode = [P.base64_to_cv2(image) for image in images]
results = self.predict(img=images_decode[0], **kwargs)
- final={}
+ final = {}
final['candidate'] = P.cv2_to_base64(results['candidate'])
final['subset'] = P.cv2_to_base64(results['subset'])
final['data'] = P.cv2_to_base64(results['data'])
-
+
return final
@runnable
@@ -238,19 +235,13 @@ class BodyPoseModel(nn.Layer):
prog='hub run {}'.format(self.name),
usage='%(prog)s',
add_help=True)
- self.arg_input_group = self.parser.add_argument_group(
- title="Input options", description="Input data. Required")
+ self.arg_input_group = self.parser.add_argument_group(title="Input options", description="Input data. Required")
self.arg_config_group = self.parser.add_argument_group(
- title="Config options",
- description=
- "Run configuration for controlling module behavior, not required.")
+ title="Config options", description="Run configuration for controlling module behavior, not required.")
self.add_module_config_arg()
self.add_module_input_arg()
args = self.parser.parse_args(argvs)
- results = self.predict(
- img=args.input_path,
- save_path=args.output_dir,
- visualization=args.visualization)
+ results = self.predict(img=args.input_path, save_path=args.output_dir, visualization=args.visualization)
return results
@@ -260,19 +251,12 @@ class BodyPoseModel(nn.Layer):
"""
self.arg_config_group.add_argument(
- '--output_dir',
- type=str,
- default='openpose_body',
- help="The directory to save output images.")
+ '--output_dir', type=str, default='openpose_body', help="The directory to save output images.")
self.arg_config_group.add_argument(
- '--visualization',
- type=bool,
- default=True,
- help="whether to save output as images.")
+ '--visualization', type=bool, default=True, help="whether to save output as images.")
def add_module_input_arg(self):
"""
Add the command input options.
"""
- self.arg_input_group.add_argument(
- '--input_path', type=str, help="path to image.")
\ No newline at end of file
+ self.arg_input_group.add_argument('--input_path', type=str, help="path to image.")
diff --git a/modules/image/keypoint_detection/openpose_body_estimation/processor.py b/modules/image/keypoint_detection/openpose_body_estimation/processor.py
index cbb1d6b7..aa17240e 100644
--- a/modules/image/keypoint_detection/openpose_body_estimation/processor.py
+++ b/modules/image/keypoint_detection/openpose_body_estimation/processor.py
@@ -312,7 +312,7 @@ class Candidate:
subset = np.delete(subset, deleteIdx, axis=0)
return candidate, subset
-
+
class ResizeScaling:
"""Resize images by scaling method.
@@ -341,4 +341,4 @@ def base64_to_cv2(b64str: str):
data = base64.b64decode(b64str.encode('utf8'))
data = np.fromstring(data, np.uint8)
data = cv2.imdecode(data, cv2.IMREAD_COLOR)
- return data
\ No newline at end of file
+ return data
diff --git a/modules/image/keypoint_detection/openpose_hands_estimation/module.py b/modules/image/keypoint_detection/openpose_hands_estimation/module.py
index b80e5f44..37a3ac27 100644
--- a/modules/image/keypoint_detection/openpose_hands_estimation/module.py
+++ b/modules/image/keypoint_detection/openpose_hands_estimation/module.py
@@ -51,7 +51,7 @@ class HandPoseModel(nn.Layer):
def __init__(self, load_checkpoint: str = None):
super(HandPoseModel, self).__init__()
-
+
self.norm_func = T.Normalize(std=[1, 1, 1])
self.resize_func = P.ResizeScaling()
self.hand_detect = P.HandDetect()
@@ -170,14 +170,18 @@ class HandPoseModel(nn.Layer):
return np.array(all_peaks)
- def predict(self, img: Union[str, np.ndarray], save_path: str = 'openpose_hand', scale: list = [0.5, 1.0, 1.5, 2.0], visualization: bool = True):
+ def predict(self,
+ img: Union[str, np.ndarray],
+ save_path: str = 'openpose_hand',
+ scale: list = [0.5, 1.0, 1.5, 2.0],
+ visualization: bool = True):
self.eval()
self.visualization = visualization
if isinstance(img, str):
org_img = cv2.imread(img)
else:
org_img = img
-
+
if not self.body_model:
self.body_model = hub.Module(name='openpose_body_estimation')
self.body_model.eval()
@@ -193,7 +197,11 @@ class HandPoseModel(nn.Layer):
peaks[:, 1] = np.where(peaks[:, 1] == 0, peaks[:, 1], peaks[:, 1] + y)
all_hand_peaks.append(peaks)
canvas = copy.deepcopy(org_img)
- canvas = self.draw_pose(canvas, body_result['candidate'], body_result['subset'],)
+ canvas = self.draw_pose(
+ canvas,
+ body_result['candidate'],
+ body_result['subset'],
+ )
canvas = self.draw_hand(canvas, all_hand_peaks)
if self.visualization:
if not os.path.exists(save_path):
@@ -201,10 +209,8 @@ class HandPoseModel(nn.Layer):
img_name = str(time.time()) + '.png'
save_path = os.path.join(save_path, img_name)
cv2.imwrite(save_path, canvas)
-
- results = {
- 'all_hand_peaks': all_hand_peaks,
- 'data': canvas}
+
+ results = {'all_hand_peaks': all_hand_peaks, 'data': canvas}
return results
@@ -215,11 +221,11 @@ class HandPoseModel(nn.Layer):
"""
images_decode = [P.base64_to_cv2(image) for image in images]
results = self.predict(img=images_decode[0], **kwargs)
- final={}
- final['all_hand_peaks']=[peak.tolist() for peak in results['all_hand_peaks']]
+ final = {}
+ final['all_hand_peaks'] = [peak.tolist() for peak in results['all_hand_peaks']]
final['data'] = P.cv2_to_base64(results['data'])
return final
-
+
@runnable
def run_cmd(self, argvs: list):
"""
@@ -230,20 +236,14 @@ class HandPoseModel(nn.Layer):
prog='hub run {}'.format(self.name),
usage='%(prog)s',
add_help=True)
- self.arg_input_group = self.parser.add_argument_group(
- title="Input options", description="Input data. Required")
+ self.arg_input_group = self.parser.add_argument_group(title="Input options", description="Input data. Required")
self.arg_config_group = self.parser.add_argument_group(
- title="Config options",
- description=
- "Run configuration for controlling module behavior, not required.")
+ title="Config options", description="Run configuration for controlling module behavior, not required.")
self.add_module_config_arg()
self.add_module_input_arg()
args = self.parser.parse_args(argvs)
results = self.predict(
- img=args.input_path,
- save_path=args.output_dir,
- scale=args.scale,
- visualization=args.visualization)
+ img=args.input_path, save_path=args.output_dir, scale=args.scale, visualization=args.visualization)
return results
@@ -253,24 +253,14 @@ class HandPoseModel(nn.Layer):
"""
self.arg_config_group.add_argument(
- '--output_dir',
- type=str,
- default='openpose_hand',
- help="The directory to save output images.")
+ '--output_dir', type=str, default='openpose_hand', help="The directory to save output images.")
self.arg_config_group.add_argument(
- '--scale',
- type=list,
- default=[0.5, 1.0, 1.5, 2.0],
- help="The search scale for openpose hands model.")
+ '--scale', type=list, default=[0.5, 1.0, 1.5, 2.0], help="The search scale for openpose hands model.")
self.arg_config_group.add_argument(
- '--visualization',
- type=bool,
- default=True,
- help="whether to save output as images.")
+ '--visualization', type=bool, default=True, help="whether to save output as images.")
def add_module_input_arg(self):
"""
Add the command input options.
"""
- self.arg_input_group.add_argument(
- '--input_path', type=str, help="path to image.")
\ No newline at end of file
+ self.arg_input_group.add_argument('--input_path', type=str, help="path to image.")
diff --git a/modules/image/keypoint_detection/openpose_hands_estimation/processor.py b/modules/image/keypoint_detection/openpose_hands_estimation/processor.py
index 9b735d93..93b16154 100644
--- a/modules/image/keypoint_detection/openpose_hands_estimation/processor.py
+++ b/modules/image/keypoint_detection/openpose_hands_estimation/processor.py
@@ -213,8 +213,8 @@ class DrawHandPose:
bg.draw()
canvas = np.frombuffer(bg.tostring_rgb(), dtype='uint8').reshape(int(height), int(width), 3)
return canvas
-
-
+
+
class ResizeScaling:
"""Resize images by scaling method.
@@ -231,7 +231,8 @@ class ResizeScaling:
scale = scale_search * self.target / img.shape[0]
resize_img = cv2.resize(img, (0, 0), fx=scale, fy=scale, interpolation=self.interpolation)
return resize_img
-
+
+
def npmax(array: np.ndarray):
"""Get max value and index."""
arrayindex = array.argmax(1)
diff --git a/modules/image/semantic_segmentation/ExtremeC3_Portrait_Segmentation/module.py b/modules/image/semantic_segmentation/ExtremeC3_Portrait_Segmentation/module.py
index fa1344dd..02c1daf2 100644
--- a/modules/image/semantic_segmentation/ExtremeC3_Portrait_Segmentation/module.py
+++ b/modules/image/semantic_segmentation/ExtremeC3_Portrait_Segmentation/module.py
@@ -6,6 +6,7 @@ import numpy as np
from paddle.nn import Layer
from paddlehub.module.module import moduleinfo
+
@moduleinfo(
name="ExtremeC3_Portrait_Segmentation", # 模型名称
type="CV/semantic_segmentation", # 模型类型
@@ -26,7 +27,7 @@ class ExtremeC3_Portrait_Segmentation(Layer):
self.model.eval()
# 均值方差
- self.mean = [107.304565, 115.69884, 132.35703 ]
+ self.mean = [107.304565, 115.69884, 132.35703]
self.std = [63.97182, 65.1337, 68.29726]
# 读取数据函数
@@ -107,20 +108,12 @@ class ExtremeC3_Portrait_Segmentation(Layer):
cv2.imwrite(os.path.join(output_dir, 'result_mask_%d.png' % i), mask)
cv2.imwrite(os.path.join(output_dir, 'result_%d.png' % i), result)
- results.append({
- 'mask': mask,
- 'result': result
- })
+ results.append({'mask': mask, 'result': result})
return results
# 关键点检测函数
- def Segmentation(self,
- images=None,
- paths=None,
- batch_size=1,
- output_dir='output',
- visualization=False):
+ def Segmentation(self, images=None, paths=None, batch_size=1, output_dir='output', visualization=False):
# 加载数据处理器
datas = self.load_datas(paths, images)
@@ -134,4 +127,4 @@ class ExtremeC3_Portrait_Segmentation(Layer):
results = self.postprocess(outputs, datas, output_dir, visualization)
# 返回结果
- return results
\ No newline at end of file
+ return results
diff --git a/modules/image/semantic_segmentation/SINet_Portrait_Segmentation/module.py b/modules/image/semantic_segmentation/SINet_Portrait_Segmentation/module.py
index 5bd18353..b72d8f1a 100644
--- a/modules/image/semantic_segmentation/SINet_Portrait_Segmentation/module.py
+++ b/modules/image/semantic_segmentation/SINet_Portrait_Segmentation/module.py
@@ -6,6 +6,7 @@ import numpy as np
from paddle.nn import Layer
from paddlehub.module.module import moduleinfo
+
@moduleinfo(
name="SINet_Portrait_Segmentation", # 模型名称
type="CV/semantic_segmentation", # 模型类型
@@ -26,7 +27,7 @@ class SINet_Portrait_Segmentation(Layer):
self.model.eval()
# 均值方差
- self.mean = [107.304565, 115.69884, 132.35703 ]
+ self.mean = [107.304565, 115.69884, 132.35703]
self.std = [63.97182, 65.1337, 68.29726]
# 读取数据函数
@@ -107,20 +108,12 @@ class SINet_Portrait_Segmentation(Layer):
cv2.imwrite(os.path.join(output_dir, 'result_mask_%d.png' % i), mask)
cv2.imwrite(os.path.join(output_dir, 'result_%d.png' % i), result)
- results.append({
- 'mask': mask,
- 'result': result
- })
+ results.append({'mask': mask, 'result': result})
return results
# 关键点检测函数
- def Segmentation(self,
- images=None,
- paths=None,
- batch_size=1,
- output_dir='output',
- visualization=False):
+ def Segmentation(self, images=None, paths=None, batch_size=1, output_dir='output', visualization=False):
# 加载数据处理器
datas = self.load_datas(paths, images)
diff --git a/modules/image/semantic_segmentation/deeplabv3p_resnet50_voc/layers.py b/modules/image/semantic_segmentation/deeplabv3p_resnet50_voc/layers.py
index dd958e19..f19373b3 100644
--- a/modules/image/semantic_segmentation/deeplabv3p_resnet50_voc/layers.py
+++ b/modules/image/semantic_segmentation/deeplabv3p_resnet50_voc/layers.py
@@ -30,22 +30,20 @@ def SyncBatchNorm(*args, **kwargs):
class ConvBNLayer(nn.Layer):
"""Basic conv bn relu layer."""
- def __init__(
- self,
- in_channels: int,
- out_channels: int,
- kernel_size: int,
- stride: int = 1,
- dilation: int = 1,
- groups: int = 1,
- is_vd_mode: bool = False,
- act: str = None,
- name: str = None):
+ def __init__(self,
+ in_channels: int,
+ out_channels: int,
+ kernel_size: int,
+ stride: int = 1,
+ dilation: int = 1,
+ groups: int = 1,
+ is_vd_mode: bool = False,
+ act: str = None,
+ name: str = None):
super(ConvBNLayer, self).__init__()
self.is_vd_mode = is_vd_mode
- self._pool2d_avg = AvgPool2D(
- kernel_size=2, stride=2, padding=0, ceil_mode=True)
+ self._pool2d_avg = AvgPool2D(kernel_size=2, stride=2, padding=0, ceil_mode=True)
self._conv = Conv2D(
in_channels=in_channels,
out_channels=out_channels,
@@ -83,11 +81,7 @@ class BottleneckBlock(nn.Layer):
super(BottleneckBlock, self).__init__()
self.conv0 = ConvBNLayer(
- in_channels=in_channels,
- out_channels=out_channels,
- kernel_size=1,
- act='relu',
- name=name + "_branch2a")
+ in_channels=in_channels, out_channels=out_channels, kernel_size=1, act='relu', name=name + "_branch2a")
self.dilation = dilation
@@ -100,11 +94,7 @@ class BottleneckBlock(nn.Layer):
dilation=dilation,
name=name + "_branch2b")
self.conv2 = ConvBNLayer(
- in_channels=out_channels,
- out_channels=out_channels * 4,
- kernel_size=1,
- act=None,
- name=name + "_branch2c")
+ in_channels=out_channels, out_channels=out_channels * 4, kernel_size=1, act=None, name=name + "_branch2c")
if not shortcut:
self.short = ConvBNLayer(
@@ -139,12 +129,7 @@ class BottleneckBlock(nn.Layer):
class SeparableConvBNReLU(nn.Layer):
"""Depthwise Separable Convolution."""
- def __init__(self,
- in_channels: int,
- out_channels: int,
- kernel_size: int,
- padding: str = 'same',
- **kwargs: dict):
+ def __init__(self, in_channels: int, out_channels: int, kernel_size: int, padding: str = 'same', **kwargs: dict):
super(SeparableConvBNReLU, self).__init__()
self.depthwise_conv = ConvBN(
in_channels,
@@ -153,8 +138,7 @@ class SeparableConvBNReLU(nn.Layer):
padding=padding,
groups=in_channels,
**kwargs)
- self.piontwise_conv = ConvBNReLU(
- in_channels, out_channels, kernel_size=1, groups=1)
+ self.piontwise_conv = ConvBNReLU(in_channels, out_channels, kernel_size=1, groups=1)
def forward(self, x: paddle.Tensor) -> paddle.Tensor:
x = self.depthwise_conv(x)
@@ -165,15 +149,9 @@ class SeparableConvBNReLU(nn.Layer):
class ConvBN(nn.Layer):
"""Basic conv bn layer"""
- def __init__(self,
- in_channels: int,
- out_channels: int,
- kernel_size: int,
- padding: str = 'same',
- **kwargs: dict):
+ def __init__(self, in_channels: int, out_channels: int, kernel_size: int, padding: str = 'same', **kwargs: dict):
super(ConvBN, self).__init__()
- self._conv = Conv2D(
- in_channels, out_channels, kernel_size, padding=padding, **kwargs)
+ self._conv = Conv2D(in_channels, out_channels, kernel_size, padding=padding, **kwargs)
self._batch_norm = SyncBatchNorm(out_channels)
def forward(self, x: paddle.Tensor) -> paddle.Tensor:
@@ -185,16 +163,10 @@ class ConvBN(nn.Layer):
class ConvBNReLU(nn.Layer):
"""Basic conv bn relu layer."""
- def __init__(self,
- in_channels: int,
- out_channels: int,
- kernel_size: int,
- padding: str = 'same',
- **kwargs: dict):
+ def __init__(self, in_channels: int, out_channels: int, kernel_size: int, padding: str = 'same', **kwargs: dict):
super(ConvBNReLU, self).__init__()
- self._conv = Conv2D(
- in_channels, out_channels, kernel_size, padding=padding, **kwargs)
+ self._conv = Conv2D(in_channels, out_channels, kernel_size, padding=padding, **kwargs)
self._batch_norm = SyncBatchNorm(out_channels)
def forward(self, x: paddle.Tensor) -> paddle.Tensor:
@@ -251,8 +223,7 @@ class Activation(nn.Layer):
act_name = act_dict[act]
self.act_func = eval("activation.{}()".format(act_name))
else:
- raise KeyError("{} does not exist in the current {}".format(
- act, act_dict.keys()))
+ raise KeyError("{} does not exist in the current {}".format(act, act_dict.keys()))
def forward(self, x: paddle.Tensor) -> paddle.Tensor:
@@ -281,7 +252,7 @@ class ASPPModule(nn.Layer):
in_channels: int,
out_channels: int,
align_corners: bool,
- use_sep_conv: bool= False,
+ use_sep_conv: bool = False,
image_pooling: bool = False):
super().__init__()
@@ -311,10 +282,7 @@ class ASPPModule(nn.Layer):
out_size += 1
self.image_pooling = image_pooling
- self.conv_bn_relu = ConvBNReLU(
- in_channels=out_channels * out_size,
- out_channels=out_channels,
- kernel_size=1)
+ self.conv_bn_relu = ConvBNReLU(in_channels=out_channels * out_size, out_channels=out_channels, kernel_size=1)
self.dropout = nn.Dropout(p=0.1) # drop rate
@@ -322,20 +290,12 @@ class ASPPModule(nn.Layer):
outputs = []
for block in self.aspp_blocks:
y = block(x)
- y = F.interpolate(
- y,
- x.shape[2:],
- mode='bilinear',
- align_corners=self.align_corners)
+ y = F.interpolate(y, x.shape[2:], mode='bilinear', align_corners=self.align_corners)
outputs.append(y)
if self.image_pooling:
img_avg = self.global_avg_pool(x)
- img_avg = F.interpolate(
- img_avg,
- x.shape[2:],
- mode='bilinear',
- align_corners=self.align_corners)
+ img_avg = F.interpolate(img_avg, x.shape[2:], mode='bilinear', align_corners=self.align_corners)
outputs.append(img_avg)
x = paddle.concat(outputs, axis=1)
diff --git a/modules/image/semantic_segmentation/deeplabv3p_resnet50_voc/module.py b/modules/image/semantic_segmentation/deeplabv3p_resnet50_voc/module.py
index 10ab03ca..a067c242 100644
--- a/modules/image/semantic_segmentation/deeplabv3p_resnet50_voc/module.py
+++ b/modules/image/semantic_segmentation/deeplabv3p_resnet50_voc/module.py
@@ -27,7 +27,6 @@ from deeplabv3p_resnet50_voc.resnet import ResNet50_vd
import deeplabv3p_resnet50_voc.layers as L
-
@moduleinfo(
name="deeplabv3p_resnet50_voc",
type="CV/semantic_segmentation",
@@ -72,9 +71,8 @@ class DeepLabV3PResnet50(nn.Layer):
super(DeepLabV3PResnet50, self).__init__()
self.backbone = ResNet50_vd()
backbone_channels = [self.backbone.feat_channels[i] for i in backbone_indices]
- self.head = DeepLabV3PHead(num_classes, backbone_indices,
- backbone_channels, aspp_ratios,
- aspp_out_channels, align_corners)
+ self.head = DeepLabV3PHead(num_classes, backbone_indices, backbone_channels, aspp_ratios, aspp_out_channels,
+ align_corners)
self.align_corners = align_corners
self.transforms = T.Compose([T.Normalize()])
@@ -96,11 +94,8 @@ class DeepLabV3PResnet50(nn.Layer):
feat_list = self.backbone(x)
logit_list = self.head(feat_list)
return [
- F.interpolate(
- logit,
- x.shape[2:],
- mode='bilinear',
- align_corners=self.align_corners) for logit in logit_list]
+ F.interpolate(logit, x.shape[2:], mode='bilinear', align_corners=self.align_corners) for logit in logit_list
+ ]
class DeepLabV3PHead(nn.Layer):
@@ -123,17 +118,13 @@ class DeepLabV3PHead(nn.Layer):
is even, e.g. 1024x512, otherwise it is True, e.g. 769x769.
"""
- def __init__(self, num_classes: int, backbone_indices: Tuple[paddle.Tensor], backbone_channels: Tuple[paddle.Tensor],
- aspp_ratios: Tuple[float], aspp_out_channels: int, align_corners: bool):
+ def __init__(self, num_classes: int, backbone_indices: Tuple[paddle.Tensor],
+ backbone_channels: Tuple[paddle.Tensor], aspp_ratios: Tuple[float], aspp_out_channels: int,
+ align_corners: bool):
super().__init__()
self.aspp = L.ASPPModule(
- aspp_ratios,
- backbone_channels[1],
- aspp_out_channels,
- align_corners,
- use_sep_conv=True,
- image_pooling=True)
+ aspp_ratios, backbone_channels[1], aspp_out_channels, align_corners, use_sep_conv=True, image_pooling=True)
self.decoder = Decoder(num_classes, backbone_channels[0], align_corners)
self.backbone_indices = backbone_indices
@@ -160,27 +151,19 @@ class Decoder(nn.Layer):
def __init__(self, num_classes: int, in_channels: int, align_corners: bool):
super(Decoder, self).__init__()
- self.conv_bn_relu1 = L.ConvBNReLU(
- in_channels=in_channels, out_channels=48, kernel_size=1)
+ self.conv_bn_relu1 = L.ConvBNReLU(in_channels=in_channels, out_channels=48, kernel_size=1)
- self.conv_bn_relu2 = L.SeparableConvBNReLU(
- in_channels=304, out_channels=256, kernel_size=3, padding=1)
- self.conv_bn_relu3 = L.SeparableConvBNReLU(
- in_channels=256, out_channels=256, kernel_size=3, padding=1)
- self.conv = nn.Conv2D(
- in_channels=256, out_channels=num_classes, kernel_size=1)
+ self.conv_bn_relu2 = L.SeparableConvBNReLU(in_channels=304, out_channels=256, kernel_size=3, padding=1)
+ self.conv_bn_relu3 = L.SeparableConvBNReLU(in_channels=256, out_channels=256, kernel_size=3, padding=1)
+ self.conv = nn.Conv2D(in_channels=256, out_channels=num_classes, kernel_size=1)
self.align_corners = align_corners
def forward(self, x: paddle.Tensor, low_level_feat: paddle.Tensor) -> paddle.Tensor:
low_level_feat = self.conv_bn_relu1(low_level_feat)
- x = F.interpolate(
- x,
- low_level_feat.shape[2:],
- mode='bilinear',
- align_corners=self.align_corners)
+ x = F.interpolate(x, low_level_feat.shape[2:], mode='bilinear', align_corners=self.align_corners)
x = paddle.concat([x, low_level_feat], axis=1)
x = self.conv_bn_relu2(x)
x = self.conv_bn_relu3(x)
x = self.conv(x)
- return x
\ No newline at end of file
+ return x
diff --git a/modules/image/semantic_segmentation/deeplabv3p_resnet50_voc/resnet.py b/modules/image/semantic_segmentation/deeplabv3p_resnet50_voc/resnet.py
index 2fa6fa2f..4ca3a252 100644
--- a/modules/image/semantic_segmentation/deeplabv3p_resnet50_voc/resnet.py
+++ b/modules/image/semantic_segmentation/deeplabv3p_resnet50_voc/resnet.py
@@ -36,11 +36,7 @@ class BasicBlock(nn.Layer):
act='relu',
name=name + "_branch2a")
self.conv1 = L.ConvBNLayer(
- in_channels=out_channels,
- out_channels=out_channels,
- kernel_size=3,
- act=None,
- name=name + "_branch2b")
+ in_channels=out_channels, out_channels=out_channels, kernel_size=3, act=None, name=name + "_branch2b")
if not shortcut:
self.short = L.ConvBNLayer(
@@ -67,35 +63,19 @@ class BasicBlock(nn.Layer):
class ResNet50_vd(nn.Layer):
- def __init__(self,
- multi_grid: tuple = (1, 2, 4)):
+ def __init__(self, multi_grid: tuple = (1, 2, 4)):
super(ResNet50_vd, self).__init__()
depth = [3, 4, 6, 3]
- num_channels = [64, 256, 512, 1024]
+ num_channels = [64, 256, 512, 1024]
num_filters = [64, 128, 256, 512]
self.feat_channels = [c * 4 for c in num_filters]
dilation_dict = {2: 2, 3: 4}
self.conv1_1 = L.ConvBNLayer(
- in_channels=3,
- out_channels=32,
- kernel_size=3,
- stride=2,
- act='relu',
- name="conv1_1")
+ in_channels=3, out_channels=32, kernel_size=3, stride=2, act='relu', name="conv1_1")
self.conv1_2 = L.ConvBNLayer(
- in_channels=32,
- out_channels=32,
- kernel_size=3,
- stride=1,
- act='relu',
- name="conv1_2")
+ in_channels=32, out_channels=32, kernel_size=3, stride=1, act='relu', name="conv1_2")
self.conv1_3 = L.ConvBNLayer(
- in_channels=32,
- out_channels=64,
- kernel_size=3,
- stride=1,
- act='relu',
- name="conv1_3")
+ in_channels=32, out_channels=64, kernel_size=3, stride=1, act='relu', name="conv1_3")
self.pool2d_max = nn.MaxPool2D(kernel_size=3, stride=2, padding=1)
self.stage_list = []
@@ -104,18 +84,15 @@ class ResNet50_vd(nn.Layer):
block_list = []
for i in range(depth[block]):
conv_name = "res" + str(block + 2) + chr(97 + i)
- dilation_rate = dilation_dict[
- block] if dilation_dict and block in dilation_dict else 1
+ dilation_rate = dilation_dict[block] if dilation_dict and block in dilation_dict else 1
if block == 3:
dilation_rate = dilation_rate * multi_grid[i]
bottleneck_block = self.add_sublayer(
'bb_%d_%d' % (block, i),
L.BottleneckBlock(
- in_channels=num_channels[block]
- if i == 0 else num_filters[block] * 4,
+ in_channels=num_channels[block] if i == 0 else num_filters[block] * 4,
out_channels=num_filters[block],
- stride=2 if i == 0 and block != 0
- and dilation_rate == 1 else 1,
+ stride=2 if i == 0 and block != 0 and dilation_rate == 1 else 1,
shortcut=shortcut,
if_first=block == i == 0,
name=conv_name,
@@ -134,4 +111,4 @@ class ResNet50_vd(nn.Layer):
for block in stage:
y = block(y)
feat_list.append(y)
- return feat_list
\ No newline at end of file
+ return feat_list
diff --git a/modules/image/semantic_segmentation/ocrnet_hrnetw18_voc/hrnet.py b/modules/image/semantic_segmentation/ocrnet_hrnetw18_voc/hrnet.py
index 2e9ea789..be1303d9 100644
--- a/modules/image/semantic_segmentation/ocrnet_hrnetw18_voc/hrnet.py
+++ b/modules/image/semantic_segmentation/ocrnet_hrnetw18_voc/hrnet.py
@@ -51,8 +51,8 @@ class HRNet_W18(nn.Layer):
def __init__(self,
pretrained: str = None,
stage1_num_modules: int = 1,
- stage1_num_blocks: tuple = (4,),
- stage1_num_channels: tuple = (64,),
+ stage1_num_blocks: tuple = (4, ),
+ stage1_num_channels: tuple = (64, ),
stage2_num_modules: int = 1,
stage2_num_blocks: tuple = (4, 4),
stage2_num_channels: tuple = (18, 36),
@@ -83,20 +83,10 @@ class HRNet_W18(nn.Layer):
self.feat_channels = [sum(stage4_num_channels)]
self.conv_layer1_1 = L.ConvBNReLU(
- in_channels=3,
- out_channels=64,
- kernel_size=3,
- stride=2,
- padding='same',
- bias_attr=False)
+ in_channels=3, out_channels=64, kernel_size=3, stride=2, padding='same', bias_attr=False)
self.conv_layer1_2 = L.ConvBNReLU(
- in_channels=64,
- out_channels=64,
- kernel_size=3,
- stride=2,
- padding='same',
- bias_attr=False)
+ in_channels=64, out_channels=64, kernel_size=3, stride=2, padding='same', bias_attr=False)
self.la1 = Layer1(
num_channels=64,
@@ -106,9 +96,7 @@ class HRNet_W18(nn.Layer):
name="layer2")
self.tr1 = TransitionLayer(
- in_channels=[self.stage1_num_channels[0] * 4],
- out_channels=self.stage2_num_channels,
- name="tr1")
+ in_channels=[self.stage1_num_channels[0] * 4], out_channels=self.stage2_num_channels, name="tr1")
self.st2 = Stage(
num_channels=self.stage2_num_channels,
@@ -120,9 +108,7 @@ class HRNet_W18(nn.Layer):
align_corners=align_corners)
self.tr2 = TransitionLayer(
- in_channels=self.stage2_num_channels,
- out_channels=self.stage3_num_channels,
- name="tr2")
+ in_channels=self.stage2_num_channels, out_channels=self.stage3_num_channels, name="tr2")
self.st3 = Stage(
num_channels=self.stage3_num_channels,
num_modules=self.stage3_num_modules,
@@ -133,9 +119,7 @@ class HRNet_W18(nn.Layer):
align_corners=align_corners)
self.tr3 = TransitionLayer(
- in_channels=self.stage3_num_channels,
- out_channels=self.stage4_num_channels,
- name="tr3")
+ in_channels=self.stage3_num_channels, out_channels=self.stage4_num_channels, name="tr3")
self.st4 = Stage(
num_channels=self.stage4_num_channels,
num_modules=self.stage4_num_modules,
@@ -161,30 +145,16 @@ class HRNet_W18(nn.Layer):
st4 = self.st4(tr3)
x0_h, x0_w = st4[0].shape[2:]
- x1 = F.interpolate(
- st4[1], (x0_h, x0_w),
- mode='bilinear',
- align_corners=self.align_corners)
- x2 = F.interpolate(
- st4[2], (x0_h, x0_w),
- mode='bilinear',
- align_corners=self.align_corners)
- x3 = F.interpolate(
- st4[3], (x0_h, x0_w),
- mode='bilinear',
- align_corners=self.align_corners)
+ x1 = F.interpolate(st4[1], (x0_h, x0_w), mode='bilinear', align_corners=self.align_corners)
+ x2 = F.interpolate(st4[2], (x0_h, x0_w), mode='bilinear', align_corners=self.align_corners)
+ x3 = F.interpolate(st4[3], (x0_h, x0_w), mode='bilinear', align_corners=self.align_corners)
x = paddle.concat([st4[0], x1, x2, x3], axis=1)
return [x]
class Layer1(nn.Layer):
- def __init__(self,
- num_channels: int,
- num_filters: int,
- num_blocks: int,
- has_se: bool = False,
- name: str = None):
+ def __init__(self, num_channels: int, num_filters: int, num_blocks: int, has_se: bool = False, name: str = None):
super(Layer1, self).__init__()
self.bottleneck_block_list = []
@@ -253,12 +223,7 @@ class TransitionLayer(nn.Layer):
class Branches(nn.Layer):
- def __init__(self,
- num_blocks: int,
- in_channels: int,
- out_channels: int,
- has_se: bool = False,
- name: str = None):
+ def __init__(self, num_blocks: int, in_channels: int, out_channels: int, has_se: bool = False, name: str = None):
super(Branches, self).__init__()
self.basic_block_list = []
@@ -273,8 +238,7 @@ class Branches(nn.Layer):
num_channels=in_ch,
num_filters=out_channels[i],
has_se=has_se,
- name=name + '_branch_layer_' + str(i + 1) + '_' +
- str(j + 1)))
+ name=name + '_branch_layer_' + str(i + 1) + '_' + str(j + 1)))
self.basic_block_list[i].append(basic_block_func)
def forward(self, x: paddle.Tensor) -> paddle.Tensor:
@@ -301,11 +265,7 @@ class BottleneckBlock(nn.Layer):
self.downsample = downsample
self.conv1 = L.ConvBNReLU(
- in_channels=num_channels,
- out_channels=num_filters,
- kernel_size=1,
- padding='same',
- bias_attr=False)
+ in_channels=num_channels, out_channels=num_filters, kernel_size=1, padding='same', bias_attr=False)
self.conv2 = L.ConvBNReLU(
in_channels=num_filters,
@@ -316,26 +276,15 @@ class BottleneckBlock(nn.Layer):
bias_attr=False)
self.conv3 = L.ConvBN(
- in_channels=num_filters,
- out_channels=num_filters * 4,
- kernel_size=1,
- padding='same',
- bias_attr=False)
+ in_channels=num_filters, out_channels=num_filters * 4, kernel_size=1, padding='same', bias_attr=False)
if self.downsample:
self.conv_down = L.ConvBN(
- in_channels=num_channels,
- out_channels=num_filters * 4,
- kernel_size=1,
- padding='same',
- bias_attr=False)
+ in_channels=num_channels, out_channels=num_filters * 4, kernel_size=1, padding='same', bias_attr=False)
if self.has_se:
self.se = SELayer(
- num_channels=num_filters * 4,
- num_filters=num_filters * 4,
- reduction_ratio=16,
- name=name + '_fc')
+ num_channels=num_filters * 4, num_filters=num_filters * 4, reduction_ratio=16, name=name + '_fc')
def forward(self, x: paddle.Tensor) -> paddle.Tensor:
residual = x
@@ -375,26 +324,14 @@ class BasicBlock(nn.Layer):
padding='same',
bias_attr=False)
self.conv2 = L.ConvBN(
- in_channels=num_filters,
- out_channels=num_filters,
- kernel_size=3,
- padding='same',
- bias_attr=False)
+ in_channels=num_filters, out_channels=num_filters, kernel_size=3, padding='same', bias_attr=False)
if self.downsample:
self.conv_down = L.ConvBNReLU(
- in_channels=num_channels,
- out_channels=num_filters,
- kernel_size=1,
- padding='same',
- bias_attr=False)
+ in_channels=num_channels, out_channels=num_filters, kernel_size=1, padding='same', bias_attr=False)
if self.has_se:
- self.se = SELayer(
- num_channels=num_filters,
- num_filters=num_filters,
- reduction_ratio=16,
- name=name + '_fc')
+ self.se = SELayer(num_channels=num_filters, num_filters=num_filters, reduction_ratio=16, name=name + '_fc')
def forward(self, x: paddle.Tensor) -> paddle.Tensor:
residual = x
@@ -423,17 +360,11 @@ class SELayer(nn.Layer):
med_ch = int(num_channels / reduction_ratio)
stdv = 1.0 / math.sqrt(num_channels * 1.0)
self.squeeze = nn.Linear(
- num_channels,
- med_ch,
- weight_attr=paddle.ParamAttr(
- initializer=nn.initializer.Uniform(-stdv, stdv)))
+ num_channels, med_ch, weight_attr=paddle.ParamAttr(initializer=nn.initializer.Uniform(-stdv, stdv)))
stdv = 1.0 / math.sqrt(med_ch * 1.0)
self.excitation = nn.Linear(
- med_ch,
- num_filters,
- weight_attr=paddle.ParamAttr(
- initializer=nn.initializer.Uniform(-stdv, stdv)))
+ med_ch, num_filters, weight_attr=paddle.ParamAttr(initializer=nn.initializer.Uniform(-stdv, stdv)))
def forward(self, x: paddle.Tensor) -> paddle.Tensor:
pool = self.pool2d_gap(x)
@@ -442,8 +373,7 @@ class SELayer(nn.Layer):
squeeze = F.relu(squeeze)
excitation = self.excitation(squeeze)
excitation = F.sigmoid(excitation)
- excitation = paddle.reshape(
- excitation, shape=[-1, self._num_channels, 1, 1])
+ excitation = paddle.reshape(excitation, shape=[-1, self._num_channels, 1, 1])
out = x * excitation
return out
@@ -507,11 +437,7 @@ class HighResolutionModule(nn.Layer):
super(HighResolutionModule, self).__init__()
self.branches_func = Branches(
- num_blocks=num_blocks,
- in_channels=num_channels,
- out_channels=num_filters,
- has_se=has_se,
- name=name)
+ num_blocks=num_blocks, in_channels=num_channels, out_channels=num_filters, has_se=has_se, name=name)
self.fuse_func = FuseLayers(
in_channels=num_filters,
@@ -557,8 +483,7 @@ class FuseLayers(nn.Layer):
for k in range(i - j):
if k == i - j - 1:
residual_func = self.add_sublayer(
- "residual_{}_layer_{}_{}_{}".format(
- name, i + 1, j + 1, k + 1),
+ "residual_{}_layer_{}_{}_{}".format(name, i + 1, j + 1, k + 1),
L.ConvBN(
in_channels=pre_num_filters,
out_channels=out_channels[i],
@@ -569,8 +494,7 @@ class FuseLayers(nn.Layer):
pre_num_filters = out_channels[i]
else:
residual_func = self.add_sublayer(
- "residual_{}_layer_{}_{}_{}".format(
- name, i + 1, j + 1, k + 1),
+ "residual_{}_layer_{}_{}_{}".format(name, i + 1, j + 1, k + 1),
L.ConvBNReLU(
in_channels=pre_num_filters,
out_channels=out_channels[j],
@@ -592,11 +516,7 @@ class FuseLayers(nn.Layer):
y = self.residual_func_list[residual_func_idx](x[j])
residual_func_idx += 1
- y = F.interpolate(
- y,
- residual_shape,
- mode='bilinear',
- align_corners=self.align_corners)
+ y = F.interpolate(y, residual_shape, mode='bilinear', align_corners=self.align_corners)
residual = residual + y
elif j < i:
y = x[j]
@@ -609,4 +529,4 @@ class FuseLayers(nn.Layer):
residual = F.relu(residual)
outs.append(residual)
- return outs
\ No newline at end of file
+ return outs
diff --git a/modules/image/semantic_segmentation/ocrnet_hrnetw18_voc/layers.py b/modules/image/semantic_segmentation/ocrnet_hrnetw18_voc/layers.py
index d5554a1b..b9a70182 100644
--- a/modules/image/semantic_segmentation/ocrnet_hrnetw18_voc/layers.py
+++ b/modules/image/semantic_segmentation/ocrnet_hrnetw18_voc/layers.py
@@ -30,22 +30,20 @@ def SyncBatchNorm(*args, **kwargs):
class ConvBNLayer(nn.Layer):
"""Basic conv bn relu layer."""
- def __init__(
- self,
- in_channels: int,
- out_channels: int,
- kernel_size: int,
- stride: int = 1,
- dilation: int = 1,
- groups: int = 1,
- is_vd_mode: bool = False,
- act: str = None,
- name: str = None):
+ def __init__(self,
+ in_channels: int,
+ out_channels: int,
+ kernel_size: int,
+ stride: int = 1,
+ dilation: int = 1,
+ groups: int = 1,
+ is_vd_mode: bool = False,
+ act: str = None,
+ name: str = None):
super(ConvBNLayer, self).__init__()
self.is_vd_mode = is_vd_mode
- self._pool2d_avg = AvgPool2D(
- kernel_size=2, stride=2, padding=0, ceil_mode=True)
+ self._pool2d_avg = AvgPool2D(kernel_size=2, stride=2, padding=0, ceil_mode=True)
self._conv = Conv2D(
in_channels=in_channels,
out_channels=out_channels,
@@ -83,11 +81,7 @@ class BottleneckBlock(nn.Layer):
super(BottleneckBlock, self).__init__()
self.conv0 = ConvBNLayer(
- in_channels=in_channels,
- out_channels=out_channels,
- kernel_size=1,
- act='relu',
- name=name + "_branch2a")
+ in_channels=in_channels, out_channels=out_channels, kernel_size=1, act='relu', name=name + "_branch2a")
self.dilation = dilation
@@ -100,11 +94,7 @@ class BottleneckBlock(nn.Layer):
dilation=dilation,
name=name + "_branch2b")
self.conv2 = ConvBNLayer(
- in_channels=out_channels,
- out_channels=out_channels * 4,
- kernel_size=1,
- act=None,
- name=name + "_branch2c")
+ in_channels=out_channels, out_channels=out_channels * 4, kernel_size=1, act=None, name=name + "_branch2c")
if not shortcut:
self.short = ConvBNLayer(
@@ -139,12 +129,7 @@ class BottleneckBlock(nn.Layer):
class SeparableConvBNReLU(nn.Layer):
"""Depthwise Separable Convolution."""
- def __init__(self,
- in_channels: int,
- out_channels: int,
- kernel_size: int,
- padding: str = 'same',
- **kwargs: dict):
+ def __init__(self, in_channels: int, out_channels: int, kernel_size: int, padding: str = 'same', **kwargs: dict):
super(SeparableConvBNReLU, self).__init__()
self.depthwise_conv = ConvBN(
in_channels,
@@ -153,8 +138,7 @@ class SeparableConvBNReLU(nn.Layer):
padding=padding,
groups=in_channels,
**kwargs)
- self.piontwise_conv = ConvBNReLU(
- in_channels, out_channels, kernel_size=1, groups=1)
+ self.piontwise_conv = ConvBNReLU(in_channels, out_channels, kernel_size=1, groups=1)
def forward(self, x: paddle.Tensor) -> paddle.Tensor:
x = self.depthwise_conv(x)
@@ -165,15 +149,9 @@ class SeparableConvBNReLU(nn.Layer):
class ConvBN(nn.Layer):
"""Basic conv bn layer"""
- def __init__(self,
- in_channels: int,
- out_channels: int,
- kernel_size: int,
- padding: str = 'same',
- **kwargs: dict):
+ def __init__(self, in_channels: int, out_channels: int, kernel_size: int, padding: str = 'same', **kwargs: dict):
super(ConvBN, self).__init__()
- self._conv = Conv2D(
- in_channels, out_channels, kernel_size, padding=padding, **kwargs)
+ self._conv = Conv2D(in_channels, out_channels, kernel_size, padding=padding, **kwargs)
self._batch_norm = SyncBatchNorm(out_channels)
def forward(self, x: paddle.Tensor) -> paddle.Tensor:
@@ -185,16 +163,10 @@ class ConvBN(nn.Layer):
class ConvBNReLU(nn.Layer):
"""Basic conv bn relu layer."""
- def __init__(self,
- in_channels: int,
- out_channels: int,
- kernel_size: int,
- padding: str = 'same',
- **kwargs: dict):
+ def __init__(self, in_channels: int, out_channels: int, kernel_size: int, padding: str = 'same', **kwargs: dict):
super(ConvBNReLU, self).__init__()
- self._conv = Conv2D(
- in_channels, out_channels, kernel_size, padding=padding, **kwargs)
+ self._conv = Conv2D(in_channels, out_channels, kernel_size, padding=padding, **kwargs)
self._batch_norm = SyncBatchNorm(out_channels)
def forward(self, x: paddle.Tensor) -> paddle.Tensor:
@@ -251,8 +223,7 @@ class Activation(nn.Layer):
act_name = act_dict[act]
self.act_func = eval("activation.{}()".format(act_name))
else:
- raise KeyError("{} does not exist in the current {}".format(
- act, act_dict.keys()))
+ raise KeyError("{} does not exist in the current {}".format(act, act_dict.keys()))
def forward(self, x: paddle.Tensor) -> paddle.Tensor:
@@ -276,13 +247,7 @@ class ASPPModule(nn.Layer):
image_pooling (bool, optional): If augmented with image-level features. Default: False
"""
- def __init__(self,
- aspp_ratios,
- in_channels,
- out_channels,
- align_corners,
- use_sep_conv=False,
- image_pooling=False):
+ def __init__(self, aspp_ratios, in_channels, out_channels, align_corners, use_sep_conv=False, image_pooling=False):
super().__init__()
self.align_corners = align_corners
@@ -311,10 +276,7 @@ class ASPPModule(nn.Layer):
out_size += 1
self.image_pooling = image_pooling
- self.conv_bn_relu = ConvBNReLU(
- in_channels=out_channels * out_size,
- out_channels=out_channels,
- kernel_size=1)
+ self.conv_bn_relu = ConvBNReLU(in_channels=out_channels * out_size, out_channels=out_channels, kernel_size=1)
self.dropout = nn.Dropout(p=0.1) # drop rate
@@ -322,24 +284,16 @@ class ASPPModule(nn.Layer):
outputs = []
for block in self.aspp_blocks:
y = block(x)
- y = F.interpolate(
- y,
- x.shape[2:],
- mode='bilinear',
- align_corners=self.align_corners)
+ y = F.interpolate(y, x.shape[2:], mode='bilinear', align_corners=self.align_corners)
outputs.append(y)
if self.image_pooling:
img_avg = self.global_avg_pool(x)
- img_avg = F.interpolate(
- img_avg,
- x.shape[2:],
- mode='bilinear',
- align_corners=self.align_corners)
+ img_avg = F.interpolate(img_avg, x.shape[2:], mode='bilinear', align_corners=self.align_corners)
outputs.append(img_avg)
x = paddle.concat(outputs, axis=1)
x = self.conv_bn_relu(x)
x = self.dropout(x)
- return x
\ No newline at end of file
+ return x
diff --git a/modules/image/semantic_segmentation/ocrnet_hrnetw18_voc/module.py b/modules/image/semantic_segmentation/ocrnet_hrnetw18_voc/module.py
index 1973f974..73f5fe99 100644
--- a/modules/image/semantic_segmentation/ocrnet_hrnetw18_voc/module.py
+++ b/modules/image/semantic_segmentation/ocrnet_hrnetw18_voc/module.py
@@ -25,6 +25,7 @@ from paddlehub.module.cv_module import ImageSegmentationModule
import ocrnet_hrnetw18_voc.layers as L
from ocrnet_hrnetw18_voc.hrnet import HRNet_W18
+
@moduleinfo(
name="ocrnet_hrnetw18_voc",
type="CV/semantic_segmentation",
@@ -90,11 +91,8 @@ class OCRNetHRNetW18(nn.Layer):
feats = [feats[i] for i in self.backbone_indices]
logit_list = self.head(feats)
logit_list = [
- F.interpolate(
- logit,
- x.shape[2:],
- mode='bilinear',
- align_corners=self.align_corners) for logit in logit_list]
+ F.interpolate(logit, x.shape[2:], mode='bilinear', align_corners=self.align_corners) for logit in logit_list
+ ]
return logit_list
@@ -108,32 +106,23 @@ class OCRHead(nn.Layer):
ocr_key_channels(int, optional): The number of key channels in ObjectAttentionBlock. Default: 256.
"""
- def __init__(self,
- num_classes: int,
- in_channels: int,
- ocr_mid_channels: int = 512,
- ocr_key_channels: int = 256):
+ def __init__(self, num_classes: int, in_channels: int, ocr_mid_channels: int = 512, ocr_key_channels: int = 256):
super().__init__()
self.num_classes = num_classes
self.spatial_gather = SpatialGatherBlock()
- self.spatial_ocr = SpatialOCRModule(ocr_mid_channels, ocr_key_channels,
- ocr_mid_channels)
+ self.spatial_ocr = SpatialOCRModule(ocr_mid_channels, ocr_key_channels, ocr_mid_channels)
self.indices = [-2, -1] if len(in_channels) > 1 else [-1, -1]
- self.conv3x3_ocr = L.ConvBNReLU(
- in_channels[self.indices[1]], ocr_mid_channels, 3, padding=1)
+ self.conv3x3_ocr = L.ConvBNReLU(in_channels[self.indices[1]], ocr_mid_channels, 3, padding=1)
self.cls_head = nn.Conv2D(ocr_mid_channels, self.num_classes, 1)
self.aux_head = nn.Sequential(
- L.ConvBNReLU(in_channels[self.indices[0]],
- in_channels[self.indices[0]], 1),
+ L.ConvBNReLU(in_channels[self.indices[0]], in_channels[self.indices[0]], 1),
nn.Conv2D(in_channels[self.indices[0]], self.num_classes, 1))
-
def forward(self, feat_list: List[paddle.Tensor]) -> paddle.Tensor:
- feat_shallow, feat_deep = feat_list[self.indices[0]], feat_list[
- self.indices[1]]
+ feat_shallow, feat_deep = feat_list[self.indices[0]], feat_list[self.indices[1]]
soft_regions = self.aux_head(feat_shallow)
pixels = self.conv3x3_ocr(feat_deep)
@@ -171,17 +160,11 @@ class SpatialGatherBlock(nn.Layer):
class SpatialOCRModule(nn.Layer):
"""Aggregate the global object representation to update the representation for each pixel."""
- def __init__(self,
- in_channels: int,
- key_channels: int,
- out_channels: int,
- dropout_rate: float = 0.1):
+ def __init__(self, in_channels: int, key_channels: int, out_channels: int, dropout_rate: float = 0.1):
super().__init__()
self.attention_block = ObjectAttentionBlock(in_channels, key_channels)
- self.conv1x1 = nn.Sequential(
- L.ConvBNReLU(2 * in_channels, out_channels, 1),
- nn.Dropout2D(dropout_rate))
+ self.conv1x1 = nn.Sequential(L.ConvBNReLU(2 * in_channels, out_channels, 1), nn.Dropout2D(dropout_rate))
def forward(self, pixels: paddle.Tensor, regions: paddle.Tensor) -> paddle.Tensor:
context = self.attention_block(pixels, regions)
@@ -201,12 +184,10 @@ class ObjectAttentionBlock(nn.Layer):
self.key_channels = key_channels
self.f_pixel = nn.Sequential(
- L.ConvBNReLU(in_channels, key_channels, 1),
- L.ConvBNReLU(key_channels, key_channels, 1))
+ L.ConvBNReLU(in_channels, key_channels, 1), L.ConvBNReLU(key_channels, key_channels, 1))
self.f_object = nn.Sequential(
- L.ConvBNReLU(in_channels, key_channels, 1),
- L.ConvBNReLU(key_channels, key_channels, 1))
+ L.ConvBNReLU(in_channels, key_channels, 1), L.ConvBNReLU(key_channels, key_channels, 1))
self.f_down = L.ConvBNReLU(in_channels, key_channels, 1)
@@ -240,4 +221,4 @@ class ObjectAttentionBlock(nn.Layer):
context = paddle.reshape(context, (n, self.key_channels, h, w))
context = self.f_up(context)
- return context
\ No newline at end of file
+ return context
diff --git a/modules/text/language_model/bert-base-cased/README.md b/modules/text/language_model/bert-base-cased/README.md
index 3f8c657d..cd11fd8b 100644
--- a/modules/text/language_model/bert-base-cased/README.md
+++ b/modules/text/language_model/bert-base-cased/README.md
@@ -167,4 +167,4 @@ paddlehub >= 2.0.0
* 2.0.2
- 增加文本匹配任务`text-matching`
\ No newline at end of file
+ 增加文本匹配任务`text-matching`
diff --git a/modules/text/language_model/bert-base-cased/module.py b/modules/text/language_model/bert-base-cased/module.py
index af74ab5f..f5e2cc7c 100644
--- a/modules/text/language_model/bert-base-cased/module.py
+++ b/modules/text/language_model/bert-base-cased/module.py
@@ -60,29 +60,27 @@ class Bert(nn.Layer):
task = 'seq-cls'
logger.warning(
"current task name 'sequence_classification' was renamed to 'seq-cls', "
- "'sequence_classification' has been deprecated and will be removed in the future.",
- )
+ "'sequence_classification' has been deprecated and will be removed in the future.", )
if task == 'seq-cls':
- self.model = BertForSequenceClassification.from_pretrained(pretrained_model_name_or_path='bert-base-cased', num_classes=self.num_classes, **kwargs)
+ self.model = BertForSequenceClassification.from_pretrained(
+ pretrained_model_name_or_path='bert-base-cased', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task == 'token-cls':
- self.model = BertForTokenClassification.from_pretrained(pretrained_model_name_or_path='bert-base-cased', num_classes=self.num_classes, **kwargs)
+ self.model = BertForTokenClassification.from_pretrained(
+ pretrained_model_name_or_path='bert-base-cased', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
- self.metric = ChunkEvaluator(
- label_list=[self.label_map[i] for i in sorted(self.label_map.keys())]
- )
+ self.metric = ChunkEvaluator(label_list=[self.label_map[i] for i in sorted(self.label_map.keys())])
elif task == 'text-matching':
self.model = BertModel.from_pretrained(pretrained_model_name_or_path='bert-base-cased', **kwargs)
self.dropout = paddle.nn.Dropout(0.1)
- self.classifier = paddle.nn.Linear(self.model.config['hidden_size']*3, 2)
+ self.classifier = paddle.nn.Linear(self.model.config['hidden_size'] * 3, 2)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task is None:
self.model = BertModel.from_pretrained(pretrained_model_name_or_path='bert-base-cased', **kwargs)
else:
- raise RuntimeError("Unknown task {}, task should be one in {}".format(
- task, self._tasks_supported))
+ raise RuntimeError("Unknown task {}, task should be one in {}".format(task, self._tasks_supported))
self.task = task
@@ -130,8 +128,7 @@ class Bert(nn.Layer):
loss = self.criterion(logits, labels.unsqueeze(-1))
num_infer_chunks, num_label_chunks, num_correct_chunks = \
self.metric.compute(None, seq_lengths, preds, labels)
- self.metric.update(
- num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
+ self.metric.update(num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
_, _, f1_score = map(float, self.metric.accumulate())
return token_level_probs, loss, {'f1_score': f1_score}
return token_level_probs
@@ -173,5 +170,4 @@ class Bert(nn.Layer):
"""
Gets the tokenizer that is customized for this module.
"""
- return BertTokenizer.from_pretrained(
- pretrained_model_name_or_path='bert-base-cased', *args, **kwargs)
+ return BertTokenizer.from_pretrained(pretrained_model_name_or_path='bert-base-cased', *args, **kwargs)
diff --git a/modules/text/language_model/bert-base-chinese/README.md b/modules/text/language_model/bert-base-chinese/README.md
index 52fb33a6..79007b08 100644
--- a/modules/text/language_model/bert-base-chinese/README.md
+++ b/modules/text/language_model/bert-base-chinese/README.md
@@ -166,4 +166,4 @@ paddlehub >= 2.0.0
* 2.0.2
- 增加文本匹配任务`text-matching`
\ No newline at end of file
+ 增加文本匹配任务`text-matching`
diff --git a/modules/text/language_model/bert-base-chinese/module.py b/modules/text/language_model/bert-base-chinese/module.py
index 443e56b1..13457527 100644
--- a/modules/text/language_model/bert-base-chinese/module.py
+++ b/modules/text/language_model/bert-base-chinese/module.py
@@ -60,37 +60,27 @@ class Bert(nn.Layer):
task = 'seq-cls'
logger.warning(
"current task name 'sequence_classification' was renamed to 'seq-cls', "
- "'sequence_classification' has been deprecated and will be removed in the future.",
- )
+ "'sequence_classification' has been deprecated and will be removed in the future.", )
if task == 'seq-cls':
self.model = BertForSequenceClassification.from_pretrained(
- pretrained_model_name_or_path='bert-base-chinese',
- num_classes=self.num_classes,
- **kwargs
- )
+ pretrained_model_name_or_path='bert-base-chinese', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task == 'token-cls':
self.model = BertForTokenClassification.from_pretrained(
- pretrained_model_name_or_path='bert-base-chinese',
- num_classes=self.num_classes,
- **kwargs
- )
+ pretrained_model_name_or_path='bert-base-chinese', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
- self.metric = ChunkEvaluator(
- label_list=[self.label_map[i] for i in sorted(self.label_map.keys())]
- )
+ self.metric = ChunkEvaluator(label_list=[self.label_map[i] for i in sorted(self.label_map.keys())])
elif task == 'text-matching':
self.model = BertModel.from_pretrained(pretrained_model_name_or_path='bert-base-chinese', **kwargs)
self.dropout = paddle.nn.Dropout(0.1)
- self.classifier = paddle.nn.Linear(self.model.config['hidden_size']*3, 2)
+ self.classifier = paddle.nn.Linear(self.model.config['hidden_size'] * 3, 2)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task is None:
self.model = BertModel.from_pretrained(pretrained_model_name_or_path='bert-base-chinese', **kwargs)
else:
- raise RuntimeError("Unknown task {}, task should be one in {}".format(
- task, self._tasks_supported))
+ raise RuntimeError("Unknown task {}, task should be one in {}".format(task, self._tasks_supported))
self.task = task
@@ -138,8 +128,7 @@ class Bert(nn.Layer):
loss = self.criterion(logits, labels.unsqueeze(-1))
num_infer_chunks, num_label_chunks, num_correct_chunks = \
self.metric.compute(None, seq_lengths, preds, labels)
- self.metric.update(
- num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
+ self.metric.update(num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
_, _, f1_score = map(float, self.metric.accumulate())
return token_level_probs, loss, {'f1_score': f1_score}
return token_level_probs
@@ -181,5 +170,4 @@ class Bert(nn.Layer):
"""
Gets the tokenizer that is customized for this module.
"""
- return BertTokenizer.from_pretrained(
- pretrained_model_name_or_path='bert-base-chinese', *args, **kwargs)
+ return BertTokenizer.from_pretrained(pretrained_model_name_or_path='bert-base-chinese', *args, **kwargs)
diff --git a/modules/text/language_model/bert-base-multilingual-cased/README.md b/modules/text/language_model/bert-base-multilingual-cased/README.md
index bd3355a8..88b0b791 100644
--- a/modules/text/language_model/bert-base-multilingual-cased/README.md
+++ b/modules/text/language_model/bert-base-multilingual-cased/README.md
@@ -166,4 +166,4 @@ paddlehub >= 2.0.0
* 2.0.2
- 增加文本匹配任务`text-matching`
\ No newline at end of file
+ 增加文本匹配任务`text-matching`
diff --git a/modules/text/language_model/bert-base-multilingual-cased/module.py b/modules/text/language_model/bert-base-multilingual-cased/module.py
index e1c79e94..2f4fa756 100644
--- a/modules/text/language_model/bert-base-multilingual-cased/module.py
+++ b/modules/text/language_model/bert-base-multilingual-cased/module.py
@@ -60,37 +60,29 @@ class Bert(nn.Layer):
task = 'seq-cls'
logger.warning(
"current task name 'sequence_classification' was renamed to 'seq-cls', "
- "'sequence_classification' has been deprecated and will be removed in the future.",
- )
+ "'sequence_classification' has been deprecated and will be removed in the future.", )
if task == 'seq-cls':
self.model = BertForSequenceClassification.from_pretrained(
- pretrained_model_name_or_path='bert-base-multilingual-cased',
- num_classes=self.num_classes,
- **kwargs
- )
+ pretrained_model_name_or_path='bert-base-multilingual-cased', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task == 'token-cls':
self.model = BertForTokenClassification.from_pretrained(
- pretrained_model_name_or_path='bert-base-multilingual-cased',
- num_classes=self.num_classes,
- **kwargs
- )
+ pretrained_model_name_or_path='bert-base-multilingual-cased', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
- self.metric = ChunkEvaluator(
- label_list=[self.label_map[i] for i in sorted(self.label_map.keys())]
- )
+ self.metric = ChunkEvaluator(label_list=[self.label_map[i] for i in sorted(self.label_map.keys())])
elif task == 'text-matching':
- self.model = BertModel.from_pretrained(pretrained_model_name_or_path='bert-base-multilingual-cased', **kwargs)
+ self.model = BertModel.from_pretrained(
+ pretrained_model_name_or_path='bert-base-multilingual-cased', **kwargs)
self.dropout = paddle.nn.Dropout(0.1)
- self.classifier = paddle.nn.Linear(self.model.config['hidden_size']*3, 2)
+ self.classifier = paddle.nn.Linear(self.model.config['hidden_size'] * 3, 2)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task is None:
- self.model = BertModel.from_pretrained(pretrained_model_name_or_path='bert-base-multilingual-cased', **kwargs)
+ self.model = BertModel.from_pretrained(
+ pretrained_model_name_or_path='bert-base-multilingual-cased', **kwargs)
else:
- raise RuntimeError("Unknown task {}, task should be one in {}".format(
- task, self._tasks_supported))
+ raise RuntimeError("Unknown task {}, task should be one in {}".format(task, self._tasks_supported))
self.task = task
@@ -138,8 +130,7 @@ class Bert(nn.Layer):
loss = self.criterion(logits, labels.unsqueeze(-1))
num_infer_chunks, num_label_chunks, num_correct_chunks = \
self.metric.compute(None, seq_lengths, preds, labels)
- self.metric.update(
- num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
+ self.metric.update(num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
_, _, f1_score = map(float, self.metric.accumulate())
return token_level_probs, loss, {'f1_score': f1_score}
return token_level_probs
diff --git a/modules/text/language_model/bert-base-multilingual-uncased/README.md b/modules/text/language_model/bert-base-multilingual-uncased/README.md
index 8ff20880..3b8b2c13 100644
--- a/modules/text/language_model/bert-base-multilingual-uncased/README.md
+++ b/modules/text/language_model/bert-base-multilingual-uncased/README.md
@@ -166,4 +166,4 @@ paddlehub >= 2.0.0
* 2.0.2
- 增加文本匹配任务`text-matching`
\ No newline at end of file
+ 增加文本匹配任务`text-matching`
diff --git a/modules/text/language_model/bert-base-multilingual-uncased/module.py b/modules/text/language_model/bert-base-multilingual-uncased/module.py
index 82fc6a4b..515a6f5f 100644
--- a/modules/text/language_model/bert-base-multilingual-uncased/module.py
+++ b/modules/text/language_model/bert-base-multilingual-uncased/module.py
@@ -60,37 +60,29 @@ class Bert(nn.Layer):
task = 'seq-cls'
logger.warning(
"current task name 'sequence_classification' was renamed to 'seq-cls', "
- "'sequence_classification' has been deprecated and will be removed in the future.",
- )
+ "'sequence_classification' has been deprecated and will be removed in the future.", )
if task == 'seq-cls':
self.model = BertForSequenceClassification.from_pretrained(
- pretrained_model_name_or_path='bert-base-multilingual-uncased',
- num_classes=self.num_classes,
- **kwargs
- )
+ pretrained_model_name_or_path='bert-base-multilingual-uncased', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task == 'token-cls':
self.model = BertForTokenClassification.from_pretrained(
- pretrained_model_name_or_path='bert-base-multilingual-uncased',
- num_classes=self.num_classes,
- **kwargs
- )
+ pretrained_model_name_or_path='bert-base-multilingual-uncased', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
- self.metric = ChunkEvaluator(
- label_list=[self.label_map[i] for i in sorted(self.label_map.keys())]
- )
+ self.metric = ChunkEvaluator(label_list=[self.label_map[i] for i in sorted(self.label_map.keys())])
elif task == 'text-matching':
- self.model = BertModel.from_pretrained(pretrained_model_name_or_path='bert-base-multilingual-uncased', **kwargs)
+ self.model = BertModel.from_pretrained(
+ pretrained_model_name_or_path='bert-base-multilingual-uncased', **kwargs)
self.dropout = paddle.nn.Dropout(0.1)
- self.classifier = paddle.nn.Linear(self.model.config['hidden_size']*3, 2)
+ self.classifier = paddle.nn.Linear(self.model.config['hidden_size'] * 3, 2)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task is None:
- self.model = BertModel.from_pretrained(pretrained_model_name_or_path='bert-base-multilingual-uncased', **kwargs)
+ self.model = BertModel.from_pretrained(
+ pretrained_model_name_or_path='bert-base-multilingual-uncased', **kwargs)
else:
- raise RuntimeError("Unknown task {}, task should be one in {}".format(
- task, self._tasks_supported))
+ raise RuntimeError("Unknown task {}, task should be one in {}".format(task, self._tasks_supported))
self.task = task
@@ -138,8 +130,7 @@ class Bert(nn.Layer):
loss = self.criterion(logits, labels.unsqueeze(-1))
num_infer_chunks, num_label_chunks, num_correct_chunks = \
self.metric.compute(None, seq_lengths, preds, labels)
- self.metric.update(
- num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
+ self.metric.update(num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
_, _, f1_score = map(float, self.metric.accumulate())
return token_level_probs, loss, {'f1_score': f1_score}
return token_level_probs
diff --git a/modules/text/language_model/bert-base-uncased/README.md b/modules/text/language_model/bert-base-uncased/README.md
index 0d42f276..83033e81 100644
--- a/modules/text/language_model/bert-base-uncased/README.md
+++ b/modules/text/language_model/bert-base-uncased/README.md
@@ -166,4 +166,4 @@ paddlehub >= 2.0.0
* 2.0.2
- 增加文本匹配任务`text-matching`
\ No newline at end of file
+ 增加文本匹配任务`text-matching`
diff --git a/modules/text/language_model/bert-base-uncased/module.py b/modules/text/language_model/bert-base-uncased/module.py
index 876d1a52..e3914715 100644
--- a/modules/text/language_model/bert-base-uncased/module.py
+++ b/modules/text/language_model/bert-base-uncased/module.py
@@ -60,29 +60,27 @@ class Bert(nn.Layer):
task = 'seq-cls'
logger.warning(
"current task name 'sequence_classification' was renamed to 'seq-cls', "
- "'sequence_classification' has been deprecated and will be removed in the future.",
- )
+ "'sequence_classification' has been deprecated and will be removed in the future.", )
if task == 'seq-cls':
- self.model = BertForSequenceClassification.from_pretrained(pretrained_model_name_or_path='bert-base-uncased', num_classes=self.num_classes, **kwargs)
+ self.model = BertForSequenceClassification.from_pretrained(
+ pretrained_model_name_or_path='bert-base-uncased', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task == 'token-cls':
- self.model = BertForTokenClassification.from_pretrained(pretrained_model_name_or_path='bert-base-uncased', num_classes=self.num_classes, **kwargs)
+ self.model = BertForTokenClassification.from_pretrained(
+ pretrained_model_name_or_path='bert-base-uncased', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
- self.metric = ChunkEvaluator(
- label_list=[self.label_map[i] for i in sorted(self.label_map.keys())]
- )
+ self.metric = ChunkEvaluator(label_list=[self.label_map[i] for i in sorted(self.label_map.keys())])
elif task == 'text-matching':
self.model = BertModel.from_pretrained(pretrained_model_name_or_path='bert-base-uncased', **kwargs)
self.dropout = paddle.nn.Dropout(0.1)
- self.classifier = paddle.nn.Linear(self.model.config['hidden_size']*3, 2)
+ self.classifier = paddle.nn.Linear(self.model.config['hidden_size'] * 3, 2)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task is None:
self.model = BertModel.from_pretrained(pretrained_model_name_or_path='bert-base-uncased', **kwargs)
else:
- raise RuntimeError("Unknown task {}, task should be one in {}".format(
- task, self._tasks_supported))
+ raise RuntimeError("Unknown task {}, task should be one in {}".format(task, self._tasks_supported))
self.task = task
@@ -130,8 +128,7 @@ class Bert(nn.Layer):
loss = self.criterion(logits, labels.unsqueeze(-1))
num_infer_chunks, num_label_chunks, num_correct_chunks = \
self.metric.compute(None, seq_lengths, preds, labels)
- self.metric.update(
- num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
+ self.metric.update(num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
_, _, f1_score = map(float, self.metric.accumulate())
return token_level_probs, loss, {'f1_score': f1_score}
return token_level_probs
@@ -173,5 +170,4 @@ class Bert(nn.Layer):
"""
Gets the tokenizer that is customized for this module.
"""
- return BertTokenizer.from_pretrained(
- pretrained_model_name_or_path='bert-base-uncased', *args, **kwargs)
+ return BertTokenizer.from_pretrained(pretrained_model_name_or_path='bert-base-uncased', *args, **kwargs)
diff --git a/modules/text/language_model/bert-large-cased/README.md b/modules/text/language_model/bert-large-cased/README.md
index 376e9fbc..a815de30 100644
--- a/modules/text/language_model/bert-large-cased/README.md
+++ b/modules/text/language_model/bert-large-cased/README.md
@@ -166,4 +166,4 @@ paddlehub >= 2.0.0
* 2.0.2
- 增加文本匹配任务`text-matching`
\ No newline at end of file
+ 增加文本匹配任务`text-matching`
diff --git a/modules/text/language_model/bert-large-cased/module.py b/modules/text/language_model/bert-large-cased/module.py
index b60eae26..a834167b 100644
--- a/modules/text/language_model/bert-large-cased/module.py
+++ b/modules/text/language_model/bert-large-cased/module.py
@@ -60,29 +60,27 @@ class Bert(nn.Layer):
task = 'seq-cls'
logger.warning(
"current task name 'sequence_classification' was renamed to 'seq-cls', "
- "'sequence_classification' has been deprecated and will be removed in the future.",
- )
+ "'sequence_classification' has been deprecated and will be removed in the future.", )
if task == 'seq-cls':
- self.model = BertForSequenceClassification.from_pretrained(pretrained_model_name_or_path='bert-large-cased', num_classes=self.num_classes, **kwargs)
+ self.model = BertForSequenceClassification.from_pretrained(
+ pretrained_model_name_or_path='bert-large-cased', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task == 'token-cls':
- self.model = BertForTokenClassification.from_pretrained(pretrained_model_name_or_path='bert-large-cased', num_classes=self.num_classes, **kwargs)
+ self.model = BertForTokenClassification.from_pretrained(
+ pretrained_model_name_or_path='bert-large-cased', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
- self.metric = ChunkEvaluator(
- label_list=[self.label_map[i] for i in sorted(self.label_map.keys())]
- )
+ self.metric = ChunkEvaluator(label_list=[self.label_map[i] for i in sorted(self.label_map.keys())])
elif task == 'text-matching':
self.model = BertModel.from_pretrained(pretrained_model_name_or_path='bert-large-cased', **kwargs)
self.dropout = paddle.nn.Dropout(0.1)
- self.classifier = paddle.nn.Linear(self.model.config['hidden_size']*3, 2)
+ self.classifier = paddle.nn.Linear(self.model.config['hidden_size'] * 3, 2)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task is None:
self.model = BertModel.from_pretrained(pretrained_model_name_or_path='bert-large-cased', **kwargs)
else:
- raise RuntimeError("Unknown task {}, task should be one in {}".format(
- task, self._tasks_supported))
+ raise RuntimeError("Unknown task {}, task should be one in {}".format(task, self._tasks_supported))
self.task = task
@@ -130,8 +128,7 @@ class Bert(nn.Layer):
loss = self.criterion(logits, labels.unsqueeze(-1))
num_infer_chunks, num_label_chunks, num_correct_chunks = \
self.metric.compute(None, seq_lengths, preds, labels)
- self.metric.update(
- num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
+ self.metric.update(num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
_, _, f1_score = map(float, self.metric.accumulate())
return token_level_probs, loss, {'f1_score': f1_score}
return token_level_probs
@@ -173,5 +170,4 @@ class Bert(nn.Layer):
"""
Gets the tokenizer that is customized for this module.
"""
- return BertTokenizer.from_pretrained(
- pretrained_model_name_or_path='bert-large-cased', *args, **kwargs)
+ return BertTokenizer.from_pretrained(pretrained_model_name_or_path='bert-large-cased', *args, **kwargs)
diff --git a/modules/text/language_model/bert-large-uncased/README.md b/modules/text/language_model/bert-large-uncased/README.md
index 072bfcba..6de8deeb 100644
--- a/modules/text/language_model/bert-large-uncased/README.md
+++ b/modules/text/language_model/bert-large-uncased/README.md
@@ -166,4 +166,4 @@ paddlehub >= 2.0.0
* 2.0.2
- 增加文本匹配任务`text-matching`
\ No newline at end of file
+ 增加文本匹配任务`text-matching`
diff --git a/modules/text/language_model/bert-large-uncased/module.py b/modules/text/language_model/bert-large-uncased/module.py
index 026d8188..157fe9aa 100644
--- a/modules/text/language_model/bert-large-uncased/module.py
+++ b/modules/text/language_model/bert-large-uncased/module.py
@@ -60,29 +60,27 @@ class Bert(nn.Layer):
task = 'seq-cls'
logger.warning(
"current task name 'sequence_classification' was renamed to 'seq-cls', "
- "'sequence_classification' has been deprecated and will be removed in the future.",
- )
+ "'sequence_classification' has been deprecated and will be removed in the future.", )
if task == 'seq-cls':
- self.model = BertForSequenceClassification.from_pretrained(pretrained_model_name_or_path='bert-large-uncased', num_classes=self.num_classes, **kwargs)
+ self.model = BertForSequenceClassification.from_pretrained(
+ pretrained_model_name_or_path='bert-large-uncased', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task == 'token-cls':
- self.model = BertForTokenClassification.from_pretrained(pretrained_model_name_or_path='bert-large-uncased', num_classes=self.num_classes, **kwargs)
+ self.model = BertForTokenClassification.from_pretrained(
+ pretrained_model_name_or_path='bert-large-uncased', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
- self.metric = ChunkEvaluator(
- label_list=[self.label_map[i] for i in sorted(self.label_map.keys())]
- )
+ self.metric = ChunkEvaluator(label_list=[self.label_map[i] for i in sorted(self.label_map.keys())])
elif task == 'text-matching':
self.model = BertModel.from_pretrained(pretrained_model_name_or_path='bert-large-uncased', **kwargs)
self.dropout = paddle.nn.Dropout(0.1)
- self.classifier = paddle.nn.Linear(self.model.config['hidden_size']*3, 2)
+ self.classifier = paddle.nn.Linear(self.model.config['hidden_size'] * 3, 2)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task is None:
self.model = BertModel.from_pretrained(pretrained_model_name_or_path='bert-large-uncased', **kwargs)
else:
- raise RuntimeError("Unknown task {}, task should be one in {}".format(
- task, self._tasks_supported))
+ raise RuntimeError("Unknown task {}, task should be one in {}".format(task, self._tasks_supported))
self.task = task
@@ -130,8 +128,7 @@ class Bert(nn.Layer):
loss = self.criterion(logits, labels.unsqueeze(-1))
num_infer_chunks, num_label_chunks, num_correct_chunks = \
self.metric.compute(None, seq_lengths, preds, labels)
- self.metric.update(
- num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
+ self.metric.update(num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
_, _, f1_score = map(float, self.metric.accumulate())
return token_level_probs, loss, {'f1_score': f1_score}
return token_level_probs
@@ -173,5 +170,4 @@ class Bert(nn.Layer):
"""
Gets the tokenizer that is customized for this module.
"""
- return BertTokenizer.from_pretrained(
- pretrained_model_name_or_path='bert-large-uncased', *args, **kwargs)
+ return BertTokenizer.from_pretrained(pretrained_model_name_or_path='bert-large-uncased', *args, **kwargs)
diff --git a/modules/text/language_model/chinese_bert_wwm/README.md b/modules/text/language_model/chinese_bert_wwm/README.md
index 734a203e..12926937 100644
--- a/modules/text/language_model/chinese_bert_wwm/README.md
+++ b/modules/text/language_model/chinese_bert_wwm/README.md
@@ -152,11 +152,11 @@ paddlehub >= 2.0.0
* 1.0.0
初始发布
-
+
* 2.0.0
全面升级动态图,接口有所变化。任务名称调整,增加序列标注任务`token-cls`
* 2.0.1
- 增加文本匹配任务`text-matching`
\ No newline at end of file
+ 增加文本匹配任务`text-matching`
diff --git a/modules/text/language_model/chinese_bert_wwm/module.py b/modules/text/language_model/chinese_bert_wwm/module.py
index 259f8b42..4490bfc4 100644
--- a/modules/text/language_model/chinese_bert_wwm/module.py
+++ b/modules/text/language_model/chinese_bert_wwm/module.py
@@ -35,8 +35,7 @@ from paddlehub.utils.log import logger
author="ymcui",
author_email="ymcui@ir.hit.edu.cn",
type="nlp/semantic_model",
- meta=TransformerModule
-)
+ meta=TransformerModule)
class BertWwm(nn.Layer):
"""
BertWwm model
@@ -61,37 +60,27 @@ class BertWwm(nn.Layer):
task = 'seq-cls'
logger.warning(
"current task name 'sequence_classification' was renamed to 'seq-cls', "
- "'sequence_classification' has been deprecated and will be removed in the future.",
- )
+ "'sequence_classification' has been deprecated and will be removed in the future.", )
if task == 'seq-cls':
self.model = BertForSequenceClassification.from_pretrained(
- pretrained_model_name_or_path='bert-wwm-chinese',
- num_classes=self.num_classes,
- **kwargs
- )
+ pretrained_model_name_or_path='bert-wwm-chinese', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task == 'token-cls':
self.model = BertForTokenClassification.from_pretrained(
- pretrained_model_name_or_path='bert-wwm-chinese',
- num_classes=self.num_classes,
- **kwargs
- )
+ pretrained_model_name_or_path='bert-wwm-chinese', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
- self.metric = ChunkEvaluator(
- label_list=[self.label_map[i] for i in sorted(self.label_map.keys())]
- )
+ self.metric = ChunkEvaluator(label_list=[self.label_map[i] for i in sorted(self.label_map.keys())])
elif task == 'text-matching':
self.model = BertModel.from_pretrained(pretrained_model_name_or_path='bert-wwm-chinese', **kwargs)
self.dropout = paddle.nn.Dropout(0.1)
- self.classifier = paddle.nn.Linear(self.model.config['hidden_size']*3, 2)
+ self.classifier = paddle.nn.Linear(self.model.config['hidden_size'] * 3, 2)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task is None:
self.model = BertModel.from_pretrained(pretrained_model_name_or_path='bert-wwm-chinese', **kwargs)
else:
- raise RuntimeError("Unknown task {}, task should be one in {}".format(
- task, self._tasks_supported))
+ raise RuntimeError("Unknown task {}, task should be one in {}".format(task, self._tasks_supported))
self.task = task
@@ -139,8 +128,7 @@ class BertWwm(nn.Layer):
loss = self.criterion(logits, labels.unsqueeze(-1))
num_infer_chunks, num_label_chunks, num_correct_chunks = \
self.metric.compute(None, seq_lengths, preds, labels)
- self.metric.update(
- num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
+ self.metric.update(num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
_, _, f1_score = map(float, self.metric.accumulate())
return token_level_probs, loss, {'f1_score': f1_score}
return token_level_probs
@@ -182,5 +170,4 @@ class BertWwm(nn.Layer):
"""
Gets the tokenizer that is customized for this module.
"""
- return BertTokenizer.from_pretrained(
- pretrained_model_name_or_path='bert-wwm-chinese', *args, **kwargs)
+ return BertTokenizer.from_pretrained(pretrained_model_name_or_path='bert-wwm-chinese', *args, **kwargs)
diff --git a/modules/text/language_model/chinese_bert_wwm_ext/README.md b/modules/text/language_model/chinese_bert_wwm_ext/README.md
index 5aac1aee..28935b5c 100644
--- a/modules/text/language_model/chinese_bert_wwm_ext/README.md
+++ b/modules/text/language_model/chinese_bert_wwm_ext/README.md
@@ -159,4 +159,4 @@ paddlehub >= 2.0.0
* 2.0.1
- 增加文本匹配任务`text-matching`
\ No newline at end of file
+ 增加文本匹配任务`text-matching`
diff --git a/modules/text/language_model/chinese_bert_wwm_ext/module.py b/modules/text/language_model/chinese_bert_wwm_ext/module.py
index 8e6e8c6f..589c9226 100644
--- a/modules/text/language_model/chinese_bert_wwm_ext/module.py
+++ b/modules/text/language_model/chinese_bert_wwm_ext/module.py
@@ -35,8 +35,7 @@ from paddlehub.utils.log import logger
author="ymcui",
author_email="ymcui@ir.hit.edu.cn",
type="nlp/semantic_model",
- meta=TransformerModule
-)
+ meta=TransformerModule)
class BertWwm(nn.Layer):
"""
BertWwm model
@@ -61,37 +60,27 @@ class BertWwm(nn.Layer):
task = 'seq-cls'
logger.warning(
"current task name 'sequence_classification' was renamed to 'seq-cls', "
- "'sequence_classification' has been deprecated and will be removed in the future.",
- )
+ "'sequence_classification' has been deprecated and will be removed in the future.", )
if task == 'seq-cls':
self.model = BertForSequenceClassification.from_pretrained(
- pretrained_model_name_or_path='bert-wwm-ext-chinese',
- num_classes=self.num_classes,
- **kwargs
- )
+ pretrained_model_name_or_path='bert-wwm-ext-chinese', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task == 'token-cls':
self.model = BertForTokenClassification.from_pretrained(
- pretrained_model_name_or_path='bert-wwm-ext-chinese',
- num_classes=self.num_classes,
- **kwargs
- )
+ pretrained_model_name_or_path='bert-wwm-ext-chinese', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
- self.metric = ChunkEvaluator(
- label_list=[self.label_map[i] for i in sorted(self.label_map.keys())]
- )
+ self.metric = ChunkEvaluator(label_list=[self.label_map[i] for i in sorted(self.label_map.keys())])
elif task == 'text-matching':
self.model = BertModel.from_pretrained(pretrained_model_name_or_path='bert-wwm-ext-chinese', **kwargs)
self.dropout = paddle.nn.Dropout(0.1)
- self.classifier = paddle.nn.Linear(self.model.config['hidden_size']*3, 2)
+ self.classifier = paddle.nn.Linear(self.model.config['hidden_size'] * 3, 2)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task is None:
self.model = BertModel.from_pretrained(pretrained_model_name_or_path='bert-wwm-ext-chinese', **kwargs)
else:
- raise RuntimeError("Unknown task {}, task should be one in {}".format(
- task, self._tasks_supported))
+ raise RuntimeError("Unknown task {}, task should be one in {}".format(task, self._tasks_supported))
self.task = task
@@ -139,8 +128,7 @@ class BertWwm(nn.Layer):
loss = self.criterion(logits, labels.unsqueeze(-1))
num_infer_chunks, num_label_chunks, num_correct_chunks = \
self.metric.compute(None, seq_lengths, preds, labels)
- self.metric.update(
- num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
+ self.metric.update(num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
_, _, f1_score = map(float, self.metric.accumulate())
return token_level_probs, loss, {'f1_score': f1_score}
return token_level_probs
@@ -182,5 +170,4 @@ class BertWwm(nn.Layer):
"""
Gets the tokenizer that is customized for this module.
"""
- return BertTokenizer.from_pretrained(
- pretrained_model_name_or_path='bert-wwm-ext-chinese', *args, **kwargs)
+ return BertTokenizer.from_pretrained(pretrained_model_name_or_path='bert-wwm-ext-chinese', *args, **kwargs)
diff --git a/modules/text/language_model/chinese_electra_base/README.md b/modules/text/language_model/chinese_electra_base/README.md
index ea96ff39..6cf0eaad 100644
--- a/modules/text/language_model/chinese_electra_base/README.md
+++ b/modules/text/language_model/chinese_electra_base/README.md
@@ -151,11 +151,11 @@ paddlehub >= 2.0.0
* 1.0.0
初始发布
-
+
* 2.0.0
全面升级动态图,接口有所变化。任务名称调整,增加序列标注任务`token-cls`
* 2.0.1
- 增加文本匹配任务`text-matching`
\ No newline at end of file
+ 增加文本匹配任务`text-matching`
diff --git a/modules/text/language_model/chinese_electra_base/module.py b/modules/text/language_model/chinese_electra_base/module.py
index 84e32039..b9040911 100644
--- a/modules/text/language_model/chinese_electra_base/module.py
+++ b/modules/text/language_model/chinese_electra_base/module.py
@@ -60,37 +60,27 @@ class Electra(nn.Layer):
task = 'seq-cls'
logger.warning(
"current task name 'sequence_classification' was renamed to 'seq-cls', "
- "'sequence_classification' has been deprecated and will be removed in the future.",
- )
+ "'sequence_classification' has been deprecated and will be removed in the future.", )
if task == 'seq-cls':
self.model = ElectraForSequenceClassification.from_pretrained(
- pretrained_model_name_or_path='chinese-electra-base',
- num_classes=self.num_classes,
- **kwargs
- )
+ pretrained_model_name_or_path='chinese-electra-base', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task == 'token-cls':
self.model = ElectraForTokenClassification.from_pretrained(
- pretrained_model_name_or_path='chinese-electra-base',
- num_classes=self.num_classes,
- **kwargs
- )
+ pretrained_model_name_or_path='chinese-electra-base', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
- self.metric = ChunkEvaluator(
- label_list=[self.label_map[i] for i in sorted(self.label_map.keys())]
- )
+ self.metric = ChunkEvaluator(label_list=[self.label_map[i] for i in sorted(self.label_map.keys())])
elif task == 'text-matching':
self.model = ElectraModel.from_pretrained(pretrained_model_name_or_path='chinese-electra-base', **kwargs)
self.dropout = paddle.nn.Dropout(0.1)
- self.classifier = paddle.nn.Linear(self.model.config['hidden_size']*3, 2)
+ self.classifier = paddle.nn.Linear(self.model.config['hidden_size'] * 3, 2)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task is None:
self.model = ElectraModel.from_pretrained(pretrained_model_name_or_path='chinese-electra-base', **kwargs)
else:
- raise RuntimeError("Unknown task {}, task should be one in {}".format(
- task, self._tasks_supported))
+ raise RuntimeError("Unknown task {}, task should be one in {}".format(task, self._tasks_supported))
self.task = task
@@ -138,8 +128,7 @@ class Electra(nn.Layer):
loss = self.criterion(logits, labels.unsqueeze(-1))
num_infer_chunks, num_label_chunks, num_correct_chunks = \
self.metric.compute(None, seq_lengths, preds, labels)
- self.metric.update(
- num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
+ self.metric.update(num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
_, _, f1_score = map(float, self.metric.accumulate())
return token_level_probs, loss, {'f1_score': f1_score}
return token_level_probs
@@ -181,5 +170,4 @@ class Electra(nn.Layer):
"""
Gets the tokenizer that is customized for this module.
"""
- return ElectraTokenizer.from_pretrained(
- pretrained_model_name_or_path='chinese-electra-base', *args, **kwargs)
+ return ElectraTokenizer.from_pretrained(pretrained_model_name_or_path='chinese-electra-base', *args, **kwargs)
diff --git a/modules/text/language_model/chinese_electra_small/README.md b/modules/text/language_model/chinese_electra_small/README.md
index 620ae041..0a006ae5 100644
--- a/modules/text/language_model/chinese_electra_small/README.md
+++ b/modules/text/language_model/chinese_electra_small/README.md
@@ -158,4 +158,4 @@ paddlehub >= 2.0.0
* 2.0.1
- 增加文本匹配任务`text-matching`
\ No newline at end of file
+ 增加文本匹配任务`text-matching`
diff --git a/modules/text/language_model/chinese_electra_small/module.py b/modules/text/language_model/chinese_electra_small/module.py
index 03401f01..ad962325 100644
--- a/modules/text/language_model/chinese_electra_small/module.py
+++ b/modules/text/language_model/chinese_electra_small/module.py
@@ -60,37 +60,27 @@ class Electra(nn.Layer):
task = 'seq-cls'
logger.warning(
"current task name 'sequence_classification' was renamed to 'seq-cls', "
- "'sequence_classification' has been deprecated and will be removed in the future.",
- )
+ "'sequence_classification' has been deprecated and will be removed in the future.", )
if task == 'seq-cls':
self.model = ElectraForSequenceClassification.from_pretrained(
- pretrained_model_name_or_path='chinese-electra-small',
- num_classes=self.num_classes,
- **kwargs
- )
+ pretrained_model_name_or_path='chinese-electra-small', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task == 'token-cls':
self.model = ElectraForTokenClassification.from_pretrained(
- pretrained_model_name_or_path='chinese-electra-small',
- num_classes=self.num_classes,
- **kwargs
- )
+ pretrained_model_name_or_path='chinese-electra-small', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
- self.metric = ChunkEvaluator(
- label_list=[self.label_map[i] for i in sorted(self.label_map.keys())]
- )
+ self.metric = ChunkEvaluator(label_list=[self.label_map[i] for i in sorted(self.label_map.keys())])
elif task == 'text-matching':
self.model = ElectraModel.from_pretrained(pretrained_model_name_or_path='chinese-electra-small', **kwargs)
self.dropout = paddle.nn.Dropout(0.1)
- self.classifier = paddle.nn.Linear(self.model.config['hidden_size']*3, 2)
+ self.classifier = paddle.nn.Linear(self.model.config['hidden_size'] * 3, 2)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task is None:
self.model = ElectraModel.from_pretrained(pretrained_model_name_or_path='chinese-electra-small', **kwargs)
else:
- raise RuntimeError("Unknown task {}, task should be one in {}".format(
- task, self._tasks_supported))
+ raise RuntimeError("Unknown task {}, task should be one in {}".format(task, self._tasks_supported))
self.task = task
@@ -138,8 +128,7 @@ class Electra(nn.Layer):
loss = self.criterion(logits, labels.unsqueeze(-1))
num_infer_chunks, num_label_chunks, num_correct_chunks = \
self.metric.compute(None, seq_lengths, preds, labels)
- self.metric.update(
- num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
+ self.metric.update(num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
_, _, f1_score = map(float, self.metric.accumulate())
return token_level_probs, loss, {'f1_score': f1_score}
return token_level_probs
@@ -181,5 +170,4 @@ class Electra(nn.Layer):
"""
Gets the tokenizer that is customized for this module.
"""
- return ElectraTokenizer.from_pretrained(
- pretrained_model_name_or_path='chinese-electra-small', *args, **kwargs)
+ return ElectraTokenizer.from_pretrained(pretrained_model_name_or_path='chinese-electra-small', *args, **kwargs)
diff --git a/modules/text/language_model/electra_base/README.md b/modules/text/language_model/electra_base/README.md
index cee97e1b..70fc1b06 100644
--- a/modules/text/language_model/electra_base/README.md
+++ b/modules/text/language_model/electra_base/README.md
@@ -154,4 +154,4 @@ paddlehub >= 2.0.0
* 1.0.1
- 增加文本匹配任务`text-matching`
\ No newline at end of file
+ 增加文本匹配任务`text-matching`
diff --git a/modules/text/language_model/electra_base/module.py b/modules/text/language_model/electra_base/module.py
index 6ef01fbb..9a4a46c9 100644
--- a/modules/text/language_model/electra_base/module.py
+++ b/modules/text/language_model/electra_base/module.py
@@ -29,8 +29,7 @@ from paddlehub.utils.log import logger
@moduleinfo(
name="electra-base",
version="1.0.1",
- summary=
- "electra-base, 12-layer, 768-hidden, 12-heads, 110M parameters. The module is executed as paddle.dygraph.",
+ summary="electra-base, 12-layer, 768-hidden, 12-heads, 110M parameters. The module is executed as paddle.dygraph.",
author="paddlepaddle",
author_email="",
type="nlp/semantic_model",
@@ -60,37 +59,27 @@ class Electra(nn.Layer):
task = 'seq-cls'
logger.warning(
"current task name 'sequence_classification' was renamed to 'seq-cls', "
- "'sequence_classification' has been deprecated and will be removed in the future.",
- )
+ "'sequence_classification' has been deprecated and will be removed in the future.", )
if task == 'seq-cls':
self.model = ElectraForSequenceClassification.from_pretrained(
- pretrained_model_name_or_path='electra-base',
- num_classes=self.num_classes,
- **kwargs
- )
+ pretrained_model_name_or_path='electra-base', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task == 'token-cls':
self.model = ElectraForTokenClassification.from_pretrained(
- pretrained_model_name_or_path='electra-base',
- num_classes=self.num_classes,
- **kwargs
- )
+ pretrained_model_name_or_path='electra-base', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
- self.metric = ChunkEvaluator(
- label_list=[self.label_map[i] for i in sorted(self.label_map.keys())]
- )
+ self.metric = ChunkEvaluator(label_list=[self.label_map[i] for i in sorted(self.label_map.keys())])
elif task == 'text-matching':
self.model = ElectraModel.from_pretrained(pretrained_model_name_or_path='electra-base', **kwargs)
self.dropout = paddle.nn.Dropout(0.1)
- self.classifier = paddle.nn.Linear(self.model.config['hidden_size']*3, 2)
+ self.classifier = paddle.nn.Linear(self.model.config['hidden_size'] * 3, 2)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task is None:
self.model = ElectraModel.from_pretrained(pretrained_model_name_or_path='electra-base', **kwargs)
else:
- raise RuntimeError("Unknown task {}, task should be one in {}".format(
- task, self._tasks_supported))
+ raise RuntimeError("Unknown task {}, task should be one in {}".format(task, self._tasks_supported))
self.task = task
@@ -138,8 +127,7 @@ class Electra(nn.Layer):
loss = self.criterion(logits, labels.unsqueeze(-1))
num_infer_chunks, num_label_chunks, num_correct_chunks = \
self.metric.compute(None, seq_lengths, preds, labels)
- self.metric.update(
- num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
+ self.metric.update(num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
_, _, f1_score = map(float, self.metric.accumulate())
return token_level_probs, loss, {'f1_score': f1_score}
return token_level_probs
@@ -181,5 +169,4 @@ class Electra(nn.Layer):
"""
Gets the tokenizer that is customized for this module.
"""
- return ElectraTokenizer.from_pretrained(
- pretrained_model_name_or_path='electra-base', *args, **kwargs)
+ return ElectraTokenizer.from_pretrained(pretrained_model_name_or_path='electra-base', *args, **kwargs)
diff --git a/modules/text/language_model/electra_large/README.md b/modules/text/language_model/electra_large/README.md
index 4619d132..e7ebae4d 100644
--- a/modules/text/language_model/electra_large/README.md
+++ b/modules/text/language_model/electra_large/README.md
@@ -154,4 +154,4 @@ paddlehub >= 2.0.0
* 1.0.1
- 增加文本匹配任务`text-matching`
\ No newline at end of file
+ 增加文本匹配任务`text-matching`
diff --git a/modules/text/language_model/electra_large/module.py b/modules/text/language_model/electra_large/module.py
index 31efe69c..cefe8e6c 100644
--- a/modules/text/language_model/electra_large/module.py
+++ b/modules/text/language_model/electra_large/module.py
@@ -29,8 +29,7 @@ from paddlehub.utils.log import logger
@moduleinfo(
name="electra-large",
version="1.0.1",
- summary=
- "electra-large, 24-layer, 1024-hidden, 16-heads, 335M parameters. The module is executed as paddle.dygraph.",
+ summary="electra-large, 24-layer, 1024-hidden, 16-heads, 335M parameters. The module is executed as paddle.dygraph.",
author="paddlepaddle",
author_email="",
type="nlp/semantic_model",
@@ -60,37 +59,27 @@ class Electra(nn.Layer):
task = 'seq-cls'
logger.warning(
"current task name 'sequence_classification' was renamed to 'seq-cls', "
- "'sequence_classification' has been deprecated and will be removed in the future.",
- )
+ "'sequence_classification' has been deprecated and will be removed in the future.", )
if task == 'seq-cls':
self.model = ElectraForSequenceClassification.from_pretrained(
- pretrained_model_name_or_path='electra-large',
- num_classes=self.num_classes,
- **kwargs
- )
+ pretrained_model_name_or_path='electra-large', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task == 'token-cls':
self.model = ElectraForTokenClassification.from_pretrained(
- pretrained_model_name_or_path='electra-large',
- num_classes=self.num_classes,
- **kwargs
- )
+ pretrained_model_name_or_path='electra-large', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
- self.metric = ChunkEvaluator(
- label_list=[self.label_map[i] for i in sorted(self.label_map.keys())]
- )
+ self.metric = ChunkEvaluator(label_list=[self.label_map[i] for i in sorted(self.label_map.keys())])
elif task == 'text-matching':
self.model = ElectraModel.from_pretrained(pretrained_model_name_or_path='electra-large', **kwargs)
self.dropout = paddle.nn.Dropout(0.1)
- self.classifier = paddle.nn.Linear(self.model.config['hidden_size']*3, 2)
+ self.classifier = paddle.nn.Linear(self.model.config['hidden_size'] * 3, 2)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task is None:
self.model = ElectraModel.from_pretrained(pretrained_model_name_or_path='electra-large', **kwargs)
else:
- raise RuntimeError("Unknown task {}, task should be one in {}".format(
- task, self._tasks_supported))
+ raise RuntimeError("Unknown task {}, task should be one in {}".format(task, self._tasks_supported))
self.task = task
@@ -138,8 +127,7 @@ class Electra(nn.Layer):
loss = self.criterion(logits, labels.unsqueeze(-1))
num_infer_chunks, num_label_chunks, num_correct_chunks = \
self.metric.compute(None, seq_lengths, preds, labels)
- self.metric.update(
- num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
+ self.metric.update(num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
_, _, f1_score = map(float, self.metric.accumulate())
return token_level_probs, loss, {'f1_score': f1_score}
return token_level_probs
@@ -181,5 +169,4 @@ class Electra(nn.Layer):
"""
Gets the tokenizer that is customized for this module.
"""
- return ElectraTokenizer.from_pretrained(
- pretrained_model_name_or_path='electra-large', *args, **kwargs)
+ return ElectraTokenizer.from_pretrained(pretrained_model_name_or_path='electra-large', *args, **kwargs)
diff --git a/modules/text/language_model/electra_small/README.md b/modules/text/language_model/electra_small/README.md
index 6d90d9d9..bdd8fd0c 100644
--- a/modules/text/language_model/electra_small/README.md
+++ b/modules/text/language_model/electra_small/README.md
@@ -154,4 +154,4 @@ paddlehub >= 2.0.0
* 1.0.1
- 增加文本匹配任务`text-matching`
\ No newline at end of file
+ 增加文本匹配任务`text-matching`
diff --git a/modules/text/language_model/electra_small/module.py b/modules/text/language_model/electra_small/module.py
index 697411f3..a4af0388 100644
--- a/modules/text/language_model/electra_small/module.py
+++ b/modules/text/language_model/electra_small/module.py
@@ -29,8 +29,7 @@ from paddlehub.utils.log import logger
@moduleinfo(
name="electra-small",
version="1.0.1",
- summary=
- "electra-small, 12-layer, 256-hidden, 4-heads, 14M parameters. The module is executed as paddle.dygraph.",
+ summary="electra-small, 12-layer, 256-hidden, 4-heads, 14M parameters. The module is executed as paddle.dygraph.",
author="paddlepaddle",
author_email="",
type="nlp/semantic_model",
@@ -60,37 +59,27 @@ class Electra(nn.Layer):
task = 'seq-cls'
logger.warning(
"current task name 'sequence_classification' was renamed to 'seq-cls', "
- "'sequence_classification' has been deprecated and will be removed in the future.",
- )
+ "'sequence_classification' has been deprecated and will be removed in the future.", )
if task == 'seq-cls':
self.model = ElectraForSequenceClassification.from_pretrained(
- pretrained_model_name_or_path='electra-small',
- num_classes=self.num_classes,
- **kwargs
- )
+ pretrained_model_name_or_path='electra-small', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task == 'token-cls':
self.model = ElectraForTokenClassification.from_pretrained(
- pretrained_model_name_or_path='electra-small',
- num_classes=self.num_classes,
- **kwargs
- )
+ pretrained_model_name_or_path='electra-small', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
- self.metric = ChunkEvaluator(
- label_list=[self.label_map[i] for i in sorted(self.label_map.keys())]
- )
+ self.metric = ChunkEvaluator(label_list=[self.label_map[i] for i in sorted(self.label_map.keys())])
elif task == 'text-matching':
self.model = ElectraModel.from_pretrained(pretrained_model_name_or_path='electra-small', **kwargs)
self.dropout = paddle.nn.Dropout(0.1)
- self.classifier = paddle.nn.Linear(self.model.config['hidden_size']*3, 2)
+ self.classifier = paddle.nn.Linear(self.model.config['hidden_size'] * 3, 2)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task is None:
self.model = ElectraModel.from_pretrained(pretrained_model_name_or_path='electra-small', **kwargs)
else:
- raise RuntimeError("Unknown task {}, task should be one in {}".format(
- task, self._tasks_supported))
+ raise RuntimeError("Unknown task {}, task should be one in {}".format(task, self._tasks_supported))
self.task = task
@@ -138,8 +127,7 @@ class Electra(nn.Layer):
loss = self.criterion(logits, labels.unsqueeze(-1))
num_infer_chunks, num_label_chunks, num_correct_chunks = \
self.metric.compute(None, seq_lengths, preds, labels)
- self.metric.update(
- num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
+ self.metric.update(num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
_, _, f1_score = map(float, self.metric.accumulate())
return token_level_probs, loss, {'f1_score': f1_score}
return token_level_probs
@@ -181,5 +169,4 @@ class Electra(nn.Layer):
"""
Gets the tokenizer that is customized for this module.
"""
- return ElectraTokenizer.from_pretrained(
- pretrained_model_name_or_path='electra-small', *args, **kwargs)
+ return ElectraTokenizer.from_pretrained(pretrained_model_name_or_path='electra-small', *args, **kwargs)
diff --git a/modules/text/language_model/ernie/README.md b/modules/text/language_model/ernie/README.md
index cd2ad5ff..8daa8808 100644
--- a/modules/text/language_model/ernie/README.md
+++ b/modules/text/language_model/ernie/README.md
@@ -187,4 +187,4 @@ paddlehub >= 2.0.0
* 2.0.2
- 增加文本匹配任务`text-matching`
\ No newline at end of file
+ 增加文本匹配任务`text-matching`
diff --git a/modules/text/language_model/ernie/module.py b/modules/text/language_model/ernie/module.py
index ecb2e40e..f851d3e4 100644
--- a/modules/text/language_model/ernie/module.py
+++ b/modules/text/language_model/ernie/module.py
@@ -60,29 +60,27 @@ class Ernie(nn.Layer):
task = 'seq-cls'
logger.warning(
"current task name 'sequence_classification' was renamed to 'seq-cls', "
- "'sequence_classification' has been deprecated and will be removed in the future.",
- )
+ "'sequence_classification' has been deprecated and will be removed in the future.", )
if task == 'seq-cls':
- self.model = ErnieForSequenceClassification.from_pretrained(pretrained_model_name_or_path='ernie-1.0', num_classes=self.num_classes, **kwargs)
+ self.model = ErnieForSequenceClassification.from_pretrained(
+ pretrained_model_name_or_path='ernie-1.0', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task == 'token-cls':
- self.model = ErnieForTokenClassification.from_pretrained(pretrained_model_name_or_path='ernie-1.0', num_classes=self.num_classes, **kwargs)
+ self.model = ErnieForTokenClassification.from_pretrained(
+ pretrained_model_name_or_path='ernie-1.0', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
- self.metric = ChunkEvaluator(
- label_list=[self.label_map[i] for i in sorted(self.label_map.keys())]
- )
+ self.metric = ChunkEvaluator(label_list=[self.label_map[i] for i in sorted(self.label_map.keys())])
elif task == 'text-matching':
self.model = ErnieModel.from_pretrained(pretrained_model_name_or_path='ernie-1.0', **kwargs)
self.dropout = paddle.nn.Dropout(0.1)
- self.classifier = paddle.nn.Linear(self.model.config['hidden_size']*3, 2)
+ self.classifier = paddle.nn.Linear(self.model.config['hidden_size'] * 3, 2)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task is None:
self.model = ErnieModel.from_pretrained(pretrained_model_name_or_path='ernie-1.0', **kwargs)
else:
- raise RuntimeError("Unknown task {}, task should be one in {}".format(
- task, self._tasks_supported))
+ raise RuntimeError("Unknown task {}, task should be one in {}".format(task, self._tasks_supported))
self.task = task
@@ -130,8 +128,7 @@ class Ernie(nn.Layer):
loss = self.criterion(logits, labels.unsqueeze(-1))
num_infer_chunks, num_label_chunks, num_correct_chunks = \
self.metric.compute(None, seq_lengths, preds, labels)
- self.metric.update(
- num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
+ self.metric.update(num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
_, _, f1_score = map(float, self.metric.accumulate())
return token_level_probs, loss, {'f1_score': f1_score}
return token_level_probs
@@ -173,5 +170,4 @@ class Ernie(nn.Layer):
"""
Gets the tokenizer that is customized for this module.
"""
- return ErnieTokenizer.from_pretrained(
- pretrained_model_name_or_path='ernie-1.0', *args, **kwargs)
+ return ErnieTokenizer.from_pretrained(pretrained_model_name_or_path='ernie-1.0', *args, **kwargs)
diff --git a/modules/text/language_model/ernie_tiny/README.md b/modules/text/language_model/ernie_tiny/README.md
index 03fc0acd..e2f765b2 100644
--- a/modules/text/language_model/ernie_tiny/README.md
+++ b/modules/text/language_model/ernie_tiny/README.md
@@ -179,4 +179,4 @@ paddlehub >= 2.0.0
* 2.0.2
- 增加文本匹配任务`text-matching`
\ No newline at end of file
+ 增加文本匹配任务`text-matching`
diff --git a/modules/text/language_model/ernie_tiny/module.py b/modules/text/language_model/ernie_tiny/module.py
index a85bc320..e4c02596 100644
--- a/modules/text/language_model/ernie_tiny/module.py
+++ b/modules/text/language_model/ernie_tiny/module.py
@@ -59,29 +59,27 @@ class ErnieTiny(nn.Layer):
task = 'seq-cls'
logger.warning(
"current task name 'sequence_classification' was renamed to 'seq-cls', "
- "'sequence_classification' has been deprecated and will be removed in the future.",
- )
+ "'sequence_classification' has been deprecated and will be removed in the future.", )
if task == 'seq-cls':
- self.model = ErnieForSequenceClassification.from_pretrained(pretrained_model_name_or_path='ernie-tiny', num_classes=self.num_classes, **kwargs)
+ self.model = ErnieForSequenceClassification.from_pretrained(
+ pretrained_model_name_or_path='ernie-tiny', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task == 'token-cls':
- self.model = ErnieForTokenClassification.from_pretrained(pretrained_model_name_or_path='ernie-tiny', num_classes=self.num_classes, **kwargs)
+ self.model = ErnieForTokenClassification.from_pretrained(
+ pretrained_model_name_or_path='ernie-tiny', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
- self.metric = ChunkEvaluator(
- label_list=[self.label_map[i] for i in sorted(self.label_map.keys())]
- )
+ self.metric = ChunkEvaluator(label_list=[self.label_map[i] for i in sorted(self.label_map.keys())])
elif task == 'text-matching':
self.model = ErnieModel.from_pretrained(pretrained_model_name_or_path='ernie-tiny', **kwargs)
self.dropout = paddle.nn.Dropout(0.1)
- self.classifier = paddle.nn.Linear(self.model.config['hidden_size']*3, 2)
+ self.classifier = paddle.nn.Linear(self.model.config['hidden_size'] * 3, 2)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task is None:
self.model = ErnieModel.from_pretrained(pretrained_model_name_or_path='ernie-tiny', **kwargs)
else:
- raise RuntimeError("Unknown task {}, task should be one in {}".format(
- task, self._tasks_supported))
+ raise RuntimeError("Unknown task {}, task should be one in {}".format(task, self._tasks_supported))
self.task = task
@@ -129,8 +127,7 @@ class ErnieTiny(nn.Layer):
loss = self.criterion(logits, labels.unsqueeze(-1))
num_infer_chunks, num_label_chunks, num_correct_chunks = \
self.metric.compute(None, seq_lengths, preds, labels)
- self.metric.update(
- num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
+ self.metric.update(num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
_, _, f1_score = map(float, self.metric.accumulate())
return token_level_probs, loss, {'f1_score': f1_score}
return token_level_probs
@@ -172,5 +169,4 @@ class ErnieTiny(nn.Layer):
"""
Gets the tokenizer that is customized for this module.
"""
- return ErnieTinyTokenizer.from_pretrained(
- pretrained_model_name_or_path='ernie-tiny', *args, **kwargs)
+ return ErnieTinyTokenizer.from_pretrained(pretrained_model_name_or_path='ernie-tiny', *args, **kwargs)
diff --git a/modules/text/language_model/ernie_v2_eng_base/README.md b/modules/text/language_model/ernie_v2_eng_base/README.md
index 818471c2..f0c20c66 100644
--- a/modules/text/language_model/ernie_v2_eng_base/README.md
+++ b/modules/text/language_model/ernie_v2_eng_base/README.md
@@ -175,4 +175,4 @@ paddlehub >= 2.0.0
* 2.0.2
- 增加文本匹配任务`text-matching`
\ No newline at end of file
+ 增加文本匹配任务`text-matching`
diff --git a/modules/text/language_model/ernie_v2_eng_base/module.py b/modules/text/language_model/ernie_v2_eng_base/module.py
index fd5a6033..03574c77 100644
--- a/modules/text/language_model/ernie_v2_eng_base/module.py
+++ b/modules/text/language_model/ernie_v2_eng_base/module.py
@@ -60,37 +60,27 @@ class ErnieV2(nn.Layer):
task = 'seq-cls'
logger.warning(
"current task name 'sequence_classification' was renamed to 'seq-cls', "
- "'sequence_classification' has been deprecated and will be removed in the future.",
- )
+ "'sequence_classification' has been deprecated and will be removed in the future.", )
if task == 'seq-cls':
self.model = ErnieForSequenceClassification.from_pretrained(
- pretrained_model_name_or_path='ernie-2.0-en',
- num_classes=self.num_classes,
- **kwargs
- )
+ pretrained_model_name_or_path='ernie-2.0-en', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task == 'token-cls':
self.model = ErnieForTokenClassification.from_pretrained(
- pretrained_model_name_or_path='ernie-2.0-en',
- num_classes=self.num_classes,
- **kwargs
- )
+ pretrained_model_name_or_path='ernie-2.0-en', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
- self.metric = ChunkEvaluator(
- label_list=[self.label_map[i] for i in sorted(self.label_map.keys())]
- )
+ self.metric = ChunkEvaluator(label_list=[self.label_map[i] for i in sorted(self.label_map.keys())])
elif task == 'text-matching':
self.model = ErnieModel.from_pretrained(pretrained_model_name_or_path='ernie-2.0-en', **kwargs)
self.dropout = paddle.nn.Dropout(0.1)
- self.classifier = paddle.nn.Linear(self.model.config['hidden_size']*3, 2)
+ self.classifier = paddle.nn.Linear(self.model.config['hidden_size'] * 3, 2)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task is None:
self.model = ErnieModel.from_pretrained(pretrained_model_name_or_path='ernie-2.0-en', **kwargs)
else:
- raise RuntimeError("Unknown task {}, task should be one in {}".format(
- task, self._tasks_supported))
+ raise RuntimeError("Unknown task {}, task should be one in {}".format(task, self._tasks_supported))
self.task = task
@@ -138,8 +128,7 @@ class ErnieV2(nn.Layer):
loss = self.criterion(logits, labels.unsqueeze(-1))
num_infer_chunks, num_label_chunks, num_correct_chunks = \
self.metric.compute(None, seq_lengths, preds, labels)
- self.metric.update(
- num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
+ self.metric.update(num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
_, _, f1_score = map(float, self.metric.accumulate())
return token_level_probs, loss, {'f1_score': f1_score}
return token_level_probs
@@ -181,5 +170,4 @@ class ErnieV2(nn.Layer):
"""
Gets the tokenizer that is customized for this module.
"""
- return ErnieTokenizer.from_pretrained(
- pretrained_model_name_or_path='ernie-2.0-en', *args, **kwargs)
\ No newline at end of file
+ return ErnieTokenizer.from_pretrained(pretrained_model_name_or_path='ernie-2.0-en', *args, **kwargs)
diff --git a/modules/text/language_model/ernie_v2_eng_large/README.md b/modules/text/language_model/ernie_v2_eng_large/README.md
index d11edff1..e80442b7 100644
--- a/modules/text/language_model/ernie_v2_eng_large/README.md
+++ b/modules/text/language_model/ernie_v2_eng_large/README.md
@@ -174,4 +174,4 @@ paddlehub >= 2.0.0
* 2.0.2
- 增加文本匹配任务`text-matching`
\ No newline at end of file
+ 增加文本匹配任务`text-matching`
diff --git a/modules/text/language_model/ernie_v2_eng_large/module.py b/modules/text/language_model/ernie_v2_eng_large/module.py
index 5be8965d..57a7779b 100644
--- a/modules/text/language_model/ernie_v2_eng_large/module.py
+++ b/modules/text/language_model/ernie_v2_eng_large/module.py
@@ -60,37 +60,27 @@ class ErnieV2(nn.Layer):
task = 'seq-cls'
logger.warning(
"current task name 'sequence_classification' was renamed to 'seq-cls', "
- "'sequence_classification' has been deprecated and will be removed in the future.",
- )
+ "'sequence_classification' has been deprecated and will be removed in the future.", )
if task == 'seq-cls':
self.model = ErnieForSequenceClassification.from_pretrained(
- pretrained_model_name_or_path='ernie-2.0-large-en',
- num_classes=self.num_classes,
- **kwargs
- )
+ pretrained_model_name_or_path='ernie-2.0-large-en', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task == 'token-cls':
self.model = ErnieForTokenClassification.from_pretrained(
- pretrained_model_name_or_path='ernie-2.0-large-en',
- num_classes=self.num_classes,
- **kwargs
- )
+ pretrained_model_name_or_path='ernie-2.0-large-en', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
- self.metric = ChunkEvaluator(
- label_list=[self.label_map[i] for i in sorted(self.label_map.keys())]
- )
+ self.metric = ChunkEvaluator(label_list=[self.label_map[i] for i in sorted(self.label_map.keys())])
elif task == 'text-matching':
self.model = ErnieModel.from_pretrained(pretrained_model_name_or_path='ernie-2.0-large-en', **kwargs)
self.dropout = paddle.nn.Dropout(0.1)
- self.classifier = paddle.nn.Linear(self.model.config['hidden_size']*3, 2)
+ self.classifier = paddle.nn.Linear(self.model.config['hidden_size'] * 3, 2)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task is None:
self.model = ErnieModel.from_pretrained(pretrained_model_name_or_path='ernie-2.0-large-en', **kwargs)
else:
- raise RuntimeError("Unknown task {}, task should be one in {}".format(
- task, self._tasks_supported))
+ raise RuntimeError("Unknown task {}, task should be one in {}".format(task, self._tasks_supported))
self.task = task
@@ -138,8 +128,7 @@ class ErnieV2(nn.Layer):
loss = self.criterion(logits, labels.unsqueeze(-1))
num_infer_chunks, num_label_chunks, num_correct_chunks = \
self.metric.compute(None, seq_lengths, preds, labels)
- self.metric.update(
- num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
+ self.metric.update(num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
_, _, f1_score = map(float, self.metric.accumulate())
return token_level_probs, loss, {'f1_score': f1_score}
return token_level_probs
@@ -181,5 +170,4 @@ class ErnieV2(nn.Layer):
"""
Gets the tokenizer that is customized for this module.
"""
- return ErnieTokenizer.from_pretrained(
- pretrained_model_name_or_path='ernie-2.0-large-en', *args, **kwargs)
+ return ErnieTokenizer.from_pretrained(pretrained_model_name_or_path='ernie-2.0-large-en', *args, **kwargs)
diff --git a/modules/text/language_model/rbt3/README.md b/modules/text/language_model/rbt3/README.md
index ccc76744..ebed472a 100644
--- a/modules/text/language_model/rbt3/README.md
+++ b/modules/text/language_model/rbt3/README.md
@@ -159,4 +159,4 @@ paddlehub >= 2.0.0
* 2.0.1
- 增加文本匹配任务`text-matching`
\ No newline at end of file
+ 增加文本匹配任务`text-matching`
diff --git a/modules/text/language_model/rbt3/module.py b/modules/text/language_model/rbt3/module.py
index 8c8fe789..7a2edac9 100644
--- a/modules/text/language_model/rbt3/module.py
+++ b/modules/text/language_model/rbt3/module.py
@@ -60,37 +60,27 @@ class Roberta(nn.Layer):
task = 'seq-cls'
logger.warning(
"current task name 'sequence_classification' was renamed to 'seq-cls', "
- "'sequence_classification' has been deprecated and will be removed in the future.",
- )
+ "'sequence_classification' has been deprecated and will be removed in the future.", )
if task == 'seq-cls':
self.model = RobertaForSequenceClassification.from_pretrained(
- pretrained_model_name_or_path='rbt3',
- num_classes=self.num_classes,
- **kwargs
- )
+ pretrained_model_name_or_path='rbt3', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task == 'token-cls':
self.model = RobertaForTokenClassification.from_pretrained(
- pretrained_model_name_or_path='rbt3',
- num_classes=self.num_classes,
- **kwargs
- )
+ pretrained_model_name_or_path='rbt3', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
- self.metric = ChunkEvaluator(
- label_list=[self.label_map[i] for i in sorted(self.label_map.keys())]
- )
+ self.metric = ChunkEvaluator(label_list=[self.label_map[i] for i in sorted(self.label_map.keys())])
elif task == 'text-matching':
self.model = RobertaModel.from_pretrained(pretrained_model_name_or_path='rbt3', **kwargs)
self.dropout = paddle.nn.Dropout(0.1)
- self.classifier = paddle.nn.Linear(self.model.config['hidden_size']*3, 2)
+ self.classifier = paddle.nn.Linear(self.model.config['hidden_size'] * 3, 2)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task is None:
self.model = RobertaModel.from_pretrained(pretrained_model_name_or_path='rbt3', **kwargs)
else:
- raise RuntimeError("Unknown task {}, task should be one in {}".format(
- task, self._tasks_supported))
+ raise RuntimeError("Unknown task {}, task should be one in {}".format(task, self._tasks_supported))
self.task = task
@@ -138,8 +128,7 @@ class Roberta(nn.Layer):
loss = self.criterion(logits, labels.unsqueeze(-1))
num_infer_chunks, num_label_chunks, num_correct_chunks = \
self.metric.compute(None, seq_lengths, preds, labels)
- self.metric.update(
- num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
+ self.metric.update(num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
_, _, f1_score = map(float, self.metric.accumulate())
return token_level_probs, loss, {'f1_score': f1_score}
return token_level_probs
@@ -181,5 +170,4 @@ class Roberta(nn.Layer):
"""
Gets the tokenizer that is customized for this module.
"""
- return RobertaTokenizer.from_pretrained(
- pretrained_model_name_or_path='rbt3', *args, **kwargs)
+ return RobertaTokenizer.from_pretrained(pretrained_model_name_or_path='rbt3', *args, **kwargs)
diff --git a/modules/text/language_model/rbtl3/README.md b/modules/text/language_model/rbtl3/README.md
index de1e475a..3562b1a6 100644
--- a/modules/text/language_model/rbtl3/README.md
+++ b/modules/text/language_model/rbtl3/README.md
@@ -159,4 +159,4 @@ paddlehub >= 2.0.0
* 2.0.1
- 增加文本匹配任务`text-matching`
\ No newline at end of file
+ 增加文本匹配任务`text-matching`
diff --git a/modules/text/language_model/rbtl3/module.py b/modules/text/language_model/rbtl3/module.py
index e2d35795..37c96ebc 100644
--- a/modules/text/language_model/rbtl3/module.py
+++ b/modules/text/language_model/rbtl3/module.py
@@ -60,37 +60,27 @@ class Roberta(nn.Layer):
task = 'seq-cls'
logger.warning(
"current task name 'sequence_classification' was renamed to 'seq-cls', "
- "'sequence_classification' has been deprecated and will be removed in the future.",
- )
+ "'sequence_classification' has been deprecated and will be removed in the future.", )
if task == 'seq-cls':
self.model = RobertaForSequenceClassification.from_pretrained(
- pretrained_model_name_or_path='rbtl3',
- num_classes=self.num_classes,
- **kwargs
- )
+ pretrained_model_name_or_path='rbtl3', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task == 'token-cls':
self.model = RobertaForTokenClassification.from_pretrained(
- pretrained_model_name_or_path='rbtl3',
- num_classes=self.num_classes,
- **kwargs
- )
+ pretrained_model_name_or_path='rbtl3', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
- self.metric = ChunkEvaluator(
- label_list=[self.label_map[i] for i in sorted(self.label_map.keys())]
- )
+ self.metric = ChunkEvaluator(label_list=[self.label_map[i] for i in sorted(self.label_map.keys())])
elif task == 'text-matching':
self.model = RobertaModel.from_pretrained(pretrained_model_name_or_path='rbtl3', **kwargs)
self.dropout = paddle.nn.Dropout(0.1)
- self.classifier = paddle.nn.Linear(self.model.config['hidden_size']*3, 2)
+ self.classifier = paddle.nn.Linear(self.model.config['hidden_size'] * 3, 2)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task is None:
self.model = RobertaModel.from_pretrained(pretrained_model_name_or_path='rbtl3', **kwargs)
else:
- raise RuntimeError("Unknown task {}, task should be one in {}".format(
- task, self._tasks_supported))
+ raise RuntimeError("Unknown task {}, task should be one in {}".format(task, self._tasks_supported))
self.task = task
@@ -138,8 +128,7 @@ class Roberta(nn.Layer):
loss = self.criterion(logits, labels.unsqueeze(-1))
num_infer_chunks, num_label_chunks, num_correct_chunks = \
self.metric.compute(None, seq_lengths, preds, labels)
- self.metric.update(
- num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
+ self.metric.update(num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
_, _, f1_score = map(float, self.metric.accumulate())
return token_level_probs, loss, {'f1_score': f1_score}
return token_level_probs
@@ -181,5 +170,4 @@ class Roberta(nn.Layer):
"""
Gets the tokenizer that is customized for this module.
"""
- return RobertaTokenizer.from_pretrained(
- pretrained_model_name_or_path='rbtl3', *args, **kwargs)
+ return RobertaTokenizer.from_pretrained(pretrained_model_name_or_path='rbtl3', *args, **kwargs)
diff --git a/modules/text/language_model/roberta-wwm-ext-large/README.md b/modules/text/language_model/roberta-wwm-ext-large/README.md
index 74629300..18a85f4b 100644
--- a/modules/text/language_model/roberta-wwm-ext-large/README.md
+++ b/modules/text/language_model/roberta-wwm-ext-large/README.md
@@ -161,4 +161,4 @@ paddlehub >= 2.0.0
* 2.0.2
- 增加文本匹配任务`text-matching`
\ No newline at end of file
+ 增加文本匹配任务`text-matching`
diff --git a/modules/text/language_model/roberta-wwm-ext-large/module.py b/modules/text/language_model/roberta-wwm-ext-large/module.py
index 74a4c471..501ff092 100644
--- a/modules/text/language_model/roberta-wwm-ext-large/module.py
+++ b/modules/text/language_model/roberta-wwm-ext-large/module.py
@@ -61,37 +61,27 @@ class Roberta(nn.Layer):
task = 'seq-cls'
logger.warning(
"current task name 'sequence_classification' was renamed to 'seq-cls', "
- "'sequence_classification' has been deprecated and will be removed in the future.",
- )
+ "'sequence_classification' has been deprecated and will be removed in the future.", )
if task == 'seq-cls':
self.model = RobertaForSequenceClassification.from_pretrained(
- pretrained_model_name_or_path='roberta-wwm-ext-large',
- num_classes=self.num_classes,
- **kwargs
- )
+ pretrained_model_name_or_path='roberta-wwm-ext-large', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task == 'token-cls':
self.model = RobertaForTokenClassification.from_pretrained(
- pretrained_model_name_or_path='roberta-wwm-ext-large',
- num_classes=self.num_classes,
- **kwargs
- )
+ pretrained_model_name_or_path='roberta-wwm-ext-large', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
- self.metric = ChunkEvaluator(
- label_list=[self.label_map[i] for i in sorted(self.label_map.keys())]
- )
+ self.metric = ChunkEvaluator(label_list=[self.label_map[i] for i in sorted(self.label_map.keys())])
elif task == 'text-matching':
self.model = RobertaModel.from_pretrained(pretrained_model_name_or_path='roberta-wwm-ext-large', **kwargs)
self.dropout = paddle.nn.Dropout(0.1)
- self.classifier = paddle.nn.Linear(self.model.config['hidden_size']*3, 2)
+ self.classifier = paddle.nn.Linear(self.model.config['hidden_size'] * 3, 2)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task is None:
self.model = RobertaModel.from_pretrained(pretrained_model_name_or_path='roberta-wwm-ext-large', **kwargs)
else:
- raise RuntimeError("Unknown task {}, task should be one in {}".format(
- task, self._tasks_supported))
+ raise RuntimeError("Unknown task {}, task should be one in {}".format(task, self._tasks_supported))
self.task = task
@@ -139,8 +129,7 @@ class Roberta(nn.Layer):
loss = self.criterion(logits, labels.unsqueeze(-1))
num_infer_chunks, num_label_chunks, num_correct_chunks = \
self.metric.compute(None, seq_lengths, preds, labels)
- self.metric.update(
- num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
+ self.metric.update(num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
_, _, f1_score = map(float, self.metric.accumulate())
return token_level_probs, loss, {'f1_score': f1_score}
return token_level_probs
@@ -182,5 +171,4 @@ class Roberta(nn.Layer):
"""
Gets the tokenizer that is customized for this module.
"""
- return RobertaTokenizer.from_pretrained(
- pretrained_model_name_or_path='roberta-wwm-ext-large', *args, **kwargs)
+ return RobertaTokenizer.from_pretrained(pretrained_model_name_or_path='roberta-wwm-ext-large', *args, **kwargs)
diff --git a/modules/text/language_model/roberta-wwm-ext/README.md b/modules/text/language_model/roberta-wwm-ext/README.md
index 19db19d8..8e7cb269 100644
--- a/modules/text/language_model/roberta-wwm-ext/README.md
+++ b/modules/text/language_model/roberta-wwm-ext/README.md
@@ -161,4 +161,4 @@ paddlehub >= 2.0.0
* 2.0.2
- 增加文本匹配任务`text-matching`
\ No newline at end of file
+ 增加文本匹配任务`text-matching`
diff --git a/modules/text/language_model/roberta-wwm-ext/module.py b/modules/text/language_model/roberta-wwm-ext/module.py
index 844ff23d..ee3b8f0d 100644
--- a/modules/text/language_model/roberta-wwm-ext/module.py
+++ b/modules/text/language_model/roberta-wwm-ext/module.py
@@ -61,37 +61,27 @@ class Roberta(nn.Layer):
task = 'seq-cls'
logger.warning(
"current task name 'sequence_classification' was renamed to 'seq-cls', "
- "'sequence_classification' has been deprecated and will be removed in the future.",
- )
+ "'sequence_classification' has been deprecated and will be removed in the future.", )
if task == 'seq-cls':
self.model = RobertaForSequenceClassification.from_pretrained(
- pretrained_model_name_or_path='roberta-wwm-ext',
- num_classes=self.num_classes,
- **kwargs
- )
+ pretrained_model_name_or_path='roberta-wwm-ext', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task == 'token-cls':
self.model = RobertaForTokenClassification.from_pretrained(
- pretrained_model_name_or_path='roberta-wwm-ext',
- num_classes=self.num_classes,
- **kwargs
- )
+ pretrained_model_name_or_path='roberta-wwm-ext', num_classes=self.num_classes, **kwargs)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
- self.metric = ChunkEvaluator(
- label_list=[self.label_map[i] for i in sorted(self.label_map.keys())]
- )
+ self.metric = ChunkEvaluator(label_list=[self.label_map[i] for i in sorted(self.label_map.keys())])
elif task == 'text-matching':
self.model = RobertaModel.from_pretrained(pretrained_model_name_or_path='roberta-wwm-ext', **kwargs)
self.dropout = paddle.nn.Dropout(0.1)
- self.classifier = paddle.nn.Linear(self.model.config['hidden_size']*3, 2)
+ self.classifier = paddle.nn.Linear(self.model.config['hidden_size'] * 3, 2)
self.criterion = paddle.nn.loss.CrossEntropyLoss()
self.metric = paddle.metric.Accuracy()
elif task is None:
self.model = RobertaModel.from_pretrained(pretrained_model_name_or_path='roberta-wwm-ext', **kwargs)
else:
- raise RuntimeError("Unknown task {}, task should be one in {}".format(
- task, self._tasks_supported))
+ raise RuntimeError("Unknown task {}, task should be one in {}".format(task, self._tasks_supported))
self.task = task
@@ -139,8 +129,7 @@ class Roberta(nn.Layer):
loss = self.criterion(logits, labels.unsqueeze(-1))
num_infer_chunks, num_label_chunks, num_correct_chunks = \
self.metric.compute(None, seq_lengths, preds, labels)
- self.metric.update(
- num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
+ self.metric.update(num_infer_chunks.numpy(), num_label_chunks.numpy(), num_correct_chunks.numpy())
_, _, f1_score = map(float, self.metric.accumulate())
return token_level_probs, loss, {'f1_score': f1_score}
return token_level_probs
@@ -182,5 +171,4 @@ class Roberta(nn.Layer):
"""
Gets the tokenizer that is customized for this module.
"""
- return RobertaTokenizer.from_pretrained(
- pretrained_model_name_or_path='roberta-wwm-ext', *args, **kwargs)
+ return RobertaTokenizer.from_pretrained(pretrained_model_name_or_path='roberta-wwm-ext', *args, **kwargs)
diff --git a/modules/text/language_model/simnet_bow/module.py b/modules/text/language_model/simnet_bow/module.py
index 51681d33..ef4a4993 100644
--- a/modules/text/language_model/simnet_bow/module.py
+++ b/modules/text/language_model/simnet_bow/module.py
@@ -29,12 +29,13 @@ class DataFormatError(Exception):
self.args = args
-@moduleinfo(name="simnet_bow",
- version="1.2.0",
- summary="Baidu's open-source similarity network model based on bow_pairwise.",
- author="baidu-nlp",
- author_email="",
- type="nlp/sentiment_analysis")
+@moduleinfo(
+ name="simnet_bow",
+ version="1.2.0",
+ summary="Baidu's open-source similarity network model based on bow_pairwise.",
+ author="baidu-nlp",
+ author_email="",
+ type="nlp/sentiment_analysis")
class SimnetBow(hub.Module):
def _initialize(self):
"""
@@ -106,40 +107,42 @@ class SimnetBow(hub.Module):
seq_len_used = fluid.layers.squeeze(seq_len, axes=[1])
# Add embedding layer.
- w_param_attrs = fluid.ParamAttr(name="emb",
- initializer=fluid.initializer.TruncatedNormal(scale=0.02),
- trainable=trainable)
+ w_param_attrs = fluid.ParamAttr(
+ name="emb", initializer=fluid.initializer.TruncatedNormal(scale=0.02), trainable=trainable)
dict_dim = 500002
- emb_1 = fluid.layers.embedding(input=text_1,
- size=[dict_dim, 128],
- is_sparse=True,
- padding_idx=dict_dim - 1,
- dtype='float32',
- param_attr=w_param_attrs)
+ emb_1 = fluid.layers.embedding(
+ input=text_1,
+ size=[dict_dim, 128],
+ is_sparse=True,
+ padding_idx=dict_dim - 1,
+ dtype='float32',
+ param_attr=w_param_attrs)
emb_1_name = emb_1.name
data_list = [text_1]
emb_name_list = [emb_1_name]
if num_slots > 1:
text_2 = fluid.data(name='text_2', shape=[-1, max_seq_len], dtype='int64', lod_level=0)
- emb_2 = fluid.embedding(input=text_2,
- size=[dict_dim, 128],
- is_sparse=True,
- padding_idx=dict_dim - 1,
- dtype='float32',
- param_attr=w_param_attrs)
+ emb_2 = fluid.embedding(
+ input=text_2,
+ size=[dict_dim, 128],
+ is_sparse=True,
+ padding_idx=dict_dim - 1,
+ dtype='float32',
+ param_attr=w_param_attrs)
emb_2_name = emb_2.name
data_list.append(text_2)
emb_name_list.append(emb_2_name)
if num_slots > 2:
text_3 = fluid.data(name='text_3', shape=[-1, max_seq_len], dtype='int64', lod_level=0)
- emb_3 = fluid.embedding(input=text_3,
- size=[dict_dim, 128],
- is_sparse=True,
- padding_idx=dict_dim - 1,
- dtype='float32',
- param_attr=w_param_attrs)
+ emb_3 = fluid.embedding(
+ input=text_3,
+ size=[dict_dim, 128],
+ is_sparse=True,
+ padding_idx=dict_dim - 1,
+ dtype='float32',
+ param_attr=w_param_attrs)
emb_3_name = emb_3.name
data_list.append(text_3)
emb_name_list.append(emb_3_name)
@@ -295,10 +298,8 @@ class SimnetBow(hub.Module):
"""
Run as a command
"""
- self.parser = argparse.ArgumentParser(description="Run the simnet_bow module.",
- prog='hub run simnet_bow',
- usage='%(prog)s',
- add_help=True)
+ self.parser = argparse.ArgumentParser(
+ description="Run the simnet_bow module.", prog='hub run simnet_bow', usage='%(prog)s', add_help=True)
self.arg_input_group = self.parser.add_argument_group(title="Input options", description="Input data. Required")
self.arg_config_group = self.parser.add_argument_group(
@@ -323,10 +324,8 @@ class SimnetBow(hub.Module):
"""
Add the command config options
"""
- self.arg_config_group.add_argument('--use_gpu',
- type=ast.literal_eval,
- default=False,
- help="whether use GPU for prediction")
+ self.arg_config_group.add_argument(
+ '--use_gpu', type=ast.literal_eval, default=False, help="whether use GPU for prediction")
self.arg_config_group.add_argument('--batch_size', type=int, default=1, help="batch size for prediction")
diff --git a/modules/text/text_generation/Rumor_prediction/dict.txt b/modules/text/text_generation/Rumor_prediction/dict.txt
index b92f924f..ee3c48cd 100644
--- a/modules/text/text_generation/Rumor_prediction/dict.txt
+++ b/modules/text/text_generation/Rumor_prediction/dict.txt
@@ -1 +1 @@
-{'寒': 0, '煲': 1, '升': 2, '耳': 3, '孜': 4, '矶': 5, '惑': 6, '谩': 7, '奉': 8, '坛': 9, '嘗': 10, '索': 11, '所': 12, '藏': 13, '阜': 14, '孟': 15, '久': 16, ')': 17, '散': 18, '真': 19, '肇': 20, '保': 21, '蜜': 22, '丁': 23, '玉': 24, '伏': 25, '次': 26, '隽': 27, '囯': 28, '浊': 29, '沥': 30, '豪': 31, '果': 32, '卢': 33, '夏': 34, '朦': 35, '墓': 36, '圖': 37, '躬': 38, '铃': 39, '浇': 40, '反': 41, '瑩': 42, '慕': 43, '練': 44, '抨': 45, '喃': 46, '滑': 47, '亇': 48, '紅': 49, '拙': 50, '侍': 51, '卤': 52, '摄': 53, '〗': 54, '谤': 55, '跟': 56, '⒑': 57, '备': 58, '躺': 59, '稳': 60, '九': 61, '歉': 62, '味': 63, '莎': 64, '黍': 65, '涎': 66, '想': 67, '鳍': 68, '籠': 69, '臨': 70, '纶': 71, '性': 72, '推': 73, '殉': 74, '平': 75, '倍': 76, '洽': 77, '浸': 78, '裔': 79, '鹤': 80, '破': 81, '軟': 82, '尚': 83, '肃': 84, '凱': 85, '呼': 86, '踊': 87, '编': 88, '輯': 89, '病': 90, '勤': 91, '婴': 92, '枯': 93, '邦': 94, '隨': 95, '級': 96, '〝': 97, '奸': 98, '愧': 99, '团': 100, '济': 101, '董': 102, '艺': 103, '赢': 104, '泄': 105, '蜂': 106, '东': 107, '荆': 108, '汶': 109, '痰': 110, '溅': 111, '湾': 112, '咚': 113, '異': 114, '省': 115, '互': 116, '亂': 117, '耙': 118, '棒': 119, '判': 120, '绘': 121, '呐': 122, '掷': 123, '匿': 124, '韵': 125, '低': 126, '演': 127, '做': 128, '榕': 129, '郡': 130, '明': 131, '吞': 132, '7': 133, '侣': 134, '曼': 135, '炭': 136, '淘': 137, '當': 138, '寨': 139, '餘': 140, '力': 141, '覽': 142, '坏': 143, '肩': 144, '宿': 145, '舟': 146, '嘉': 147, '妹': 148, '各': 149, '著': 150, '归': 151, '遗': 152, '表': 153, '勋': 154, '》': 155, '拦': 156, '瞬': 157, '運': 158, '挖': 159, '谊': 160, '乒': 161, '忽': 162, 'お': 163, '伞': 164, '粤': 165, '曾': 166, '糍': 167, '墨': 168, '设': 169, '滞': 170, '踩': 171, '沛': 172, '盗': 173, '尢': 174, '慌': 175, 'w': 176, '币': 177, 'O': 178, '份': 179, '晨': 180, '菌': 181, '药': 182, '颅': 183, '碍': 184, '桐': 185, '驱': 186, '险': 187, '焖': 188, '仕': 189, '牒': 190, '功': 191, '万': 192, '恼': 193, '囤': 194, '狐': 195, '诸': 196, '憨': 197, '戈': 198, '雀': 199, '筆': 200, '咆': 201, '郅': 202, '残': 203, '刷': 204, '茄': 205, '垄': 206, '眾': 207, '偿': 208, '求': 209, '0': 210, 'g': 211, '荩': 212, '帳': 213, '襲': 214, '庞': 215, '逅': 216, '杆': 217, '埃': 218, '俊': 219, '缺': 220, '爭': 221, '坨': 222, '秃': 223, '遐': 224, '是': 225, '玮': 226, '邀': 227, '监': 228, '呢': 229, '曦': 230, '紹': 231, '惋': 232, '揣': 233, '铺': 234, '篇': 235, '獨': 236, '哀': 237, '趣': 238, '咩': 239, '澳': 240, '坪': 241, '冰': 242, '婶': 243, '烟': 244, '像': 245, '👍': 246, '庸': 247, '舞': 248, '父': 249, '\ue415': 250, '貨': 251, '稠': 252, '锣': 253, '憶': 254, '鹅': 255, '苕': 256, '宋': 257, '机': 258, '.': 259, '危': 260, '鳝': 261, '御': 262, '隶': 263, '锥': 264, '失': 265, '第': 266, '座': 267, '★': 268, '宥': 269, '鞭': 270, '才': 271, '弃': 272, '憬': 273, '帝': 274, '\ue021': 275, '睡': 276, '凿': 277, '瀟': 278, '帥': 279, '渢': 280, '说': 281, '疚': 282, '墀': 283, '榨': 284, '哑': 285, '吼': 286, '意': 287, '드': 288, '–': 289, '耍': 290, '劝': 291, '話': 292, '親': 293, '桩': 294, "'": 295, '酚': 296, '干': 297, '国': 298, '歼': 299, '蕴': 300, '酿': 301, '叠': 302, '派': 303, '嬛': 304, '韩': 305, '宫': 306, '仁': 307, '臭': 308, '牌': 309, '說': 310, '棕': 311, '舍': 312, '伊': 313, '卿': 314, '抱': 315, '蔚': 316, '遛': 317, '/': 318, '腰': 319, '違': 320, '纱': 321, '溯': 322, '\u2029': 323, '怯': 324, '哎': 325, '曝': 326, '终': 327, '丨': 328, '逺': 329, '哩': 330, '警': 331, '捷': 332, '宙': 333, '峻': 334, '原': 335, '觀': 336, '蓋': 337, '竹': 338, '戴': 339, '聽': 340, '桓': 341, '沫': 342, '忐': 343, '杰': 344, '执': 345, '利': 346, '帽': 347, '嗷': 348, '枳': 349, '沪': 350, '率': 351, '雾': 352, '嚣': 353, '啸': 354, '乎': 355, '饮': 356, '独': 357, '添': 358, '走': 359, '涉': 360, '怪': 361, '羔': 362, '巾': 363, '盼': 364, '繁': 365, '呦': 366, '舌': 367, '斐': 368, '使': 369, '坐': 370, '依': 371, '啊': 372, '电': 373, '幺': 374, '沿': 375, '內': 376, '汪': 377, '称': 378, '妈': 379, '宏': 380, '柜': 381, '盲': 382, '蹒': 383, '開': 384, '稼': 385, '诈': 386, '瞰': 387, 'ㅋ': 388, '∩': 389, '嫉': 390, '泮': 391, '起': 392, '资': 393, '仍': 394, '憎': 395, '美': 396, '。': 397, '傈': 398, '裴': 399, '棺': 400, '弱': 401, '匪': 402, '箱': 403, '相': 404, '更': 405, '没': 406, '聚': 407, '跨': 408, '訴': 409, '龙': 410, '施': 411, '厌': 412, '梓': 413, '莺': 414, '阶': 415, '棋': 416, '专': 417, '挤': 418, '禮': 419, 'る': 420, '\ue10c': 421, '巡': 422, '遥': 423, '日': 424, '岗': 425, '勝': 426, '殡': 427, '痴': 428, '措': 429, '狸': 430, '#': 431, '歷': 432, '趁': 433, '殆': 434, '只': 435, '鼓': 436, '亞': 437, ' ': 438, '流': 439, '悲': 440, '噬': 441, '裤': 442, '拐': 443, '😠': 444, '狂': 445, '山': 446, '镇': 447, '稍': 448, '染': 449, '-': 450, '瑾': 451, '账': 452, 'l': 453, '誌': 454, '赡': 455, '지': 456, 'キ': 457, '谅': 458, '聘': 459, '绎': 460, '词': 461, '血': 462, '墙': 463, '℃': 464, '嫖': 465, '尺': 466, '活': 467, '脍': 468, '担': 469, '男': 470, '掉': 471, '咒': 472, '吸': 473, '痞': 474, '根': 475, '晏': 476, '仨': 477, '急': 478, '怠': 479, '履': 480, '洼': 481, '唾': 482, '懷': 483, '妆': 484, '单': 485, '肾': 486, '奧': 487, '薪': 488, '皂': 489, '参': 490, '朔': 491, '甲': 492, '钉': 493, '雖': 494, '希': 495, '冬': 496, '摩': 497, '谎': 498, '铂': 499, '蹄': 500, '壮': 501, '纺': 502, '岛': 503, '伴': 504, '贱': 505, '柯': 506, '拒': 507, '鲑': 508, '童': 509, '怡': 510, '績': 511, 'で': 512, '邻': 513, '班': 514, '藉': 515, '锐': 516, '鄙': 517, '蛰': 518, '告': 519, '⒒': 520, '浙': 521, '近': 522, '屈': 523, '喝': 524, '呛': 525, '痛': 526, '甚': 527, '铜': 528, '巅': 529, '盾': 530, '爵': 531, '段': 532, '貓': 533, '紀': 534, '臂': 535, '載': 536, '扁': 537, '😜': 538, '焚': 539, '厕': 540, '︰': 541, '谭': 542, '粱': 543, '殒': 544, '睐': 545, '夫': 546, '淞': 547, '骚': 548, '凳': 549, '洪': 550, '碎': 551, 'C': 552, '全': 553, '以': 554, '霉': 555, '放': 556, '觅': 557, '磕': 558, '励': 559, '搜': 560, '膊': 561, '畫': 562, '熊': 563, '罐': 564, '闸': 565, '歆': 566, '虹': 567, '估': 568, '落': 569, '經': 570, '拼': 571, '挺': 572, '糙': 573, '鉴': 574, '豁': 575, '捆': 576, '比': 577, '濛': 578, '初': 579, '属': 580, '寫': 581, '候': 582, '參': 583, '碳': 584, '哟': 585, '姜': 586, '垢': 587, '券': 588, '慑': 589, '点': 590, '己': 591, '霞': 592, '纸': 593, '哥': 594, '赎': 595, '妞': 596, '勲': 597, '刁': 598, '胃': 599, '韭': 600, '註': 601, '詐': 602, '燮': 603, '群': 604, '庙': 605, '來': 606, '仗': 607, '9': 608, '探': 609, '蝶': 610, '傅': 611, '徽': 612, '缤': 613, '^': 614, '堡': 615, '赏': 616, '蛆': 617, '烩': 618, '準': 619, '朵': 620, '吃': 621, '嘴': 622, '典': 623, '端': 624, '連': 625, '趟': 626, '欲': 627, '『': 628, '馒': 629, '神': 630, '拯': 631, '芸': 632, '防': 633, '竣': 634, '时': 635, '輕': 636, '却': 637, '泳': 638, '陡': 639, '冒': 640, '💖': 641, '托': 642, '鹫': 643, '姊': 644, '嘲': 645, '枸': 646, '总': 647, '绿': 648, '症': 649, '练': 650, '耕': 651, '野': 652, '强': 653, '匆': 654, '🙏': 655, '吶': 656, 'o': 657, '包': 658, '幣': 659, '央': 660, '惮': 661, '險': 662, '爬': 663, '猪': 664, '邯': 665, '妖': 666, '挣': 667, '世': 668, '登': 669, '女': 670, '佐': 671, '笙': 672, '×': 673, '你': 674, '肆': 675, '池': 676, '鳄': 677, '蒂': 678, '腕': 679, '囡': 680, '娅': 681, '°': 682, '徇': 683, '沱': 684, '恢': 685, '“': 686, 'I': 687, '恭': 688, '缝': 689, '肮': 690, '就': 691, '眶': 692, '席': 693, '據': 694, '剂': 695, '哄': 696, '谈': 697, '岔': 698, '瞒': 699, '坦': 700, '忑': 701, '赈': 702, '雷': 703, '辰': 704, 'e': 705, '荥': 706, '闯': 707, '純': 708, '揽': 709, '林': 710, '巴': 711, '逞': 712, '串': 713, '璨': 714, '聊': 715, '偌': 716, '斑': 717, '暄': 718, '计': 719, '会': 720, '琪': 721, '⒊': 722, '吹': 723, '碟': 724, '胚': 725, '陣': 726, '饭': 727, '🔴': 728, '友': 729, '招': 730, '扯': 731, '武': 732, '錄': 733, '後': 734, '敖': 735, '审': 736, '鸟': 737, '筑': 738, '稽': 739, '吵': 740, '制': 741, '俄': 742, '逮': 743, '毙': 744, '摘': 745, '巫': 746, '姣': 747, '從': 748, '瑰': 749, '闻': 750, '队': 751, '汲': 752, '听': 753, '邓': 754, '逆': 755, '隔': 756, '袒': 757, '芮': 758, '肺': 759, '汗': 760, '权': 761, '注': 762, '华': 763, '技': 764, '肓': 765, '”': 766, '愚': 767, '奠': 768, '呃': 769, '壹': 770, '搽': 771, '榜': 772, '莫': 773, '邮': 774, '狱': 775, '镑': 776, '雁': 777, '殊': 778, '貌': 779, '两': 780, '璃': 781, '关': 782, '吻': 783, '悉': 784, '惊': 785, '靴': 786, '手': 787, '姨': 788, '朴': 789, '修': 790, '谄': 791, '必': 792, '熱': 793, '煞': 794, '煜': 795, '廉': 796, '炅': 797, '照': 798, '睿': 799, 'う': 800, '呀': 801, '甜': 802, '珞': 803, '攬': 804, '简': 805, '牧': 806, '漳': 807, '狼': 808, '契': 809, '焉': 810, '糨': 811, '賤': 812, '庄': 813, '於': 814, '\u3000': 815, '慨': 816, '吧': 817, '交': 818, '赴': 819, '薰': 820, '磋': 821, '囗': 822, '诺': 823, '龜': 824, '孀': 825, '绝': 826, '旧': 827, '擀': 828, '録': 829, '秉': 830, '淋': 831, '料': 832, '碗': 833, '七': 834, '降': 835, '乾': 836, '叨': 837, '確': 838, '韧': 839, '廳': 840, '胖': 841, '階': 842, '肿': 843, '断': 844, '汹': 845, '伪': 846, '且': 847, '烧': 848, '銀': 849, '蚌': 850, '翼': 851, '纳': 852, '斌': 853, '侃': 854, '规': 855, '款': 856, '路': 857, '拧': 858, '别': 859, '协': 860, '矮': 861, '悬': 862, '場': 863, '•': 864, '寺': 865, '昨': 866, '尘': 867, '藕': 868, '能': 869, '講': 870, '蛮': 871, '곤': 872, '澡': 873, '炫': 874, '写': 875, '够': 876, '胞': 877, '藩': 878, '赦': 879, '鈞': 880, '〖': 881, '迁': 882, '灿': 883, '桦': 884, '瞎': 885, '戲': 886, '迦': 887, '楷': 888, '玄': 889, '哮': 890, '古': 891, 'N': 892, '配': 893, '弄': 894, '太': 895, '都': 896, '盯': 897, '邹': 898, '隻': 899, '🎯': 900, '靠': 901, '谱': 902, '任': 903, '应': 904, '約': 905, '攸': 906, '恨': 907, '邵': 908, '尿': 909, '岖': 910, '煮': 911, '柄': 912, '珀': 913, '还': 914, '削': 915, '輸': 916, '诿': 917, '秩': 918, '\xa0': 919, '喽': 920, '吳': 921, '説': 922, 'E': 923, '勃': 924, '紫': 925, '补': 926, '痨': 927, '卷': 928, '巢': 929, '拢': 930, '對': 931, '浮': 932, '期': 933, '兰': 934, '勁': 935, '死': 936, '传': 937, '備': 938, '篡': 939, '瓤': 940, '醇': 941, '錢': 942, '強': 943, '狰': 944, '蛀': 945, '健': 946, '键': 947, '圳': 948, '丧': 949, '拳': 950, '沈': 951, '捉': 952, '浆': 953, '金': 954, '品': 955, '悚': 956, '佈': 957, '愫': 958, '株': 959, '陀': 960, '廣': 961, '斤': 962, '烛': 963, '连': 964, '癌': 965, '晤': 966, '诛': 967, '倫': 968, '→': 969, '梧': 970, '瀬': 971, '蜗': 972, '刨': 973, '叮': 974, '戰': 975, '界': 976, '婷': 977, '拷': 978, '飙': 979, '绷': 980, '开': 981, '還': 982, '蚝': 983, '暗': 984, '焦': 985, '右': 986, '<': 987, '脑': 988, '攀': 989, '蹋': 990, '源': 991, '热': 992, '引': 993, '圓': 994, '咂': 995, '乌': 996, '塚': 997, '银': 998, '館': 999, '范': 1000, '乍': 1001, '均': 1002, '圣': 1003, '舱': 1004, '凑': 1005, '青': 1006, '寂': 1007, '馅': 1008, '惫': 1009, '😂': 1010, '曰': 1011, '戮': 1012, '砸': 1013, '逐': 1014, '⚠': 1015, '奚': 1016, '榄': 1017, '屉': 1018, '炮': 1019, '統': 1020, '樟': 1021, '谙': 1022, '肉': 1023, '蝴': 1024, '4': 1025, '栽': 1026, '葡': 1027, '诞': 1028, '嚏': 1029, '无': 1030, '沢': 1031, '夸': 1032, '娆': 1033, '限': 1034, '跷': 1035, '样': 1036, '势': 1037, '虫': 1038, '频': 1039, '裙': 1040, '糗': 1041, '涵': 1042, '禽': 1043, '終': 1044, '搏': 1045, '勇': 1046, '秦': 1047, 'θ': 1048, '#': 1049, '&': 1050, '抠': 1051, '磅': 1052, '垃': 1053, '耀': 1054, '律': 1055, '适': 1056, '究': 1057, '杂': 1058, '堵': 1059, '迷': 1060, '钻': 1061, '缆': 1062, '职': 1063, '共': 1064, '濃': 1065, '滋': 1066, '張': 1067, '剔': 1068, '层': 1069, '媽': 1070, '恕': 1071, '细': 1072, '體': 1073, '麒': 1074, '刊': 1075, '俏': 1076, '傻': 1077, '莱': 1078, '策': 1079, '浓': 1080, '离': 1081, '鸭': 1082, 'c': 1083, '釜': 1084, '蛩': 1085, '本': 1086, '龄': 1087, '忌': 1088, '载': 1089, '訪': 1090, '泥': 1091, '朽': 1092, '叶': 1093, '字': 1094, '盐': 1095, '争': 1096, '尹': 1097, '扣': 1098, '场': 1099, '螺': 1100, '文': 1101, '挨': 1102, '炎': 1103, '竿': 1104, '恃': 1105, '贡': 1106, '堰': 1107, '栖': 1108, '捏': 1109, '≪': 1110, '腊': 1111, '杖': 1112, '肚': 1113, '幾': 1114, '<': 1115, '饥': 1116, '醒': 1117, '掼': 1118, '束': 1119, '再': 1120, '叫': 1121, '湯': 1122, '扇': 1123, '緯': 1124, '亊': 1125, '撤': 1126, '5': 1127, '室': 1128, '離': 1129, '严': 1130, '压': 1131, '霖': 1132, '魅': 1133, '改': 1134, '樽': 1135, '腥': 1136, '歲': 1137, '谜': 1138, '優': 1139, '矩': 1140, '顏': 1141, '喔': 1142, '旁': 1143, '聂': 1144, '缓': 1145, '勾': 1146, '寄': 1147, '棠': 1148, '纹': 1149, '轿': 1150, '触': 1151, '先': 1152, '投': 1153, '⒍': 1154, '傑': 1155, '鹰': 1156, '趴': 1157, '霜': 1158, '酬': 1159, '⒔': 1160, '拎': 1161, '澜': 1162, '盎': 1163, '蚁': 1164, '南': 1165, '焱': 1166, '飏': 1167, '讯': 1168, '胡': 1169, '谦': 1170, '篪': 1171, '按': 1172, '恵': 1173, '辽': 1174, '寓': 1175, '祷': 1176, '峯': 1177, '档': 1178, '尸': 1179, '‘': 1180, '牛': 1181, '遨': 1182, '匣': 1183, '拭': 1184, '赶': 1185, '润': 1186, '捧': 1187, '薦': 1188, '桢': 1189, '踮': 1190, '祈': 1191, '洞': 1192, '疱': 1193, '杞': 1194, '侬': 1195, '则': 1196, '圭': 1197, '痔': 1198, '认': 1199, '泡': 1200, '宪': 1201, '抉': 1202, '衙': 1203, '欧': 1204, '擁': 1205, '哈': 1206, '砣': 1207, '膳': 1208, '科': 1209, '睬': 1210, '買': 1211, '藥': 1212, '缠': 1213, '永': 1214, '啲': 1215, '我': 1216, '捞': 1217, '杏': 1218, '敬': 1219, '持': 1220, '牺': 1221, '陂': 1222, '辛': 1223, '慧': 1224, '傳': 1225, '汽': 1226, '雉': 1227, '饪': 1228, '打': 1229, '分': 1230, '姑': 1231, '竟': 1232, '娜': 1233, '筋': 1234, '殴': 1235, '乳': 1236, '朋': 1237, '负': 1238, '靓': 1239, '潮': 1240, '织': 1241, '洋': 1242, '揉': 1243, '象': 1244, '齊': 1245, '顺': 1246, '漉': 1247, '⒉': 1248, '挡': 1249, '冧': 1250, '咔': 1251, '角': 1252, '网': 1253, '遍': 1254, '尤': 1255, '茉': 1256, '搀': 1257, '\u200a': 1258, '豚': 1259, '绑': 1260, '绵': 1261, '實': 1262, '骇': 1263, '滩': 1264, '彼': 1265, '桔': 1266, '槟': 1267, '哆': 1268, '头': 1269, '旭': 1270, '芳': 1271, '喉': 1272, '又': 1273, '脏': 1274, '几': 1275, '羽': 1276, '鑫': 1277, '沧': 1278, '「': 1279, '净': 1280, '驰': 1281, '帘': 1282, '企': 1283, '绯': 1284, '啪': 1285, '献': 1286, '掌': 1287, '赫': 1288, '癫': 1289, '诉': 1290, '承': 1291, '列': 1292, '緣': 1293, '复': 1294, '天': 1295, '丈': 1296, '元': 1297, '货': 1298, '辱': 1299, '糕': 1300, '咽': 1301, '厥': 1302, '地': 1303, '伶': 1304, '谨': 1305, '魄': 1306, '識': 1307, '孕': 1308, '負': 1309, '存': 1310, '⑥': 1311, '宁': 1312, '闺': 1313, '个': 1314, '虏': 1315, '暖': 1316, '冤': 1317, '母': 1318, '组': 1319, '燃': 1320, '憋': 1321, '厨': 1322, '咸': 1323, '贿': 1324, '捶': 1325, '租': 1326, '毒': 1327, '炳': 1328, '熔': 1329, '澄': 1330, '抑': 1331, '領': 1332, '惭': 1333, '满': 1334, '菇': 1335, '另': 1336, '旋': 1337, '柏': 1338, '些': 1339, '质': 1340, '撇': 1341, '恰': 1342, '臣': 1343, '丛': 1344, '沇': 1345, '远': 1346, '烂': 1347, '债': 1348, '批': 1349, '菊': 1350, '夜': 1351, '锻': 1352, '嚓': 1353, '傍': 1354, '邡': 1355, '晓': 1356, '岸': 1357, '爱': 1358, '毕': 1359, '漓': 1360, '锡': 1361, '⒕': 1362, '访': 1363, '豆': 1364, '沾': 1365, '牢': 1366, '惠': 1367, '豹': 1368, '念': 1369, '唤': 1370, '扭': 1371, '網': 1372, '爷': 1373, '錯': 1374, '旅': 1375, '休': 1376, '桶': 1377, '疼': 1378, '📢': 1379, '铁': 1380, '叙': 1381, '楼': 1382, '辟': 1383, '搞': 1384, 'て': 1385, '台': 1386, '炽': 1387, '侯': 1388, '霓': 1389, '粹': 1390, '卦': 1391, '煎': 1392, '枪': 1393, '高': 1394, '叟': 1395, '巧': 1396, '桥': 1397, '跪': 1398, '萝': 1399, '唇': 1400, '苑': 1401, '旗': 1402, '渊': 1403, '葩': 1404, '晾': 1405, '伦': 1406, '受': 1407, '椒': 1408, '姚': 1409, '梗': 1410, '尬': 1411, '局': 1412, '庝': 1413, '兲': 1414, '竞': 1415, '被': 1416, '雞': 1417, '覺': 1418, '攪': 1419, '惘': 1420, '丘': 1421, '闷': 1422, '擦': 1423, '沟': 1424, '皮': 1425, '炼': 1426, '礦': 1427, '叹': 1428, '检': 1429, '陈': 1430, '胎': 1431, '👏': 1432, '甘': 1433, '颍': 1434, '萬': 1435, '部': 1436, '楚': 1437, '隋': 1438, '燈': 1439, '客': 1440, '⒓': 1441, '襟': 1442, '悠': 1443, '葫': 1444, '着': 1445, '徹': 1446, '撅': 1447, '弘': 1448, '琅': 1449, '怨': 1450, '+': 1451, '披': 1452, '筠': 1453, '习': 1454, '停': 1455, '翻': 1456, '寿': 1457, '寝': 1458, '维': 1459, '漏': 1460, '程': 1461, '向': 1462, '=': 1463, '拘': 1464, '乙': 1465, '將': 1466, '姥': 1467, '柳': 1468, '冯': 1469, '搖': 1470, '吠': 1471, '上': 1472, '蹈': 1473, 'M': 1474, '倔': 1475, '痤': 1476, '腺': 1477, '须': 1478, '秤': 1479, '姿': 1480, '逛': 1481, 'S': 1482, '窈': 1483, '彰': 1484, '黎': 1485, '帷': 1486, '+': 1487, '县': 1488, '釧': 1489, '觊': 1490, '扒': 1491, '幼': 1492, '崖': 1493, '多': 1494, '峡': 1495, '动': 1496, '溃': 1497, '翠': 1498, '液': 1499, '抗': 1500, '拋': 1501, '管': 1502, 'K': 1503, '睛': 1504, '案': 1505, '宅': 1506, '鲲': 1507, '扬': 1508, '折': 1509, '珍': 1510, '幫': 1511, '届': 1512, '節': 1513, '嚷': 1514, '問': 1515, '虞': 1516, '校': 1517, '造': 1518, '憧': 1519, '退': 1520, '祎': 1521, '溜': 1522, '役': 1523, '逼': 1524, '➊': 1525, '語': 1526, '超': 1527, '辜': 1528, '4': 1529, '奋': 1530, '虚': 1531, '卑': 1532, '袁': 1533, '\ue00e': 1534, '嘅': 1535, '骸': 1536, 'サ': 1537, '僳': 1538, '芦': 1539, '股': 1540, '舰': 1541, '奕': 1542, '撞': 1543, '癢': 1544, '膨': 1545, '攫': 1546, '伤': 1547, '枭': 1548, '诅': 1549, '哨': 1550, '荡': 1551, '膛': 1552, '爸': 1553, '沉': 1554, '悟': 1555, '蹦': 1556, '陳': 1557, '弯': 1558, '梨': 1559, '脉': 1560, '烈': 1561, '蘇': 1562, '肘': 1563, '确': 1564, '漆': 1565, '8': 1566, '钊': 1567, '获': 1568, '噱': 1569, '刺': 1570, '丽': 1571, '扩': 1572, '领': 1573, '潇': 1574, '即': 1575, '把': 1576, '撕': 1577, ',': 1578, '吟': 1579, '饨': 1580, '隘': 1581, 'i': 1582, '夠': 1583, '郝': 1584, '者': 1585, '渠': 1586, '淄': 1587, '嵌': 1588, '幻': 1589, '鸣': 1590, '兑': 1591, 'ャ': 1592, '脊': 1593, '和': 1594, '柒': 1595, '簿': 1596, '匀': 1597, '缩': 1598, '井': 1599, '隆': 1600, '龍': 1601, '寸': 1602, '浴': 1603, '将': 1604, '徙': 1605, '塔': 1606, '定': 1607, '營': 1608, '⒖': 1609, '評': 1610, '或': 1611, '鸡': 1612, '轉': 1613, '崩': 1614, '矢': 1615, '甄': 1616, '晒': 1617, '喵': 1618, '窦': 1619, '⒌': 1620, '環': 1621, '姗': 1622, '❤': 1623, '齿': 1624, '阱': 1625, '北': 1626, '抵': 1627, '眈': 1628, '舅': 1629, '伙': 1630, '陷': 1631, '剥': 1632, '淀': 1633, '恍': 1634, '蔥': 1635, '宛': 1636, '卻': 1637, '览': 1638, '應': 1639, '動': 1640, '顿': 1641, '义': 1642, '炜': 1643, '奖': 1644, '琍': 1645, '啬': 1646, '匡': 1647, '狄': 1648, '欢': 1649, '阖': 1650, '方': 1651, '↓': 1652, '劑': 1653, '占': 1654, '贬': 1655, '观': 1656, '弧': 1657, '口': 1658, '蘋': 1659, '封': 1660, '拽': 1661, '哇': 1662, '船': 1663, '畜': 1664, '洗': 1665, '嘟': 1666, '忡': 1667, '佑': 1668, '贞': 1669, '俩': 1670, '它': 1671, '埋': 1672, '/': 1673, '殺': 1674, '窘': 1675, '兹': 1676, '纬': 1677, '桑': 1678, '迭': 1679, '卖': 1680, '➋': 1681, '躲': 1682, '驻': 1683, '阀': 1684, '穎': 1685, '嗨': 1686, '簸': 1687, '腔': 1688, '🔲': 1689, '努': 1690, '剁': 1691, '擅': 1692, '欺': 1693, '⒐': 1694, '唔': 1695, '们': 1696, '逝': 1697, '斓': 1698, '积': 1699, '烨': 1700, 'R': 1701, '陸': 1702, '悔': 1703, '非': 1704, '耗': 1705, '园': 1706, '嘎': 1707, '蝎': 1708, '咙': 1709, '侨': 1710, '痘': 1711, '曹': 1712, '侥': 1713, '接': 1714, '咖': 1715, '9': 1716, '住': 1717, '玛': 1718, '鞠': 1719, '脾': 1720, '撼': 1721, '火': 1722, '剩': 1723, '牙': 1724, '酋': 1725, '韶': 1726, '目': 1727, '论': 1728, '环': 1729, '6': 1730, '祛': 1731, '喊': 1732, '娘': 1733, '抄': 1734, '构': 1735, '嗲': 1736, '缮': 1737, '贤': 1738, '遣': 1739, '竺': 1740, '缙': 1741, '雅': 1742, '摇': 1743, '间': 1744, '刀': 1745, '拍': 1746, '(': 1747, '庐': 1748, '胺': 1749, '携': 1750, '价': 1751, '合': 1752, '益': 1753, '溝': 1754, '電': 1755, '佢': 1756, '黑': 1757, '骗': 1758, '亿': 1759, '阉': 1760, '坼': 1761, '趋': 1762, '蕉': 1763, '侠': 1764, '昌': 1765, '素': 1766, '飯': 1767, '僧': 1768, '逻': 1769, '赌': 1770, '尊': 1771, '紋': 1772, '彬': 1773, '庆': 1774, '找': 1775, '讲': 1776, '…': 1777, '雇': 1778, '纪': 1779, 'J': 1780, '」': 1781, '杯': 1782, '獎': 1783, '吕': 1784, '皓': 1785, '沁': 1786, '椽': 1787, '出': 1788, '邱': 1789, '咗': 1790, '?': 1791, '充': 1792, '阳': 1793, '\ue141': 1794, '扶': 1795, '亢': 1796, '逃': 1797, '河': 1798, '治': 1799, '愿': 1800, '际': 1801, '图': 1802, '拔': 1803, '祸': 1804, '墟': 1805, '横': 1806, '啦': 1807, '炒': 1808, '首': 1809, '證': 1810, '丢': 1811, '芜': 1812, '少': 1813, '敞': 1814, '诫': 1815, '陆': 1816, '`': 1817, '旬': 1818, '刑': 1819, '行': 1820, '.': 1821, 'é': 1822, '删': 1823, '犬': 1824, '邪': 1825, '亨': 1826, '*': 1827, '巳': 1828, '虑': 1829, '灵': 1830, '箭': 1831, '倡': 1832, '隧': 1833, '懒': 1834, '疡': 1835, '已': 1836, '摔': 1837, '谋': 1838, '讼': 1839, '衡': 1840, '妥': 1841, '鞋': 1842, '区': 1843, '仲': 1844, '盘': 1845, '腚': 1846, '沒': 1847, '拌': 1848, '蒸': 1849, '侵': 1850, '迹': 1851, '守': 1852, '湿': 1853, '達': 1854, '骏': 1855, '萧': 1856, '硝': 1857, '麻': 1858, '颗': 1859, '柔': 1860, '昧': 1861, '堪': 1862, '晟': 1863, '衔': 1864, '杠': 1865, '啖': 1866, '戟': 1867, '睹': 1868, '异': 1869, 'h': 1870, '┭': 1871, '迢': 1872, '蕾': 1873, '怜': 1874, '缴': 1875, '印': 1876, '醫': 1877, '袍': 1878, '妊': 1879, '录': 1880, '嘈': 1881, '蕭': 1882, '闹': 1883, '支': 1884, '唐': 1885, '星': 1886, '订': 1887, '烦': 1888, '齒': 1889, '甫': 1890, '既': 1891, '疮': 1892, '绪': 1893, '皇': 1894, '莲': 1895, '志': 1896, '涡': 1897, '偎': 1898, '胁': 1899, '疹': 1900, '勺': 1901, '因': 1902, '杜': 1903, '宠': 1904, '渎': 1905, '贯': 1906, '瓦': 1907, '衅': 1908, '叩': 1909, '瘀': 1910, '直': 1911, '肥': 1912, '许': 1913, '京': 1914, '敲': 1915, '褶': 1916, '沸': 1917, '毁': 1918, '讨': 1919, '屿': 1920, '值': 1921, '蹭': 1922, '芩': 1923, '街': 1924, '馨': 1925, '髦': 1926, '湧': 1927, '粵': 1928, '玻': 1929, '朱': 1930, '凌': 1931, '汕': 1932, '絕': 1933, '謝': 1934, '完': 1935, '函': 1936, '龚': 1937, '飽': 1938, '檐': 1939, '猫': 1940, '坍': 1941, '微': 1942, '跌': 1943, '奏': 1944, '仙': 1945, '站': 1946, '彪': 1947, '尔': 1948, '迈': 1949, '节': 1950, '尽': 1951, '诠': 1952, '乏': 1953, '犯': 1954, '研': 1955, '宰': 1956, '厮': 1957, '項': 1958, '搬': 1959, '忘': 1960, '当': 1961, '怀': 1962, '冲': 1963, '侄': 1964, '骤': 1965, '況': 1966, '會': 1967, '卸': 1968, '泾': 1969, '毯': 1970, '剑': 1971, '见': 1972, '蔗': 1973, '輩': 1974, '季': 1975, '珊': 1976, '嚕': 1977, '稣': 1978, '建': 1979, '误': 1980, '询': 1981, '茂': 1982, '獠': 1983, '潘': 1984, '舆': 1985, '嫁': 1986, '砂': 1987, '係': 1988, '仅': 1989, '茫': 1990, '酥': 1991, '茎': 1992, '汾': 1993, '﹣': 1994, '凶': 1995, '居': 1996, '喂': 1997, '搅': 1998, '璋': 1999, '羁': 2000, '挥': 2001, '回': 2002, '囊': 2003, '赞': 2004, '揪': 2005, '浦': 2006, '椰': 2007, '衷': 2008, ':': 2009, '汤': 2010, '編': 2011, '裏': 2012, '续': 2013, '广': 2014, '靡': 2015, '困': 2016, '選': 2017, '今': 2018, '垫': 2019, '崴': 2020, '车': 2021, '择': 2022, '饼': 2023, '炬': 2024, '傲': 2025, '組': 2026, '若': 2027, '敌': 2028, '疽': 2029, '骄': 2030, '誓': 2031, '温': 2032, '攝': 2033, '忻': 2034, '千': 2035, '綠': 2036, '辑': 2037, '佯': 2038, '傾': 2039, '桃': 2040, '抿': 2041, '踏': 2042, '豫': 2043, '态': 2044, '❌': 2045, '抹': 2046, '懈': 2047, '员': 2048, '对': 2049, '圾': 2050, '潭': 2051, '孔': 2052, '看': 2053, '鬼': 2054, '假': 2055, '呱': 2056, '號': 2057, '鍾': 2058, 'も': 2059, '疗': 2060, '谷': 2061, '彗': 2062, '丝': 2063, '之': 2064, '阪': 2065, '帮': 2066, '侧': 2067, '付': 2068, '祀': 2069, '苯': 2070, '诚': 2071, '歪': 2072, '举': 2073, '加': 2074, '婺': 2075, '窃': 2076, '👽': 2077, '容': 2078, '切': 2079, '锦': 2080, '唉': 2081, '弊': 2082, '及': 2083, '寻': 2084, '式': 2085, '页': 2086, '随': 2087, '钟': 2088, '炙': 2089, '颐': 2090, '瘦': 2091, '肤': 2092, '2': 2093, '絮': 2094, '畔': 2095, '娟': 2096, '⑤': 2097, '晰': 2098, '馆': 2099, '疏': 2100, '砧': 2101, '挂': 2102, '視': 2103, '浔': 2104, '丫': 2105, '1': 2106, '纷': 2107, '掏': 2108, '释': 2109, '惟': 2110, '家': 2111, '芥': 2112, '侮': 2113, '挝': 2114, '狠': 2115, '畸': 2116, 'A': 2117, '殃': 2118, '鲁': 2119, '琴': 2120, '枉': 2121, '佳': 2122, '菲': 2123, 'ン': 2124, '甩': 2125, '唱': 2126, '糟': 2127, '徨': 2128, '进': 2129, '忆': 2130, '蚂': 2131, '氣': 2132, '諾': 2133, '敦': 2134, '叭': 2135, '梳': 2136, '庇': 2137, '球': 2138, '饺': 2139, 'V': 2140, '增': 2141, '《': 2142, '亏': 2143, '匹': 2144, '楠': 2145, '畅': 2146, '暮': 2147, '物': 2148, '屠': 2149, '税': 2150, '魏': 2151, '碰': 2152, '[': 2153, '鲜': 2154, '蟹': 2155, '縛': 2156, '基': 2157, '蔡': 2158, '爽': 2159, '導': 2160, '级': 2161, '赛': 2162, '项': 2163, '寞': 2164, '湘': 2165, '渴': 2166, '么': 2167, '稚': 2168, '冷': 2169, '轩': 2170, '\ue419': 2171, '教': 2172, '爪': 2173, '淆': 2174, '轻': 2175, '靈': 2176, '融': 2177, '衩': 2178, '結': 2179, '喱': 2180, '曉': 2181, '贴': 2182, '云': 2183, '尝': 2184, '紧': 2185, '慘': 2186, '线': 2187, '笋': 2188, '暴': 2189, '數': 2190, '不': 2191, '拖': 2192, '滤': 2193, '秀': 2194, '蜀': 2195, '愤': 2196, '易': 2197, '导': 2198, '玲': 2199, '蛇': 2200, '奂': 2201, '挫': 2202, '嘛': 2203, '腻': 2204, '雯': 2205, '阔': 2206, '实': 2207, '蛊': 2208, '叼': 2209, '经': 2210, '廊': 2211, '拓': 2212, '达': 2213, '混': 2214, '仆': 2215, '痕': 2216, '较': 2217, '信': 2218, '镌': 2219, '荣': 2220, '羊': 2221, '吴': 2222, '苟': 2223, '借': 2224, '郑': 2225, '祠': 2226, '喜': 2227, '歌': 2228, '况': 2229, '桉': 2230, '笔': 2231, '聆': 2232, '树': 2233, '啃': 2234, '飞': 2235, '从': 2236, '門': 2237, 'G': 2238, '仓': 2239, '位': 2240, '欣': 2241, '音': 2242, '扑': 2243, '❗': 2244, '透': 2245, '述': 2246, '報': 2247, '咎': 2248, '肌': 2249, '吊': 2250, '了': 2251, '贾': 2252, '半': 2253, '截': 2254, '‼': 2255, '允': 2256, '瞄': 2257, '奴': 2258, '鹿': 2259, '蓆': 2260, 'め': 2261, '故': 2262, '革': 2263, '循': 2264, '诩': 2265, '拉': 2266, '\ue112': 2267, '〜': 2268, '粘': 2269, '眨': 2270, '垮': 2271, '⒋': 2272, '≧': 2273, '呸': 2274, '量': 2275, '氰': 2276, '涩': 2277, '吁': 2278, '瑜': 2279, '有': 2280, '罚': 2281, '邢': 2282, '英': 2283, '鼠': 2284, '蜘': 2285, '⑦': 2286, '別': 2287, '際': 2288, '记': 2289, '麼': 2290, '城': 2291, '邊': 2292, '哉': 2293, '茹': 2294, '矣': 2295, '聞': 2296, '航': 2297, '瘙': 2298, '椅': 2299, '泰': 2300, '屬': 2301, '蹂': 2302, '咁': 2303, '躁': 2304, '|': 2305, '变': 2306, '胜': 2307, '调': 2308, '疆': 2309, '该': 2310, '亡': 2311, '晔': 2312, '窒': 2313, '罡': 2314, '核': 2315, '·': 2316, '糠': 2317, '旨': 2318, '钱': 2319, '凰': 2320, '民': 2321, '祥': 2322, '洒': 2323, '锅': 2324, '悄': 2325, '迂': 2326, '器': 2327, '戳': 2328, '蒲': 2329, '诙': 2330, '喳': 2331, '為': 2332, '雨': 2333, '旻': 2334, '灼': 2335, '肝': 2336, '匠': 2337, '土': 2338, '琳': 2339, '惩': 2340, '・': 2341, '姐': 2342, '彩': 2343, '障': 2344, '進': 2345, '劵': 2346, '理': 2347, '沏': 2348, '外': 2349, '佛': 2350, 'か': 2351, '裝': 2352, '皙': 2353, '颇': 2354, '肪': 2355, '崔': 2356, '嚼': 2357, '讳': 2358, '救': 2359, '淮': 2360, '烁': 2361, '搂': 2362, '⒎': 2363, '臀': 2364, '💗': 2365, '诀': 2366, '踪': 2367, '辆': 2368, '殇': 2369, '岁': 2370, '猥': 2371, '墩': 2372, '晃': 2373, '渔': 2374, '腐': 2375, '觉': 2376, '吨': 2377, '芙': 2378, '🇸': 2379, '服': 2380, '需': 2381, 't': 2382, '琨': 2383, '丐': 2384, '昼': 2385, '兜': 2386, '事': 2387, '谬': 2388, '氛': 2389, '菠': 2390, '介': 2391, '径': 2392, '俐': 2393, '黯': 2394, '3': 2395, '陕': 2396, '➍': 2397, '蝙': 2398, '岐': 2399, '藝': 2400, '黏': 2401, '蓉': 2402, '陶': 2403, '准': 2404, '追': 2405, '衝': 2406, '雌': 2407, '沃': 2408, '關': 2409, '贝': 2410, 'd': 2411, '博': 2412, '速': 2413, '洁': 2414, '珐': 2415, '督': 2416, '瑞': 2417, '步': 2418, '嗯': 2419, '贸': 2420, '喀': 2421, '拟': 2422, '件': 2423, '💓': 2424, '生': 2425, '钨': 2426, '!': 2427, '機': 2428, '\ue41d': 2429, '皱': 2430, '族': 2431, '僭': 2432, '镐': 2433, '精': 2434, '艘': 2435, '镖': 2436, '曙': 2437, '扔': 2438, '😚': 2439, '勉': 2440, '疯': 2441, '赋': 2442, '騙': 2443, '徐': 2444, '塑': 2445, '凭': 2446, '人': 2447, '川': 2448, '\ue333': 2449, '弈': 2450, '賀': 2451, '党': 2452, '始': 2453, 'v': 2454, '腋': 2455, '致': 2456, '隊': 2457, '丸': 2458, '😭': 2459, '格': 2460, '幸': 2461, '與': 2462, '淌': 2463, '掩': 2464, '待': 2465, '于': 2466, '悍': 2467, '蹲': 2468, '难': 2469, '禺': 2470, '可': 2471, '義': 2472, '䄂': 2473, '谢': 2474, '咕': 2475, '毬': 2476, '喇': 2477, '戸': 2478, '魚': 2479, '娠': 2480, '圈': 2481, '弓': 2482, '蒋': 2483, '掘': 2484, '滾': 2485, '谶': 2486, '孱': 2487, '購': 2488, '躏': 2489, '呵': 2490, '焯': 2491, '\ue418': 2492, '仰': 2493, '密': 2494, '苗': 2495, '纠': 2496, '霆': 2497, '臥': 2498, '灬': 2499, '願': 2500, '荐': 2501, '惧': 2502, '兽': 2503, '渡': 2504, '酷': 2505, '森': 2506, '厘': 2507, '食': 2508, '办': 2509, '俞': 2510, '训': 2511, '灭': 2512, '婕': 2513, '袜': 2514, '罢': 2515, '旺': 2516, '瞥': 2517, '寧': 2518, '笨': 2519, '筷': 2520, '睦': 2521, '迪': 2522, '种': 2523, '題': 2524, '纲': 2525, '預': 2526, '螂': 2527, '醉': 2528, '息': 2529, '胭': 2530, '昕': 2531, '鲨': 2532, '衰': 2533, '逸': 2534, '享': 2535, '士': 2536, '纵': 2537, '莓': 2538, '顾': 2539, '孩': 2540, '拨': 2541, '乓': 2542, '吐': 2543, '显': 2544, '難': 2545, '泌': 2546, '舉': 2547, '剃': 2548, '∕': 2549, '無': 2550, '叔': 2551, '俗': 2552, '裕': 2553, '~': 2554, '讓': 2555, '卜': 2556, '奔': 2557, '凤': 2558, '畏': 2559, '6': 2560, '虐': 2561, '婆': 2562, '骆': 2563, '霧': 2564, '最': 2565, '缨': 2566, 'z': 2567, '晶': 2568, '粑': 2569, '觑': 2570, '砷': 2571, '劣': 2572, '濡': 2573, '骁': 2574, '附': 2575, '鱼': 2576, '综': 2577, '敷': 2578, '粟': 2579, 'x': 2580, '恩': 2581, '迫': 2582, 'з': 2583, '予': 2584, '谟': 2585, '辍': 2586, '螨': 2587, '幽': 2588, '讥': 2589, '填': 2590, '專': 2591, '报': 2592, '驴': 2593, '促': 2594, '语': 2595, '辣': 2596, '棵': 2597, '峙': 2598, '崎': 2599, '珑': 2600, '左': 2601, '東': 2602, '琥': 2603, '厢': 2604, '悦': 2605, '心': 2606, '莞': 2607, '☞': 2608, '阎': 2609, '琼': 2610, '赔': 2611, '厦': 2612, '瞑': 2613, '邃': 2614, '苍': 2615, '炉': 2616, '朗': 2617, '视': 2618, '劲': 2619, '臾': 2620, '颖': 2621, '哋': 2622, '堆': 2623, '课': 2624, '咪': 2625, '缘': 2626, '屍': 2627, '恻': 2628, '裹': 2629, '市': 2630, '魯': 2631, '卵': 2632, '扎': 2633, '钞': 2634, '禀': 2635, '瘋': 2636, '窿': 2637, '差': 2638, '脂': 2639, '化': 2640, '掺': 2641, '菩': 2642, '溟': 2643, '焰': 2644, '淳': 2645, '逢': 2646, '铎': 2647, '訂': 2648, '鬣': 2649, '括': 2650, '启': 2651, '吾': 2652, '输': 2653, '芽': 2654, '昆': 2655, '旦': 2656, '套': 2657, '韦': 2658, '姻': 2659, '弗': 2660, '戒': 2661, '遁': 2662, 'B': 2663, '蔬': 2664, '俠': 2665, '读': 2666, '早': 2667, '并': 2668, '三': 2669, '剿': 2670, '颈': 2671, '渭': 2672, '罒': 2673, '亭': 2674, '湛': 2675, '铛': 2676, '嗜': 2677, '巍': 2678, '讣': 2679, '恋': 2680, '酒': 2681, '蔓': 2682, '冠': 2683, '绚': 2684, '碉': 2685, '減': 2686, '抓': 2687, '眠': 2688, '%': 2689, 'q': 2690, '婚': 2691, '肛': 2692, '让': 2693, '梦': 2694, '李': 2695, '得': 2696, '乞': 2697, '赂': 2698, '圆': 2699, '擎': 2700, 'F': 2701, '务': 2702, '=': 2703, '解': 2704, '宴': 2705, '名': 2706, '鹂': 2707, '碑': 2708, '篮': 2709, '带': 2710, '议': 2711, '鲍': 2712, '慰': 2713, '舊': 2714, '感': 2715, '煥': 2716, '饰': 2717, '爆': 2718, '梁': 2719, '副': 2720, '米': 2721, '腹': 2722, '🐵': 2723, '耻': 2724, '赵': 2725, '蛛': 2726, '羯': 2727, '瑚': 2728, '忏': 2729, '箴': 2730, '驚': 2731, '除': 2732, '娃': 2733, '链': 2734, '嬉': 2735, '袱': 2736, '㎡': 2737, '噜': 2738, '中': 2739, '谐': 2740, '识': 2741, '禅': 2742, '秽': 2743, '眩': 2744, '彦': 2745, '塞': 2746, '摒': 2747, '魂': 2748, '秋': 2749, '铭': 2750, '\\': 2751, '泱': 2752, '胶': 2753, '樣': 2754, '妃': 2755, '厄': 2756, '尅': 2757, '术': 2758, '转': 2759, '途': 2760, '灯': 2761, '爹': 2762, '喻': 2763, '痒': 2764, '栎': 2765, '馬': 2766, '訓': 2767, '囂': 2768, '▽': 2769, '联': 2770, '熄': 2771, '周': 2772, '殷': 2773, '整': 2774, '睇': 2775, '便': 2776, '蜷': 2777, '硕': 2778, '彻': 2779, '试': 2780, '傭': 2781, '冼': 2782, '避': 2783, 'ノ': 2784, '镜': 2785, '瓣': 2786, '噤': 2787, '耐': 2788, '炸': 2789, '疾': 2790, '商': 2791, '愁': 2792, '腑': 2793, '吏': 2794, '贷': 2795, '算': 2796, '瞧': 2797, '孰': 2798, '婪': 2799, '氧': 2800, '详': 2801, '崛': 2802, '福': 2803, '营': 2804, '姓': 2805, '霾': 2806, '奈': 2807, '潜': 2808, '✨': 2809, '铱': 2810, '妝': 2811, '裸': 2812, '递': 2813, '番': 2814, '薇': 2815, '瑟': 2816, '挚': 2817, '默': 2818, '妍': 2819, '诽': 2820, '忠': 2821, '欠': 2822, '诋': 2823, '秘': 2824, '栗': 2825, '风': 2826, '跋': 2827, '師': 2828, '取': 2829, '灾': 2830, '瑪': 2831, '遏': 2832, '彝': 2833, '侦': 2834, '妩': 2835, '"': 2836, '院': 2837, '础': 2838, '藍': 2839, '也': 2840, '此': 2841, '灌': 2842, '兴': 2843, '覆': 2844, '馍': 2845, '公': 2846, '怎': 2847, '亚': 2848, '跳': 2849, '肠': 2850, '歡': 2851, '坡': 2852, '邂': 2853, '凹': 2854, '谁': 2855, '插': 2856, '荷': 2857, '琵': 2858, '兒': 2859, '槃': 2860, '芒': 2861, 'k': 2862, '豢': 2863, '她': 2864, '穿': 2865, '劈': 2866, '尴': 2867, '击': 2868, '滴': 2869, '茜': 2870, '募': 2871, '烙': 2872, '柱': 2873, '嘘': 2874, '夙': 2875, '】': 2876, '擇': 2877, '肢': 2878, '璐': 2879, '粮': 2880, '阻': 2881, '绞': 2882, '赤': 2883, '捂': 2884, '泵': 2885, '圃': 2886, '蓬': 2887, '赖': 2888, '悯': 2889, '底': 2890, '岩': 2891, '淤': 2892, '闲': 2893, '慶': 2894, '媛': 2895, '惕': 2896, '岂': 2897, '为': 2898, '贩': 2899, '田': 2900, '勒': 2901, '捅': 2902, '业': 2903, '黃': 2904, '话': 2905, '愛': 2906, '徒': 2907, '什': 2908, '屁': 2909, '孝': 2910, '胳': 2911, '闭': 2912, '雕': 2913, 'し': 2914, '卧': 2915, '农': 2916, '奥': 2917, '伟': 2918, '轰': 2919, '昏': 2920, '馥': 2921, '戚': 2922, '戶': 2923, '饿': 2924, '糸': 2925, '入': 2926, '逗': 2927, '豬': 2928, '波': 2929, '尋': 2930, '颠': 2931, '堂': 2932, '枚': 2933, '枝': 2934, '珉': 2935, '送': 2936, '脖': 2937, '成': 2938, '咬': 2939, '鲟': 2940, '抚': 2941, '与': 2942, '茬': 2943, '拱': 2944, '学': 2945, '?': 2946, '摸': 2947, '腌': 2948, '怒': 2949, '哗': 2950, '选': 2951, '眼': 2952, '芬': 2953, '罕': 2954, '创': 2955, '涂': 2956, '稻': 2957, '大': 2958, '腱': 2959, '辈': 2960, '億': 2961, '猴': 2962, '新': 2963, 'y': 2964, '射': 2965, '概': 2966, '娇': 2967, '败': 2968, '辞': 2969, '裱': 2970, '個': 2971, '额': 2972, '帖': 2973, '遂': 2974, '質': 2975, '頭': 2976, '绕': 2977, '噢': 2978, '래': 2979, '房': 2980, '丹': 2981, '条': 2982, '苒': 2983, '捐': 2984, '顶': 2985, '檬': 2986, '災': 2987, '返': 2988, '史': 2989, '逊': 2990, '糜': 2991, '题': 2992, '嫌': 2993, '蓝': 2994, '饲': 2995, '沙': 2996, '蘑': 2997, '雪': 2998, '材': 2999, '媚': 3000, '』': 3001, '葵': 3002, '妄': 3003, '穷': 3004, '贈': 3005, '焕': 3006, '嘱': 3007, '播': 3008, '援': 3009, '脸': 3010, '废': 3011, '菜': 3012, '糯': 3013, '-': 3014, '蘭': 3015, '!': 3016, '四': 3017, '临': 3018, '苹': 3019, '缕': 3020, '迄': 3021, '窗': 3022, '孤': 3023, '罹': 3024, '萄': 3025, '莹': 3026, '蜕': 3027, '遵': 3028, '橄': 3029, '乘': 3030, '那': 3031, '仿': 3032, '絲': 3033, '\ue109': 3034, '扫': 3035, '贫': 3036, '隅': 3037, '觎': 3038, '雲': 3039, '洛': 3040, '踢': 3041, '抛': 3042, '磁': 3043, '穆': 3044, '涛': 3045, 'H': 3046, '贼': 3047, '噩': 3048, '昭': 3049, '蝠': 3050, '墅': 3051, '屹': 3052, '堕': 3053, '祇': 3054, '靜': 3055, '禄': 3056, '购': 3057, '瑶': 3058, 'à': 3059, '言': 3060, '泽': 3061, '揚': 3062, '宣': 3063, '瀑': 3064, '书': 3065, '澈': 3066, '玑': 3067, '违': 3068, '劳': 3069, '較': 3070, '指': 3071, '詩': 3072, '纤': 3073, '笑': 3074, '華': 3075, '诗': 3076, '袂': 3077, '倪': 3078, '羞': 3079, '拾': 3080, '小': 3081, '¥': 3082, '轮': 3083, '纽': 3084, '蹬': 3085, '惯': 3086, '➌': 3087, '下': 3088, '宽': 3089, '好': 3090, '店': 3091, '芝': 3092, '藻': 3093, '暑': 3094, '跑': 3095, '褐': 3096, '響': 3097, '、': 3098, '☑': 3099, '短': 3100, '晚': 3101, '挪': 3102, '⒏': 3103, '哕': 3104, '形': 3105, '陪': 3106, '芭': 3107, '枣': 3108, '總': 3109, '〞': 3110, '涅': 3111, '但': 3112, '影': 3113, '据': 3114, '笫': 3115, '港': 3116, '月': 3117, '版': 3118, '彷': 3119, '柴': 3120, '阿': 3121, '玩': 3122, '损': 3123, '结': 3124, '虎': 3125, '殖': 3126, '韓': 3127, '鯉': 3128, '歇': 3129, '屯': 3130, '句': 3131, '坊': 3132, '酸': 3133, '某': 3134, '屏': 3135, '養': 3136, '迟': 3137, '萌': 3138, '产': 3139, '减': 3140, '嘍': 3141, '颚': 3142, '遇': 3143, '倦': 3144, '嘶': 3145, '獻': 3146, '枫': 3147, '置': 3148, '钗': 3149, '响': 3150, '奘': 3151, '现': 3152, '➏': 3153, '消': 3154, '屋': 3155, '粗': 3156, '痊': 3157, '狈': 3158, '海': 3159, '卓': 3160, '郭': 3161, '帛': 3162, '过': 3163, '坤': 3164, '晗': 3165, '杨': 3166, '賓': 3167, '岼': 3168, '嘿': 3169, '辉': 3170, '蜡': 3171, '愣': 3172, '伐': 3173, '张': 3174, '帆': 3175, '龈': 3176, '害': 3177, '團': 3178, '重': 3179, '自': 3180, '剧': 3181, '骂': 3182, '亲': 3183, '践': 3184, '寡': 3185, '荫': 3186, '用': 3187, '系': 3188, '\u200b': 3189, '橙': 3190, '愉': 3191, '缉': 3192, '哦': 3193, '窟': 3194, '砖': 3195, '鴻': 3196, '体': 3197, '空': 3198, '汉': 3199, '阅': 3200, '淡': 3201, '祭': 3202, '痈': 3203, '映': 3204, '卡': 3205, '牠': 3206, '夕': 3207, '财': 3208, '豊': 3209, '麟': 3210, '贵': 3211, 'X': 3212, '驼': 3213, '脱': 3214, '¥': 3215, '@': 3216, '(': 3217, '矛': 3218, '瓷': 3219, '汨': 3220, '框': 3221, '悱': 3222, '竖': 3223, '宾': 3224, '霸': 3225, '坟': 3226, '栋': 3227, 'a': 3228, '同': 3229, '正': 3230, '片': 3231, 'b': 3232, '边': 3233, '樱': 3234, '畑': 3235, '要': 3236, '斯': 3237, '咯': 3238, '的': 3239, '亦': 3240, '摊': 3241, '赁': 3242, '續': 3243, '呻': 3244, '司': 3245, '摆': 3246, '绳': 3247, '唠': 3248, '嬷': 3249, '煌': 3250, '章': 3251, '翅': 3252, '\': 3253, '腿': 3254, '棘': 3255, '老': 3256, '{': 3257, '姬': 3258, '惶': 3259, '晴': 3260, '兮': 3261, '咏': 3262, '号': 3263, '漠': 3264, '厅': 3265, '匙': 3266, '議': 3267, '滥': 3268, '飆': 3269, '锤': 3270, '屎': 3271, '幕': 3272, '祝': 3273, '阴': 3274, '盟': 3275, '壤': 3276, '胸': 3277, '妓': 3278, '囉': 3279, '瑕': 3280, '阮': 3281, '㎝': 3282, '峰': 3283, '溧': 3284, '轺': 3285, '止': 3286, '浩': 3287, '趕': 3288, '衛': 3289, '遷': 3290, '奶': 3291, '供': 3292, '这': 3293, '現': 3294, '塌': 3295, '慎': 3296, '提': 3297, '良': 3298, '津': 3299, '威': 3300, '州': 3301, '售': 3302, '筒': 3303, '┮': 3304, '🇺': 3305, ')': 3306, '溺': 3307, '春': 3308, '鳥': 3309, '驳': 3310, '辖': 3311, '苛': 3312, '赘': 3313, '敏': 3314, '飘': 3315, '筹': 3316, '激': 3317, '毫': 3318, '掀': 3319, '宇': 3320, '稿': 3321, '瘪': 3322, '誕': 3323, '✅': 3324, '赐': 3325, '恳': 3326, '岭': 3327, '白': 3328, '声': 3329, '村': 3330, '頁': 3331, '淚': 3332, '鲵': 3333, '恪': 3334, '错': 3335, '香': 3336, '靶': 3337, '骨': 3338, '雄': 3339, '萍': 3340, '昊': 3341, 'リ': 3342, '五': 3343, '挟': 3344, '鉛': 3345, '滨': 3346, '漱': 3347, '喷': 3348, '油': 3349, '状': 3350, '髓': 3351, '丰': 3352, '培': 3353, '裁': 3354, '繹': 3355, '蔑': 3356, '棉': 3357, '泼': 3358, '③': 3359, '掐': 3360, '喺': 3361, '克': 3362, '硬': 3363, '闪': 3364, '伺': 3365, '褪': 3366, '猬': 3367, '哭': 3368, '費': 3369, '薛': 3370, '淫': 3371, '矜': 3372, '丑': 3373, '清': 3374, '馋': 3375, '伍': 3376, '预': 3377, '駿': 3378, '丶': 3379, '其': 3380, '潸': 3381, '辗': 3382, '妮': 3383, '未': 3384, '疑': 3385, '盖': 3386, '刻': 3387, '悼': 3388, '◆': 3389, '评': 3390, '籍': 3391, '巨': 3392, '迅': 3393, '秒': 3394, '斩': 3395, '◇': 3396, '胀': 3397, '杀': 3398, '杭': 3399, '萨': 3400, '鑿': 3401, '該': 3402, '郁': 3403, '换': 3404, '距': 3405, '茨': 3406, '搁': 3407, '歹': 3408, '帕': 3409, '劉': 3410, '缔': 3411, '漢': 3412, '裡': 3413, '屡': 3414, '[': 3415, '毛': 3416, '誉': 3417, '涯': 3418, '儿': 3419, '躯': 3420, '驶': 3421, '荼': 3422, '啫': 3423, '彤': 3424, '烤': 3425, '收': 3426, '瓜': 3427, '侈': 3428, '斗': 3429, '里': 3430, '辩': 3431, '熙': 3432, '采': 3433, '忧': 3434, '穴': 3435, '符': 3436, '免': 3437, '握': 3438, '請': 3439, '鸠': 3440, '慈': 3441, '廈': 3442, '抬': 3443, '嚴': 3444, '身': 3445, '虔': 3446, '然': 3447, '斋': 3448, '控': 3449, '患': 3450, '飛': 3451, '赃': 3452, '撵': 3453, '燥': 3454, '舜': 3455, '國': 3456, '膝': 3457, '羅': 3458, '葱': 3459, '汀': 3460, '乖': 3461, '蛟': 3462, '露': 3463, '梆': 3464, '麽': 3465, '医': 3466, '條': 3467, '板': 3468, '割': 3469, '祖': 3470, '钢': 3471, '渺': 3472, '點': 3473, '惰': 3474, '戏': 3475, '具': 3476, '延': 3477, '刹': 3478, '塘': 3479, '铅': 3480, '诊': 3481, '凝': 3482, '綸': 3483, '☆': 3484, '壶': 3485, '計': 3486, '锋': 3487, '在': 3488, '颤': 3489, '伯': 3490, '固': 3491, '①': 3492, '游': 3493, '囚': 3494, '帼': 3495, '每': 3496, '亮': 3497, '蚊': 3498, '而': 3499, 'Q': 3500, '奢': 3501, '赠': 3502, '檔': 3503, '含': 3504, '继': 3505, '蛙': 3506, '顷': 3507, '艰': 3508, '撮': 3509, '`': 3510, '怕': 3511, '夺': 3512, '咳': 3513, '認': 3514, '隐': 3515, '⒈': 3516, '②': 3517, '蜃': 3518, '衬': 3519, '喬': 3520, '牲': 3521, '淇': 3522, '私': 3523, '哲': 3524, '雙': 3525, '痪': 3526, '嵘': 3527, '晕': 3528, '撒': 3529, '莉': 3530, '霍': 3531, '園': 3532, '摧': 3533, '➎': 3534, '艱': 3535, '🍀': 3536, '姆': 3537, '谍': 3538, '军': 3539, '越': 3540, '撰': 3541, '双': 3542, '唯': 3543, '嘻': 3544, '狗': 3545, '襄': 3546, ']': 3547, '脚': 3548, '貴': 3549, '湊': 3550, '懊': 3551, '斜': 3552, ',': 3553, '智': 3554, '蠢': 3555, '幅': 3556, '惨': 3557, '俺': 3558, '膀': 3559, '年': 3560, '震': 3561, '禁': 3562, '桌': 3563, '⋯': 3564, '厂': 3565, 'と': 3566, '翁': 3567, '瓯': 3568, '花': 3569, '詞': 3570, 'j': 3571, '战': 3572, '魇': 3573, '舒': 3574, '雹': 3575, '主': 3576, '鄉': 3577, '❀': 3578, '惹': 3579, '扰': 3580, '棍': 3581, '啥': 3582, '柿': 3583, '坠': 3584, '译': 3585, '泓': 3586, '否': 3587, '粒': 3588, '酝': 3589, '敗': 3590, '猿': 3591, '跃': 3592, '泉': 3593, '饕': 3594, '狮': 3595, '浪': 3596, '背': 3597, '至': 3598, '罂': 3599, '岚': 3600, '骑': 3601, '苏': 3602, '测': 3603, '仔': 3604, '>': 3605, '}': 3606, '毅': 3607, '突': 3608, '数': 3609, '齐': 3610, 'n': 3611, '丙': 3612, '敢': 3613, '掠': 3614, '犀': 3615, '码': 3616, '盒': 3617, '雜': 3618, '析': 3619, '乔': 3620, '🐒': 3621, '蒜': 3622, '♪': 3623, '架': 3624, '脐': 3625, '倩': 3626, '刘': 3627, '馄': 3628, '扳': 3629, '销': 3630, '彈': 3631, '滚': 3632, ']': 3633, '豌': 3634, '規': 3635, '羡': 3636, '佣': 3637, '讶': 3638, '代': 3639, '裳': 3640, '疤': 3641, '哪': 3642, '何': 3643, '聋': 3644, '绩': 3645, '發': 3646, '振': 3647, '鎮': 3648, '户': 3649, '亟': 3650, '虾': 3651, '沦': 3652, '泛': 3653, '淑': 3654, '寰': 3655, '黛': 3656, '溫': 3657, '粽': 3658, '溢': 3659, '蠻': 3660, '廿': 3661, '類': 3662, '椎': 3663, '扼': 3664, '😱': 3665, 'Z': 3666, '麦': 3667, '西': 3668, '卫': 3669, '瞻': 3670, '舵': 3671, '2': 3672, '富': 3673, '暹': 3674, '道': 3675, '渣': 3676, '查': 3677, '命': 3678, '噗': 3679, '令': 3680, '请': 3681, '腾': 3682, '决': 3683, '搡': 3684, '帶': 3685, '娉': 3686, '膏': 3687, '展': 3688, '累': 3689, '眉': 3690, '壁': 3691, '剎': 3692, '睾': 3693, '很': 3694, '八': 3695, '蟒': 3696, '茶': 3697, '朩': 3698, '銳': 3699, '描': 3700, '快': 3701, '嫂': 3702, '厚': 3703, '④': 3704, '≫': 3705, '陵': 3706, '签': 3707, '诬': 3708, '由': 3709, '马': 3710, '昂': 3711, '溪': 3712, '石': 3713, '暂': 3714, 's': 3715, '橡': 3716, '运': 3717, '漫': 3718, '刮': 3719, '呗': 3720, '綦': 3721, '勘': 3722, '亩': 3723, '布': 3724, '盈': 3725, '谛': 3726, '嗽': 3727, '罗': 3728, '宝': 3729, '痺': 3730, '漂': 3731, 'Y': 3732, '凉': 3733, '胆': 3734, '․': 3735, '婉': 3736, '艇': 3737, '鳗': 3738, '幹': 3739, '碧': 3740, '們': 3741, '催': 3742, '´': 3743, '讹': 3744, '隣': 3745, 'T': 3746, '骼': 3747, '颁': 3748, '罄': 3749, '木': 3750, '慢': 3751, '腫': 3752, '度': 3753, '恐': 3754, '百': 3755, '鹏': 3756, 'u': 3757, '往': 3758, ':': 3759, '模': 3760, '魔': 3761, '十': 3762, '郎': 3763, '讽': 3764, '婀': 3765, '揭': 3766, '耽': 3767, '栏': 3768, '绣': 3769, '頻': 3770, '拥': 3771, '層': 3772, '面': 3773, '酱': 3774, '😲': 3775, '書': 3776, '睽': 3777, '偷': 3778, '兔': 3779, '叛': 3780, '肯': 3781, '衫': 3782, '集': 3783, '络': 3784, '类': 3785, '翰': 3786, '磊': 3787, '牡': 3788, '氯': 3789, '特': 3790, '标': 3791, 'W': 3792, '妨': 3793, '效': 3794, '冀': 3795, '召': 3796, '政': 3797, '囧': 3798, '惜': 3799, '讪': 3800, '磨': 3801, '深': 3802, '璧': 3803, '犹': 3804, '瘤': 3805, '餐': 3806, '挽': 3807, '吉': 3808, '廷': 3809, '呲': 3810, '訊': 3811, '酗': 3812, '佬': 3813, '酶': 3814, '轨': 3815, '型': 3816, '偕': 3817, '诵': 3818, '漯': 3819, '似': 3820, '嗦': 3821, '乃': 3822, '梅': 3823, '⑧': 3824, '靖': 3825, '票': 3826, '滿': 3827, '色': 3828, '址': 3829, 'r': 3830, '屑': 3831, '衣': 3832, '%': 3833, '咋': 3834, '棚': 3835, '_': 3836, '帅': 3837, '娑': 3838, '窕': 3839, '拜': 3840, '酵': 3841, '埔': 3842, '茅': 3843, '他': 3844, '見': 3845, '操': 3846, '等': 3847, '境': 3848, '叉': 3849, '遭': 3850, '札': 3851, '来': 3852, '水': 3853, '鄭': 3854, '历': 3855, '劫': 3856, '署': 3857, '孙': 3858, '红': 3859, '养': 3860, '壳': 3861, '艳': 3862, '捣': 3863, '饶': 3864, '恤': 3865, '醋': 3866, '憐': 3867, '植': 3868, '翱': 3869, '辅': 3870, '蛋': 3871, '鄂': 3872, '媳': 3873, '泣': 3874, '替': 3875, '猎': 3876, '憔': 3877, '晋': 3878, '韌': 3879, '统': 3880, '雍': 3881, '翡': 3882, '偶': 3883, '弥': 3884, '兩': 3885, '戀': 3886, '嗎': 3887, '≦': 3888, '烫': 3889, '😢': 3890, '聪': 3891, '﹏': 3892, '佟': 3893, '厉': 3894, '甸': 3895, '普': 3896, '轴': 3897, '寅': 3898, '优': 3899, '坑': 3900, '哼': 3901, '拆': 3902, '验': 3903, '内': 3904, 'U': 3905, '婵': 3906, '搭': 3907, '時': 3908, 'D': 3909, '颜': 3910, '繼': 3911, '坞': 3912, '斷': 3913, '咱': 3914, '諒': 3915, '郸': 3916, '康': 3917, '六': 3918, '娶': 3919, '獸': 3920, '巩': 3921, '睁': 3922, '奇': 3923, '汁': 3924, '拿': 3925, '黔': 3926, '捍': 3927, '溶': 3928, '瓢': 3929, '阁': 3930, '阂': 3931, '蟑': 3932, '瑋': 3933, '谣': 3934, '去': 3935, '悸': 3936, '麥': 3937, '創': 3938, '袋': 3939, '立': 3940, '册': 3941, '榴': 3942, '荏': 3943, '乱': 3944, '常': 3945, '淹': 3946, '育': 3947, '藤': 3948, '汰': 3949, '缢': 3950, '倒': 3951, '偏': 3952, '瘫': 3953, '凡': 3954, ';': 3955, '辐': 3956, '诱': 3957, '忙': 3958, '熟': 3959, '零': 3960, '荒': 3961, '庵': 3962, '江': 3963, '逍': 3964, '煽': 3965, '佩': 3966, '凸': 3967, '泊': 3968, '巷': 3969, '凯': 3970, '丞': 3971, '學': 3972, '騰': 3973, '碾': 3974, '萱': 3975, '钓': 3976, '勿': 3977, '煤': 3978, '扈': 3979, '灰': 3980, '烹': 3981, '磐': 3982, '冻': 3983, '围': 3984, '筝': 3985, '嫡': 3986, '耶': 3987, '矫': 3988, '鼻': 3989, '粉': 3990, '踹': 3991, '捡': 3992, '赚': 3993, '绍': 3994, '泪': 3995, '善': 3996, '弟': 3997, '萃': 3998, '诶': 3999, '試': 4000, '垂': 4001, '庭': 4002, '费': 4003, '乡': 4004, '礁': 4005, '申': 4006, '呜': 4007, '坷': 4008, '坝': 4009, '飒': 4010, '证': 4011, '扮': 4012, '痿': 4013, '阐': 4014, '庚': 4015, '1': 4016, '问': 4017, '5': 4018, '俱': 4019, '祺': 4020, '嫩': 4021, '礼': 4022, '琶': 4023, '疫': 4024, '针': 4025, '盡': 4026, '汇': 4027, '暧': 4028, '乐': 4029, '尾': 4030, '德': 4031, '膜': 4032, '湖': 4033, '缪': 4034, '极': 4035, '☎': 4036, '獒': 4037, '恶': 4038, '熹': 4039, '谠': 4040, '凄': 4041, '买': 4042, '午': 4043, '狞': 4044, '伸': 4045, '贪': 4046, '兵': 4047, '唁': 4048, '察': 4049, '燕': 4050, '浏': 4051, '剛': 4052, '龟': 4053, '浅': 4054, '橇': 4055, '艹': 4056, '薄': 4057, '扛': 4058, '绛': 4059, '委': 4060, '勢': 4061, '憾': 4062, '污': 4063, '螃': 4064, '郊': 4065, '"': 4066, '官': 4067, '虽': 4068, '啤': 4069, '诲': 4070, '蓄': 4071, '喘': 4072, '软': 4073, '排': 4074, '遠': 4075, '彭': 4076, '倾': 4077, '授': 4078, '眸': 4079, 'p': 4080, '遮': 4081, '恒': 4082, '师': 4083, '崇': 4084, '般': 4085, '琐': 4086, '责': 4087, '宗': 4088, '呆': 4089, '鳌': 4090, '处': 4091, '攻': 4092, '钥': 4093, '松': 4094, '醺': 4095, '鼎': 4096, '储': 4097, '陌': 4098, '咲': 4099, '3': 4100, '幂': 4101, '恣': 4102, '谓': 4103, '過': 4104, '緊': 4105, '咨': 4106, '宵': 4107, '抖': 4108, '鑑': 4109, '到': 4110, '盔': 4111, '望': 4112, '浑': 4113, '给': 4114, '剪': 4115, '妙': 4116, '僵': 4117, '饱': 4118, '岳': 4119, '髮': 4120, '怺': 4121, '工': 4122, '鸦': 4123, '渐': 4124, '驾': 4125, '娛': 4126, '葛': 4127, '風': 4128, '愈': 4129, '糊': 4130, '週': 4131, '洲': 4132, '颂': 4133, '曲': 4134, '助': 4135, '懂': 4136, '王': 4137, '妻': 4138, '俚': 4139, '肋': 4140, '潼': 4141, '氓': 4142, '袭': 4143, '&': 4144, '🇨': 4145, '草': 4146, '広': 4147, '子': 4148, '🌟': 4149, '呈': 4150, '景': 4151, '二': 4152, '捕': 4153, '绒': 4154, '忍': 4155, '迎': 4156, '礴': 4157, '瘾': 4158, '序': 4159, '7': 4160, '胧': 4161, '锢': 4162, 'f': 4163, '掇': 4164, '咻': 4165, '吝': 4166, '寶': 4167, '氏': 4168, '窝': 4169, '阵': 4170, '坚': 4171, '疲': 4172, '兼': 4173, '皆': 4174, '攒': 4175, '酣': 4176, '仪': 4177, '變': 4178, '桂': 4179, '兆': 4180, '昶': 4181, '装': 4182, '尖': 4183, 'L': 4184, '瓶': 4185, '稀': 4186, '诡': 4187, '妒': 4188, '裂': 4189, '弦': 4190, '翔': 4191, '葬': 4192, '馈': 4193, '扉': 4194, '囔': 4195, '喧': 4196, '盛': 4197, '笛': 4198, '態': 4199, '町': 4200, '餮': 4201, '钛': 4202, '🍁': 4203, '灣': 4204, '鬥': 4205, '嵯': 4206, '粥': 4207, '慵': 4208, '如': 4209, '葆': 4210, '記': 4211, '足': 4212, '约': 4213, '屌': 4214, '移': 4215, '门': 4216, '詹': 4217, '價': 4218, '闽': 4219, '屆': 4220, '碱': 4221, '袖': 4222, '長': 4223, '画': 4224, '余': 4225, '琢': 4226, '帐': 4227, '嚎': 4228, '留': 4229, '跚': 4230, '床': 4231, '刚': 4232, '哒': 4233, '鸽': 4234, '知': 4235, '块': 4236, '杉': 4237, '尼': 4238, '’': 4239, '敛': 4240, '涨': 4241, '橫': 4242, '思': 4243, '媒': 4244, '朝': 4245, '輝': 4246, '例': 4247, '押': 4248, '槽': 4249, '挑': 4250, '狭': 4251, '間': 4252, '前': 4253, '考': 4254, '娱': 4255, '械': 4256, '✈': 4257, '嗓': 4258, '斥': 4259, '【': 4260, '紐': 4261, '罪': 4262, '皈': 4263, '长': 4264, '仇': 4265, '捭': 4266, '猜': 4267, 'm': 4268, '罩': 4269, '逾': 4270, '宜': 4271, '光': 4272, '后': 4273, '撑': 4274, '剖': 4275, '盆': 4276, '️': 4277, '峭': 4278, '牵': 4279, '砍': 4280, '沂': 4281, 'れ': 4282, '樊': 4283, '贺': 4284, '略': 4285, '🇳': 4286, '—': 4287, '吓': 4288, '拣': 4289, '亵': 4290, '静': 4291, '谴': 4292, '鬧': 4293, '論': 4294, '耿': 4295, '护': 4296, '苦': 4297, '艾': 4298, '∠': 4299, '猝': 4300, 'P': 4301, '黄': 4302, '君': 4303, 'こ': 4304, '弛': 4305, '恙': 4306, '笼': 4307, '柬': 4308, '猛': 4309, '酯': 4310, '划': 4311, '肖': 4312, '撬': 4313, '郫': 4314, '~': 4315, '缸': 4316, '種': 4317, '崭': 4318, '毗': 4319, '薯': 4320, '粪': 4321, '俭': 4322, '篷': 4323, '萤': 4324, '標': 4325, '糖': 4326, '裆': 4327, '熬': 4328, '一': 4329, '库': 4330, '▲': 4331, '冥': 4332, '锁': 4333, '俘': 4334, '抢': 4335, '征': 4336, '玫': 4337, '厲': 4338, '芯': 4339, '众': 4340, '吗': 4341, '歧': 4342, '楊': 4343, '篱': 4344, '夹': 4345, '悴': 4346, ';': 4347, '菁': 4348, '示': 4349, '衍': 4350, '抽': 4351, '纯': 4352, '您': 4353, '答': 4354, '法': 4355, '>': 4356, '窜': 4357, '坎': 4358, '柠': 4359, 'ら': 4360, '給': 4361, '♥': 4362, '噪': 4363, '⚫': 4364, '枕': 4365, '榆': 4366, '樂': 4367, '气': 4368, '末': 4369, '這': 4370, '矿': 4371, '員': 4372, '蚤': 4373, '梯': 4374, '通': 4375, '脆': 4376, '聲': 4377, '0': 4378, '弹': 4379, '怖': 4380, '俨': 4381, '域': 4382, '冉': 4383, '痹': 4384, '府': 4385, '啡': 4386, '绽': 4387, '頒': 4388, '辦': 4389, '发': 4390, '碌': 4391, '社': 4392, '🚬': 4393, '渗': 4394, '珠': 4395, '兄': 4396, '鸿': 4397, '哺': 4398, '俯': 4399, '妇': 4400, '蒙': 4401, '幢': 4402, '叽': 4403, '幡': 4404, '鎖': 4405, '安': 4406, '作': 4407, '情': 4408, '': 4409}
\ No newline at end of file
+{'寒': 0, '煲': 1, '升': 2, '耳': 3, '孜': 4, '矶': 5, '惑': 6, '谩': 7, '奉': 8, '坛': 9, '嘗': 10, '索': 11, '所': 12, '藏': 13, '阜': 14, '孟': 15, '久': 16, ')': 17, '散': 18, '真': 19, '肇': 20, '保': 21, '蜜': 22, '丁': 23, '玉': 24, '伏': 25, '次': 26, '隽': 27, '囯': 28, '浊': 29, '沥': 30, '豪': 31, '果': 32, '卢': 33, '夏': 34, '朦': 35, '墓': 36, '圖': 37, '躬': 38, '铃': 39, '浇': 40, '反': 41, '瑩': 42, '慕': 43, '練': 44, '抨': 45, '喃': 46, '滑': 47, '亇': 48, '紅': 49, '拙': 50, '侍': 51, '卤': 52, '摄': 53, '〗': 54, '谤': 55, '跟': 56, '⒑': 57, '备': 58, '躺': 59, '稳': 60, '九': 61, '歉': 62, '味': 63, '莎': 64, '黍': 65, '涎': 66, '想': 67, '鳍': 68, '籠': 69, '臨': 70, '纶': 71, '性': 72, '推': 73, '殉': 74, '平': 75, '倍': 76, '洽': 77, '浸': 78, '裔': 79, '鹤': 80, '破': 81, '軟': 82, '尚': 83, '肃': 84, '凱': 85, '呼': 86, '踊': 87, '编': 88, '輯': 89, '病': 90, '勤': 91, '婴': 92, '枯': 93, '邦': 94, '隨': 95, '級': 96, '〝': 97, '奸': 98, '愧': 99, '团': 100, '济': 101, '董': 102, '艺': 103, '赢': 104, '泄': 105, '蜂': 106, '东': 107, '荆': 108, '汶': 109, '痰': 110, '溅': 111, '湾': 112, '咚': 113, '異': 114, '省': 115, '互': 116, '亂': 117, '耙': 118, '棒': 119, '判': 120, '绘': 121, '呐': 122, '掷': 123, '匿': 124, '韵': 125, '低': 126, '演': 127, '做': 128, '榕': 129, '郡': 130, '明': 131, '吞': 132, '7': 133, '侣': 134, '曼': 135, '炭': 136, '淘': 137, '當': 138, '寨': 139, '餘': 140, '力': 141, '覽': 142, '坏': 143, '肩': 144, '宿': 145, '舟': 146, '嘉': 147, '妹': 148, '各': 149, '著': 150, '归': 151, '遗': 152, '表': 153, '勋': 154, '》': 155, '拦': 156, '瞬': 157, '運': 158, '挖': 159, '谊': 160, '乒': 161, '忽': 162, 'お': 163, '伞': 164, '粤': 165, '曾': 166, '糍': 167, '墨': 168, '设': 169, '滞': 170, '踩': 171, '沛': 172, '盗': 173, '尢': 174, '慌': 175, 'w': 176, '币': 177, 'O': 178, '份': 179, '晨': 180, '菌': 181, '药': 182, '颅': 183, '碍': 184, '桐': 185, '驱': 186, '险': 187, '焖': 188, '仕': 189, '牒': 190, '功': 191, '万': 192, '恼': 193, '囤': 194, '狐': 195, '诸': 196, '憨': 197, '戈': 198, '雀': 199, '筆': 200, '咆': 201, '郅': 202, '残': 203, '刷': 204, '茄': 205, '垄': 206, '眾': 207, '偿': 208, '求': 209, '0': 210, 'g': 211, '荩': 212, '帳': 213, '襲': 214, '庞': 215, '逅': 216, '杆': 217, '埃': 218, '俊': 219, '缺': 220, '爭': 221, '坨': 222, '秃': 223, '遐': 224, '是': 225, '玮': 226, '邀': 227, '监': 228, '呢': 229, '曦': 230, '紹': 231, '惋': 232, '揣': 233, '铺': 234, '篇': 235, '獨': 236, '哀': 237, '趣': 238, '咩': 239, '澳': 240, '坪': 241, '冰': 242, '婶': 243, '烟': 244, '像': 245, '👍': 246, '庸': 247, '舞': 248, '父': 249, '\ue415': 250, '貨': 251, '稠': 252, '锣': 253, '憶': 254, '鹅': 255, '苕': 256, '宋': 257, '机': 258, '.': 259, '危': 260, '鳝': 261, '御': 262, '隶': 263, '锥': 264, '失': 265, '第': 266, '座': 267, '★': 268, '宥': 269, '鞭': 270, '才': 271, '弃': 272, '憬': 273, '帝': 274, '\ue021': 275, '睡': 276, '凿': 277, '瀟': 278, '帥': 279, '渢': 280, '说': 281, '疚': 282, '墀': 283, '榨': 284, '哑': 285, '吼': 286, '意': 287, '드': 288, '–': 289, '耍': 290, '劝': 291, '話': 292, '親': 293, '桩': 294, "'": 295, '酚': 296, '干': 297, '国': 298, '歼': 299, '蕴': 300, '酿': 301, '叠': 302, '派': 303, '嬛': 304, '韩': 305, '宫': 306, '仁': 307, '臭': 308, '牌': 309, '說': 310, '棕': 311, '舍': 312, '伊': 313, '卿': 314, '抱': 315, '蔚': 316, '遛': 317, '/': 318, '腰': 319, '違': 320, '纱': 321, '溯': 322, '\u2029': 323, '怯': 324, '哎': 325, '曝': 326, '终': 327, '丨': 328, '逺': 329, '哩': 330, '警': 331, '捷': 332, '宙': 333, '峻': 334, '原': 335, '觀': 336, '蓋': 337, '竹': 338, '戴': 339, '聽': 340, '桓': 341, '沫': 342, '忐': 343, '杰': 344, '执': 345, '利': 346, '帽': 347, '嗷': 348, '枳': 349, '沪': 350, '率': 351, '雾': 352, '嚣': 353, '啸': 354, '乎': 355, '饮': 356, '独': 357, '添': 358, '走': 359, '涉': 360, '怪': 361, '羔': 362, '巾': 363, '盼': 364, '繁': 365, '呦': 366, '舌': 367, '斐': 368, '使': 369, '坐': 370, '依': 371, '啊': 372, '电': 373, '幺': 374, '沿': 375, '內': 376, '汪': 377, '称': 378, '妈': 379, '宏': 380, '柜': 381, '盲': 382, '蹒': 383, '開': 384, '稼': 385, '诈': 386, '瞰': 387, 'ㅋ': 388, '∩': 389, '嫉': 390, '泮': 391, '起': 392, '资': 393, '仍': 394, '憎': 395, '美': 396, '。': 397, '傈': 398, '裴': 399, '棺': 400, '弱': 401, '匪': 402, '箱': 403, '相': 404, '更': 405, '没': 406, '聚': 407, '跨': 408, '訴': 409, '龙': 410, '施': 411, '厌': 412, '梓': 413, '莺': 414, '阶': 415, '棋': 416, '专': 417, '挤': 418, '禮': 419, 'る': 420, '\ue10c': 421, '巡': 422, '遥': 423, '日': 424, '岗': 425, '勝': 426, '殡': 427, '痴': 428, '措': 429, '狸': 430, '#': 431, '歷': 432, '趁': 433, '殆': 434, '只': 435, '鼓': 436, '亞': 437, ' ': 438, '流': 439, '悲': 440, '噬': 441, '裤': 442, '拐': 443, '😠': 444, '狂': 445, '山': 446, '镇': 447, '稍': 448, '染': 449, '-': 450, '瑾': 451, '账': 452, 'l': 453, '誌': 454, '赡': 455, '지': 456, 'キ': 457, '谅': 458, '聘': 459, '绎': 460, '词': 461, '血': 462, '墙': 463, '℃': 464, '嫖': 465, '尺': 466, '活': 467, '脍': 468, '担': 469, '男': 470, '掉': 471, '咒': 472, '吸': 473, '痞': 474, '根': 475, '晏': 476, '仨': 477, '急': 478, '怠': 479, '履': 480, '洼': 481, '唾': 482, '懷': 483, '妆': 484, '单': 485, '肾': 486, '奧': 487, '薪': 488, '皂': 489, '参': 490, '朔': 491, '甲': 492, '钉': 493, '雖': 494, '希': 495, '冬': 496, '摩': 497, '谎': 498, '铂': 499, '蹄': 500, '壮': 501, '纺': 502, '岛': 503, '伴': 504, '贱': 505, '柯': 506, '拒': 507, '鲑': 508, '童': 509, '怡': 510, '績': 511, 'で': 512, '邻': 513, '班': 514, '藉': 515, '锐': 516, '鄙': 517, '蛰': 518, '告': 519, '⒒': 520, '浙': 521, '近': 522, '屈': 523, '喝': 524, '呛': 525, '痛': 526, '甚': 527, '铜': 528, '巅': 529, '盾': 530, '爵': 531, '段': 532, '貓': 533, '紀': 534, '臂': 535, '載': 536, '扁': 537, '😜': 538, '焚': 539, '厕': 540, '︰': 541, '谭': 542, '粱': 543, '殒': 544, '睐': 545, '夫': 546, '淞': 547, '骚': 548, '凳': 549, '洪': 550, '碎': 551, 'C': 552, '全': 553, '以': 554, '霉': 555, '放': 556, '觅': 557, '磕': 558, '励': 559, '搜': 560, '膊': 561, '畫': 562, '熊': 563, '罐': 564, '闸': 565, '歆': 566, '虹': 567, '估': 568, '落': 569, '經': 570, '拼': 571, '挺': 572, '糙': 573, '鉴': 574, '豁': 575, '捆': 576, '比': 577, '濛': 578, '初': 579, '属': 580, '寫': 581, '候': 582, '參': 583, '碳': 584, '哟': 585, '姜': 586, '垢': 587, '券': 588, '慑': 589, '点': 590, '己': 591, '霞': 592, '纸': 593, '哥': 594, '赎': 595, '妞': 596, '勲': 597, '刁': 598, '胃': 599, '韭': 600, '註': 601, '詐': 602, '燮': 603, '群': 604, '庙': 605, '來': 606, '仗': 607, '9': 608, '探': 609, '蝶': 610, '傅': 611, '徽': 612, '缤': 613, '^': 614, '堡': 615, '赏': 616, '蛆': 617, '烩': 618, '準': 619, '朵': 620, '吃': 621, '嘴': 622, '典': 623, '端': 624, '連': 625, '趟': 626, '欲': 627, '『': 628, '馒': 629, '神': 630, '拯': 631, '芸': 632, '防': 633, '竣': 634, '时': 635, '輕': 636, '却': 637, '泳': 638, '陡': 639, '冒': 640, '💖': 641, '托': 642, '鹫': 643, '姊': 644, '嘲': 645, '枸': 646, '总': 647, '绿': 648, '症': 649, '练': 650, '耕': 651, '野': 652, '强': 653, '匆': 654, '🙏': 655, '吶': 656, 'o': 657, '包': 658, '幣': 659, '央': 660, '惮': 661, '險': 662, '爬': 663, '猪': 664, '邯': 665, '妖': 666, '挣': 667, '世': 668, '登': 669, '女': 670, '佐': 671, '笙': 672, '×': 673, '你': 674, '肆': 675, '池': 676, '鳄': 677, '蒂': 678, '腕': 679, '囡': 680, '娅': 681, '°': 682, '徇': 683, '沱': 684, '恢': 685, '“': 686, 'I': 687, '恭': 688, '缝': 689, '肮': 690, '就': 691, '眶': 692, '席': 693, '據': 694, '剂': 695, '哄': 696, '谈': 697, '岔': 698, '瞒': 699, '坦': 700, '忑': 701, '赈': 702, '雷': 703, '辰': 704, 'e': 705, '荥': 706, '闯': 707, '純': 708, '揽': 709, '林': 710, '巴': 711, '逞': 712, '串': 713, '璨': 714, '聊': 715, '偌': 716, '斑': 717, '暄': 718, '计': 719, '会': 720, '琪': 721, '⒊': 722, '吹': 723, '碟': 724, '胚': 725, '陣': 726, '饭': 727, '🔴': 728, '友': 729, '招': 730, '扯': 731, '武': 732, '錄': 733, '後': 734, '敖': 735, '审': 736, '鸟': 737, '筑': 738, '稽': 739, '吵': 740, '制': 741, '俄': 742, '逮': 743, '毙': 744, '摘': 745, '巫': 746, '姣': 747, '從': 748, '瑰': 749, '闻': 750, '队': 751, '汲': 752, '听': 753, '邓': 754, '逆': 755, '隔': 756, '袒': 757, '芮': 758, '肺': 759, '汗': 760, '权': 761, '注': 762, '华': 763, '技': 764, '肓': 765, '”': 766, '愚': 767, '奠': 768, '呃': 769, '壹': 770, '搽': 771, '榜': 772, '莫': 773, '邮': 774, '狱': 775, '镑': 776, '雁': 777, '殊': 778, '貌': 779, '两': 780, '璃': 781, '关': 782, '吻': 783, '悉': 784, '惊': 785, '靴': 786, '手': 787, '姨': 788, '朴': 789, '修': 790, '谄': 791, '必': 792, '熱': 793, '煞': 794, '煜': 795, '廉': 796, '炅': 797, '照': 798, '睿': 799, 'う': 800, '呀': 801, '甜': 802, '珞': 803, '攬': 804, '简': 805, '牧': 806, '漳': 807, '狼': 808, '契': 809, '焉': 810, '糨': 811, '賤': 812, '庄': 813, '於': 814, '\u3000': 815, '慨': 816, '吧': 817, '交': 818, '赴': 819, '薰': 820, '磋': 821, '囗': 822, '诺': 823, '龜': 824, '孀': 825, '绝': 826, '旧': 827, '擀': 828, '録': 829, '秉': 830, '淋': 831, '料': 832, '碗': 833, '七': 834, '降': 835, '乾': 836, '叨': 837, '確': 838, '韧': 839, '廳': 840, '胖': 841, '階': 842, '肿': 843, '断': 844, '汹': 845, '伪': 846, '且': 847, '烧': 848, '銀': 849, '蚌': 850, '翼': 851, '纳': 852, '斌': 853, '侃': 854, '规': 855, '款': 856, '路': 857, '拧': 858, '别': 859, '协': 860, '矮': 861, '悬': 862, '場': 863, '•': 864, '寺': 865, '昨': 866, '尘': 867, '藕': 868, '能': 869, '講': 870, '蛮': 871, '곤': 872, '澡': 873, '炫': 874, '写': 875, '够': 876, '胞': 877, '藩': 878, '赦': 879, '鈞': 880, '〖': 881, '迁': 882, '灿': 883, '桦': 884, '瞎': 885, '戲': 886, '迦': 887, '楷': 888, '玄': 889, '哮': 890, '古': 891, 'N': 892, '配': 893, '弄': 894, '太': 895, '都': 896, '盯': 897, '邹': 898, '隻': 899, '🎯': 900, '靠': 901, '谱': 902, '任': 903, '应': 904, '約': 905, '攸': 906, '恨': 907, '邵': 908, '尿': 909, '岖': 910, '煮': 911, '柄': 912, '珀': 913, '还': 914, '削': 915, '輸': 916, '诿': 917, '秩': 918, '\xa0': 919, '喽': 920, '吳': 921, '説': 922, 'E': 923, '勃': 924, '紫': 925, '补': 926, '痨': 927, '卷': 928, '巢': 929, '拢': 930, '對': 931, '浮': 932, '期': 933, '兰': 934, '勁': 935, '死': 936, '传': 937, '備': 938, '篡': 939, '瓤': 940, '醇': 941, '錢': 942, '強': 943, '狰': 944, '蛀': 945, '健': 946, '键': 947, '圳': 948, '丧': 949, '拳': 950, '沈': 951, '捉': 952, '浆': 953, '金': 954, '品': 955, '悚': 956, '佈': 957, '愫': 958, '株': 959, '陀': 960, '廣': 961, '斤': 962, '烛': 963, '连': 964, '癌': 965, '晤': 966, '诛': 967, '倫': 968, '→': 969, '梧': 970, '瀬': 971, '蜗': 972, '刨': 973, '叮': 974, '戰': 975, '界': 976, '婷': 977, '拷': 978, '飙': 979, '绷': 980, '开': 981, '還': 982, '蚝': 983, '暗': 984, '焦': 985, '右': 986, '<': 987, '脑': 988, '攀': 989, '蹋': 990, '源': 991, '热': 992, '引': 993, '圓': 994, '咂': 995, '乌': 996, '塚': 997, '银': 998, '館': 999, '范': 1000, '乍': 1001, '均': 1002, '圣': 1003, '舱': 1004, '凑': 1005, '青': 1006, '寂': 1007, '馅': 1008, '惫': 1009, '😂': 1010, '曰': 1011, '戮': 1012, '砸': 1013, '逐': 1014, '⚠': 1015, '奚': 1016, '榄': 1017, '屉': 1018, '炮': 1019, '統': 1020, '樟': 1021, '谙': 1022, '肉': 1023, '蝴': 1024, '4': 1025, '栽': 1026, '葡': 1027, '诞': 1028, '嚏': 1029, '无': 1030, '沢': 1031, '夸': 1032, '娆': 1033, '限': 1034, '跷': 1035, '样': 1036, '势': 1037, '虫': 1038, '频': 1039, '裙': 1040, '糗': 1041, '涵': 1042, '禽': 1043, '終': 1044, '搏': 1045, '勇': 1046, '秦': 1047, 'θ': 1048, '#': 1049, '&': 1050, '抠': 1051, '磅': 1052, '垃': 1053, '耀': 1054, '律': 1055, '适': 1056, '究': 1057, '杂': 1058, '堵': 1059, '迷': 1060, '钻': 1061, '缆': 1062, '职': 1063, '共': 1064, '濃': 1065, '滋': 1066, '張': 1067, '剔': 1068, '层': 1069, '媽': 1070, '恕': 1071, '细': 1072, '體': 1073, '麒': 1074, '刊': 1075, '俏': 1076, '傻': 1077, '莱': 1078, '策': 1079, '浓': 1080, '离': 1081, '鸭': 1082, 'c': 1083, '釜': 1084, '蛩': 1085, '本': 1086, '龄': 1087, '忌': 1088, '载': 1089, '訪': 1090, '泥': 1091, '朽': 1092, '叶': 1093, '字': 1094, '盐': 1095, '争': 1096, '尹': 1097, '扣': 1098, '场': 1099, '螺': 1100, '文': 1101, '挨': 1102, '炎': 1103, '竿': 1104, '恃': 1105, '贡': 1106, '堰': 1107, '栖': 1108, '捏': 1109, '≪': 1110, '腊': 1111, '杖': 1112, '肚': 1113, '幾': 1114, '<': 1115, '饥': 1116, '醒': 1117, '掼': 1118, '束': 1119, '再': 1120, '叫': 1121, '湯': 1122, '扇': 1123, '緯': 1124, '亊': 1125, '撤': 1126, '5': 1127, '室': 1128, '離': 1129, '严': 1130, '压': 1131, '霖': 1132, '魅': 1133, '改': 1134, '樽': 1135, '腥': 1136, '歲': 1137, '谜': 1138, '優': 1139, '矩': 1140, '顏': 1141, '喔': 1142, '旁': 1143, '聂': 1144, '缓': 1145, '勾': 1146, '寄': 1147, '棠': 1148, '纹': 1149, '轿': 1150, '触': 1151, '先': 1152, '投': 1153, '⒍': 1154, '傑': 1155, '鹰': 1156, '趴': 1157, '霜': 1158, '酬': 1159, '⒔': 1160, '拎': 1161, '澜': 1162, '盎': 1163, '蚁': 1164, '南': 1165, '焱': 1166, '飏': 1167, '讯': 1168, '胡': 1169, '谦': 1170, '篪': 1171, '按': 1172, '恵': 1173, '辽': 1174, '寓': 1175, '祷': 1176, '峯': 1177, '档': 1178, '尸': 1179, '‘': 1180, '牛': 1181, '遨': 1182, '匣': 1183, '拭': 1184, '赶': 1185, '润': 1186, '捧': 1187, '薦': 1188, '桢': 1189, '踮': 1190, '祈': 1191, '洞': 1192, '疱': 1193, '杞': 1194, '侬': 1195, '则': 1196, '圭': 1197, '痔': 1198, '认': 1199, '泡': 1200, '宪': 1201, '抉': 1202, '衙': 1203, '欧': 1204, '擁': 1205, '哈': 1206, '砣': 1207, '膳': 1208, '科': 1209, '睬': 1210, '買': 1211, '藥': 1212, '缠': 1213, '永': 1214, '啲': 1215, '我': 1216, '捞': 1217, '杏': 1218, '敬': 1219, '持': 1220, '牺': 1221, '陂': 1222, '辛': 1223, '慧': 1224, '傳': 1225, '汽': 1226, '雉': 1227, '饪': 1228, '打': 1229, '分': 1230, '姑': 1231, '竟': 1232, '娜': 1233, '筋': 1234, '殴': 1235, '乳': 1236, '朋': 1237, '负': 1238, '靓': 1239, '潮': 1240, '织': 1241, '洋': 1242, '揉': 1243, '象': 1244, '齊': 1245, '顺': 1246, '漉': 1247, '⒉': 1248, '挡': 1249, '冧': 1250, '咔': 1251, '角': 1252, '网': 1253, '遍': 1254, '尤': 1255, '茉': 1256, '搀': 1257, '\u200a': 1258, '豚': 1259, '绑': 1260, '绵': 1261, '實': 1262, '骇': 1263, '滩': 1264, '彼': 1265, '桔': 1266, '槟': 1267, '哆': 1268, '头': 1269, '旭': 1270, '芳': 1271, '喉': 1272, '又': 1273, '脏': 1274, '几': 1275, '羽': 1276, '鑫': 1277, '沧': 1278, '「': 1279, '净': 1280, '驰': 1281, '帘': 1282, '企': 1283, '绯': 1284, '啪': 1285, '献': 1286, '掌': 1287, '赫': 1288, '癫': 1289, '诉': 1290, '承': 1291, '列': 1292, '緣': 1293, '复': 1294, '天': 1295, '丈': 1296, '元': 1297, '货': 1298, '辱': 1299, '糕': 1300, '咽': 1301, '厥': 1302, '地': 1303, '伶': 1304, '谨': 1305, '魄': 1306, '識': 1307, '孕': 1308, '負': 1309, '存': 1310, '⑥': 1311, '宁': 1312, '闺': 1313, '个': 1314, '虏': 1315, '暖': 1316, '冤': 1317, '母': 1318, '组': 1319, '燃': 1320, '憋': 1321, '厨': 1322, '咸': 1323, '贿': 1324, '捶': 1325, '租': 1326, '毒': 1327, '炳': 1328, '熔': 1329, '澄': 1330, '抑': 1331, '領': 1332, '惭': 1333, '满': 1334, '菇': 1335, '另': 1336, '旋': 1337, '柏': 1338, '些': 1339, '质': 1340, '撇': 1341, '恰': 1342, '臣': 1343, '丛': 1344, '沇': 1345, '远': 1346, '烂': 1347, '债': 1348, '批': 1349, '菊': 1350, '夜': 1351, '锻': 1352, '嚓': 1353, '傍': 1354, '邡': 1355, '晓': 1356, '岸': 1357, '爱': 1358, '毕': 1359, '漓': 1360, '锡': 1361, '⒕': 1362, '访': 1363, '豆': 1364, '沾': 1365, '牢': 1366, '惠': 1367, '豹': 1368, '念': 1369, '唤': 1370, '扭': 1371, '網': 1372, '爷': 1373, '錯': 1374, '旅': 1375, '休': 1376, '桶': 1377, '疼': 1378, '📢': 1379, '铁': 1380, '叙': 1381, '楼': 1382, '辟': 1383, '搞': 1384, 'て': 1385, '台': 1386, '炽': 1387, '侯': 1388, '霓': 1389, '粹': 1390, '卦': 1391, '煎': 1392, '枪': 1393, '高': 1394, '叟': 1395, '巧': 1396, '桥': 1397, '跪': 1398, '萝': 1399, '唇': 1400, '苑': 1401, '旗': 1402, '渊': 1403, '葩': 1404, '晾': 1405, '伦': 1406, '受': 1407, '椒': 1408, '姚': 1409, '梗': 1410, '尬': 1411, '局': 1412, '庝': 1413, '兲': 1414, '竞': 1415, '被': 1416, '雞': 1417, '覺': 1418, '攪': 1419, '惘': 1420, '丘': 1421, '闷': 1422, '擦': 1423, '沟': 1424, '皮': 1425, '炼': 1426, '礦': 1427, '叹': 1428, '检': 1429, '陈': 1430, '胎': 1431, '👏': 1432, '甘': 1433, '颍': 1434, '萬': 1435, '部': 1436, '楚': 1437, '隋': 1438, '燈': 1439, '客': 1440, '⒓': 1441, '襟': 1442, '悠': 1443, '葫': 1444, '着': 1445, '徹': 1446, '撅': 1447, '弘': 1448, '琅': 1449, '怨': 1450, '+': 1451, '披': 1452, '筠': 1453, '习': 1454, '停': 1455, '翻': 1456, '寿': 1457, '寝': 1458, '维': 1459, '漏': 1460, '程': 1461, '向': 1462, '=': 1463, '拘': 1464, '乙': 1465, '將': 1466, '姥': 1467, '柳': 1468, '冯': 1469, '搖': 1470, '吠': 1471, '上': 1472, '蹈': 1473, 'M': 1474, '倔': 1475, '痤': 1476, '腺': 1477, '须': 1478, '秤': 1479, '姿': 1480, '逛': 1481, 'S': 1482, '窈': 1483, '彰': 1484, '黎': 1485, '帷': 1486, '+': 1487, '县': 1488, '釧': 1489, '觊': 1490, '扒': 1491, '幼': 1492, '崖': 1493, '多': 1494, '峡': 1495, '动': 1496, '溃': 1497, '翠': 1498, '液': 1499, '抗': 1500, '拋': 1501, '管': 1502, 'K': 1503, '睛': 1504, '案': 1505, '宅': 1506, '鲲': 1507, '扬': 1508, '折': 1509, '珍': 1510, '幫': 1511, '届': 1512, '節': 1513, '嚷': 1514, '問': 1515, '虞': 1516, '校': 1517, '造': 1518, '憧': 1519, '退': 1520, '祎': 1521, '溜': 1522, '役': 1523, '逼': 1524, '➊': 1525, '語': 1526, '超': 1527, '辜': 1528, '4': 1529, '奋': 1530, '虚': 1531, '卑': 1532, '袁': 1533, '\ue00e': 1534, '嘅': 1535, '骸': 1536, 'サ': 1537, '僳': 1538, '芦': 1539, '股': 1540, '舰': 1541, '奕': 1542, '撞': 1543, '癢': 1544, '膨': 1545, '攫': 1546, '伤': 1547, '枭': 1548, '诅': 1549, '哨': 1550, '荡': 1551, '膛': 1552, '爸': 1553, '沉': 1554, '悟': 1555, '蹦': 1556, '陳': 1557, '弯': 1558, '梨': 1559, '脉': 1560, '烈': 1561, '蘇': 1562, '肘': 1563, '确': 1564, '漆': 1565, '8': 1566, '钊': 1567, '获': 1568, '噱': 1569, '刺': 1570, '丽': 1571, '扩': 1572, '领': 1573, '潇': 1574, '即': 1575, '把': 1576, '撕': 1577, ',': 1578, '吟': 1579, '饨': 1580, '隘': 1581, 'i': 1582, '夠': 1583, '郝': 1584, '者': 1585, '渠': 1586, '淄': 1587, '嵌': 1588, '幻': 1589, '鸣': 1590, '兑': 1591, 'ャ': 1592, '脊': 1593, '和': 1594, '柒': 1595, '簿': 1596, '匀': 1597, '缩': 1598, '井': 1599, '隆': 1600, '龍': 1601, '寸': 1602, '浴': 1603, '将': 1604, '徙': 1605, '塔': 1606, '定': 1607, '營': 1608, '⒖': 1609, '評': 1610, '或': 1611, '鸡': 1612, '轉': 1613, '崩': 1614, '矢': 1615, '甄': 1616, '晒': 1617, '喵': 1618, '窦': 1619, '⒌': 1620, '環': 1621, '姗': 1622, '❤': 1623, '齿': 1624, '阱': 1625, '北': 1626, '抵': 1627, '眈': 1628, '舅': 1629, '伙': 1630, '陷': 1631, '剥': 1632, '淀': 1633, '恍': 1634, '蔥': 1635, '宛': 1636, '卻': 1637, '览': 1638, '應': 1639, '動': 1640, '顿': 1641, '义': 1642, '炜': 1643, '奖': 1644, '琍': 1645, '啬': 1646, '匡': 1647, '狄': 1648, '欢': 1649, '阖': 1650, '方': 1651, '↓': 1652, '劑': 1653, '占': 1654, '贬': 1655, '观': 1656, '弧': 1657, '口': 1658, '蘋': 1659, '封': 1660, '拽': 1661, '哇': 1662, '船': 1663, '畜': 1664, '洗': 1665, '嘟': 1666, '忡': 1667, '佑': 1668, '贞': 1669, '俩': 1670, '它': 1671, '埋': 1672, '/': 1673, '殺': 1674, '窘': 1675, '兹': 1676, '纬': 1677, '桑': 1678, '迭': 1679, '卖': 1680, '➋': 1681, '躲': 1682, '驻': 1683, '阀': 1684, '穎': 1685, '嗨': 1686, '簸': 1687, '腔': 1688, '🔲': 1689, '努': 1690, '剁': 1691, '擅': 1692, '欺': 1693, '⒐': 1694, '唔': 1695, '们': 1696, '逝': 1697, '斓': 1698, '积': 1699, '烨': 1700, 'R': 1701, '陸': 1702, '悔': 1703, '非': 1704, '耗': 1705, '园': 1706, '嘎': 1707, '蝎': 1708, '咙': 1709, '侨': 1710, '痘': 1711, '曹': 1712, '侥': 1713, '接': 1714, '咖': 1715, '9': 1716, '住': 1717, '玛': 1718, '鞠': 1719, '脾': 1720, '撼': 1721, '火': 1722, '剩': 1723, '牙': 1724, '酋': 1725, '韶': 1726, '目': 1727, '论': 1728, '环': 1729, '6': 1730, '祛': 1731, '喊': 1732, '娘': 1733, '抄': 1734, '构': 1735, '嗲': 1736, '缮': 1737, '贤': 1738, '遣': 1739, '竺': 1740, '缙': 1741, '雅': 1742, '摇': 1743, '间': 1744, '刀': 1745, '拍': 1746, '(': 1747, '庐': 1748, '胺': 1749, '携': 1750, '价': 1751, '合': 1752, '益': 1753, '溝': 1754, '電': 1755, '佢': 1756, '黑': 1757, '骗': 1758, '亿': 1759, '阉': 1760, '坼': 1761, '趋': 1762, '蕉': 1763, '侠': 1764, '昌': 1765, '素': 1766, '飯': 1767, '僧': 1768, '逻': 1769, '赌': 1770, '尊': 1771, '紋': 1772, '彬': 1773, '庆': 1774, '找': 1775, '讲': 1776, '…': 1777, '雇': 1778, '纪': 1779, 'J': 1780, '」': 1781, '杯': 1782, '獎': 1783, '吕': 1784, '皓': 1785, '沁': 1786, '椽': 1787, '出': 1788, '邱': 1789, '咗': 1790, '?': 1791, '充': 1792, '阳': 1793, '\ue141': 1794, '扶': 1795, '亢': 1796, '逃': 1797, '河': 1798, '治': 1799, '愿': 1800, '际': 1801, '图': 1802, '拔': 1803, '祸': 1804, '墟': 1805, '横': 1806, '啦': 1807, '炒': 1808, '首': 1809, '證': 1810, '丢': 1811, '芜': 1812, '少': 1813, '敞': 1814, '诫': 1815, '陆': 1816, '`': 1817, '旬': 1818, '刑': 1819, '行': 1820, '.': 1821, 'é': 1822, '删': 1823, '犬': 1824, '邪': 1825, '亨': 1826, '*': 1827, '巳': 1828, '虑': 1829, '灵': 1830, '箭': 1831, '倡': 1832, '隧': 1833, '懒': 1834, '疡': 1835, '已': 1836, '摔': 1837, '谋': 1838, '讼': 1839, '衡': 1840, '妥': 1841, '鞋': 1842, '区': 1843, '仲': 1844, '盘': 1845, '腚': 1846, '沒': 1847, '拌': 1848, '蒸': 1849, '侵': 1850, '迹': 1851, '守': 1852, '湿': 1853, '達': 1854, '骏': 1855, '萧': 1856, '硝': 1857, '麻': 1858, '颗': 1859, '柔': 1860, '昧': 1861, '堪': 1862, '晟': 1863, '衔': 1864, '杠': 1865, '啖': 1866, '戟': 1867, '睹': 1868, '异': 1869, 'h': 1870, '┭': 1871, '迢': 1872, '蕾': 1873, '怜': 1874, '缴': 1875, '印': 1876, '醫': 1877, '袍': 1878, '妊': 1879, '录': 1880, '嘈': 1881, '蕭': 1882, '闹': 1883, '支': 1884, '唐': 1885, '星': 1886, '订': 1887, '烦': 1888, '齒': 1889, '甫': 1890, '既': 1891, '疮': 1892, '绪': 1893, '皇': 1894, '莲': 1895, '志': 1896, '涡': 1897, '偎': 1898, '胁': 1899, '疹': 1900, '勺': 1901, '因': 1902, '杜': 1903, '宠': 1904, '渎': 1905, '贯': 1906, '瓦': 1907, '衅': 1908, '叩': 1909, '瘀': 1910, '直': 1911, '肥': 1912, '许': 1913, '京': 1914, '敲': 1915, '褶': 1916, '沸': 1917, '毁': 1918, '讨': 1919, '屿': 1920, '值': 1921, '蹭': 1922, '芩': 1923, '街': 1924, '馨': 1925, '髦': 1926, '湧': 1927, '粵': 1928, '玻': 1929, '朱': 1930, '凌': 1931, '汕': 1932, '絕': 1933, '謝': 1934, '完': 1935, '函': 1936, '龚': 1937, '飽': 1938, '檐': 1939, '猫': 1940, '坍': 1941, '微': 1942, '跌': 1943, '奏': 1944, '仙': 1945, '站': 1946, '彪': 1947, '尔': 1948, '迈': 1949, '节': 1950, '尽': 1951, '诠': 1952, '乏': 1953, '犯': 1954, '研': 1955, '宰': 1956, '厮': 1957, '項': 1958, '搬': 1959, '忘': 1960, '当': 1961, '怀': 1962, '冲': 1963, '侄': 1964, '骤': 1965, '況': 1966, '會': 1967, '卸': 1968, '泾': 1969, '毯': 1970, '剑': 1971, '见': 1972, '蔗': 1973, '輩': 1974, '季': 1975, '珊': 1976, '嚕': 1977, '稣': 1978, '建': 1979, '误': 1980, '询': 1981, '茂': 1982, '獠': 1983, '潘': 1984, '舆': 1985, '嫁': 1986, '砂': 1987, '係': 1988, '仅': 1989, '茫': 1990, '酥': 1991, '茎': 1992, '汾': 1993, '﹣': 1994, '凶': 1995, '居': 1996, '喂': 1997, '搅': 1998, '璋': 1999, '羁': 2000, '挥': 2001, '回': 2002, '囊': 2003, '赞': 2004, '揪': 2005, '浦': 2006, '椰': 2007, '衷': 2008, ':': 2009, '汤': 2010, '編': 2011, '裏': 2012, '续': 2013, '广': 2014, '靡': 2015, '困': 2016, '選': 2017, '今': 2018, '垫': 2019, '崴': 2020, '车': 2021, '择': 2022, '饼': 2023, '炬': 2024, '傲': 2025, '組': 2026, '若': 2027, '敌': 2028, '疽': 2029, '骄': 2030, '誓': 2031, '温': 2032, '攝': 2033, '忻': 2034, '千': 2035, '綠': 2036, '辑': 2037, '佯': 2038, '傾': 2039, '桃': 2040, '抿': 2041, '踏': 2042, '豫': 2043, '态': 2044, '❌': 2045, '抹': 2046, '懈': 2047, '员': 2048, '对': 2049, '圾': 2050, '潭': 2051, '孔': 2052, '看': 2053, '鬼': 2054, '假': 2055, '呱': 2056, '號': 2057, '鍾': 2058, 'も': 2059, '疗': 2060, '谷': 2061, '彗': 2062, '丝': 2063, '之': 2064, '阪': 2065, '帮': 2066, '侧': 2067, '付': 2068, '祀': 2069, '苯': 2070, '诚': 2071, '歪': 2072, '举': 2073, '加': 2074, '婺': 2075, '窃': 2076, '👽': 2077, '容': 2078, '切': 2079, '锦': 2080, '唉': 2081, '弊': 2082, '及': 2083, '寻': 2084, '式': 2085, '页': 2086, '随': 2087, '钟': 2088, '炙': 2089, '颐': 2090, '瘦': 2091, '肤': 2092, '2': 2093, '絮': 2094, '畔': 2095, '娟': 2096, '⑤': 2097, '晰': 2098, '馆': 2099, '疏': 2100, '砧': 2101, '挂': 2102, '視': 2103, '浔': 2104, '丫': 2105, '1': 2106, '纷': 2107, '掏': 2108, '释': 2109, '惟': 2110, '家': 2111, '芥': 2112, '侮': 2113, '挝': 2114, '狠': 2115, '畸': 2116, 'A': 2117, '殃': 2118, '鲁': 2119, '琴': 2120, '枉': 2121, '佳': 2122, '菲': 2123, 'ン': 2124, '甩': 2125, '唱': 2126, '糟': 2127, '徨': 2128, '进': 2129, '忆': 2130, '蚂': 2131, '氣': 2132, '諾': 2133, '敦': 2134, '叭': 2135, '梳': 2136, '庇': 2137, '球': 2138, '饺': 2139, 'V': 2140, '增': 2141, '《': 2142, '亏': 2143, '匹': 2144, '楠': 2145, '畅': 2146, '暮': 2147, '物': 2148, '屠': 2149, '税': 2150, '魏': 2151, '碰': 2152, '[': 2153, '鲜': 2154, '蟹': 2155, '縛': 2156, '基': 2157, '蔡': 2158, '爽': 2159, '導': 2160, '级': 2161, '赛': 2162, '项': 2163, '寞': 2164, '湘': 2165, '渴': 2166, '么': 2167, '稚': 2168, '冷': 2169, '轩': 2170, '\ue419': 2171, '教': 2172, '爪': 2173, '淆': 2174, '轻': 2175, '靈': 2176, '融': 2177, '衩': 2178, '結': 2179, '喱': 2180, '曉': 2181, '贴': 2182, '云': 2183, '尝': 2184, '紧': 2185, '慘': 2186, '线': 2187, '笋': 2188, '暴': 2189, '數': 2190, '不': 2191, '拖': 2192, '滤': 2193, '秀': 2194, '蜀': 2195, '愤': 2196, '易': 2197, '导': 2198, '玲': 2199, '蛇': 2200, '奂': 2201, '挫': 2202, '嘛': 2203, '腻': 2204, '雯': 2205, '阔': 2206, '实': 2207, '蛊': 2208, '叼': 2209, '经': 2210, '廊': 2211, '拓': 2212, '达': 2213, '混': 2214, '仆': 2215, '痕': 2216, '较': 2217, '信': 2218, '镌': 2219, '荣': 2220, '羊': 2221, '吴': 2222, '苟': 2223, '借': 2224, '郑': 2225, '祠': 2226, '喜': 2227, '歌': 2228, '况': 2229, '桉': 2230, '笔': 2231, '聆': 2232, '树': 2233, '啃': 2234, '飞': 2235, '从': 2236, '門': 2237, 'G': 2238, '仓': 2239, '位': 2240, '欣': 2241, '音': 2242, '扑': 2243, '❗': 2244, '透': 2245, '述': 2246, '報': 2247, '咎': 2248, '肌': 2249, '吊': 2250, '了': 2251, '贾': 2252, '半': 2253, '截': 2254, '‼': 2255, '允': 2256, '瞄': 2257, '奴': 2258, '鹿': 2259, '蓆': 2260, 'め': 2261, '故': 2262, '革': 2263, '循': 2264, '诩': 2265, '拉': 2266, '\ue112': 2267, '〜': 2268, '粘': 2269, '眨': 2270, '垮': 2271, '⒋': 2272, '≧': 2273, '呸': 2274, '量': 2275, '氰': 2276, '涩': 2277, '吁': 2278, '瑜': 2279, '有': 2280, '罚': 2281, '邢': 2282, '英': 2283, '鼠': 2284, '蜘': 2285, '⑦': 2286, '別': 2287, '際': 2288, '记': 2289, '麼': 2290, '城': 2291, '邊': 2292, '哉': 2293, '茹': 2294, '矣': 2295, '聞': 2296, '航': 2297, '瘙': 2298, '椅': 2299, '泰': 2300, '屬': 2301, '蹂': 2302, '咁': 2303, '躁': 2304, '|': 2305, '变': 2306, '胜': 2307, '调': 2308, '疆': 2309, '该': 2310, '亡': 2311, '晔': 2312, '窒': 2313, '罡': 2314, '核': 2315, '·': 2316, '糠': 2317, '旨': 2318, '钱': 2319, '凰': 2320, '民': 2321, '祥': 2322, '洒': 2323, '锅': 2324, '悄': 2325, '迂': 2326, '器': 2327, '戳': 2328, '蒲': 2329, '诙': 2330, '喳': 2331, '為': 2332, '雨': 2333, '旻': 2334, '灼': 2335, '肝': 2336, '匠': 2337, '土': 2338, '琳': 2339, '惩': 2340, '・': 2341, '姐': 2342, '彩': 2343, '障': 2344, '進': 2345, '劵': 2346, '理': 2347, '沏': 2348, '外': 2349, '佛': 2350, 'か': 2351, '裝': 2352, '皙': 2353, '颇': 2354, '肪': 2355, '崔': 2356, '嚼': 2357, '讳': 2358, '救': 2359, '淮': 2360, '烁': 2361, '搂': 2362, '⒎': 2363, '臀': 2364, '💗': 2365, '诀': 2366, '踪': 2367, '辆': 2368, '殇': 2369, '岁': 2370, '猥': 2371, '墩': 2372, '晃': 2373, '渔': 2374, '腐': 2375, '觉': 2376, '吨': 2377, '芙': 2378, '🇸': 2379, '服': 2380, '需': 2381, 't': 2382, '琨': 2383, '丐': 2384, '昼': 2385, '兜': 2386, '事': 2387, '谬': 2388, '氛': 2389, '菠': 2390, '介': 2391, '径': 2392, '俐': 2393, '黯': 2394, '3': 2395, '陕': 2396, '➍': 2397, '蝙': 2398, '岐': 2399, '藝': 2400, '黏': 2401, '蓉': 2402, '陶': 2403, '准': 2404, '追': 2405, '衝': 2406, '雌': 2407, '沃': 2408, '關': 2409, '贝': 2410, 'd': 2411, '博': 2412, '速': 2413, '洁': 2414, '珐': 2415, '督': 2416, '瑞': 2417, '步': 2418, '嗯': 2419, '贸': 2420, '喀': 2421, '拟': 2422, '件': 2423, '💓': 2424, '生': 2425, '钨': 2426, '!': 2427, '機': 2428, '\ue41d': 2429, '皱': 2430, '族': 2431, '僭': 2432, '镐': 2433, '精': 2434, '艘': 2435, '镖': 2436, '曙': 2437, '扔': 2438, '😚': 2439, '勉': 2440, '疯': 2441, '赋': 2442, '騙': 2443, '徐': 2444, '塑': 2445, '凭': 2446, '人': 2447, '川': 2448, '\ue333': 2449, '弈': 2450, '賀': 2451, '党': 2452, '始': 2453, 'v': 2454, '腋': 2455, '致': 2456, '隊': 2457, '丸': 2458, '😭': 2459, '格': 2460, '幸': 2461, '與': 2462, '淌': 2463, '掩': 2464, '待': 2465, '于': 2466, '悍': 2467, '蹲': 2468, '难': 2469, '禺': 2470, '可': 2471, '義': 2472, '䄂': 2473, '谢': 2474, '咕': 2475, '毬': 2476, '喇': 2477, '戸': 2478, '魚': 2479, '娠': 2480, '圈': 2481, '弓': 2482, '蒋': 2483, '掘': 2484, '滾': 2485, '谶': 2486, '孱': 2487, '購': 2488, '躏': 2489, '呵': 2490, '焯': 2491, '\ue418': 2492, '仰': 2493, '密': 2494, '苗': 2495, '纠': 2496, '霆': 2497, '臥': 2498, '灬': 2499, '願': 2500, '荐': 2501, '惧': 2502, '兽': 2503, '渡': 2504, '酷': 2505, '森': 2506, '厘': 2507, '食': 2508, '办': 2509, '俞': 2510, '训': 2511, '灭': 2512, '婕': 2513, '袜': 2514, '罢': 2515, '旺': 2516, '瞥': 2517, '寧': 2518, '笨': 2519, '筷': 2520, '睦': 2521, '迪': 2522, '种': 2523, '題': 2524, '纲': 2525, '預': 2526, '螂': 2527, '醉': 2528, '息': 2529, '胭': 2530, '昕': 2531, '鲨': 2532, '衰': 2533, '逸': 2534, '享': 2535, '士': 2536, '纵': 2537, '莓': 2538, '顾': 2539, '孩': 2540, '拨': 2541, '乓': 2542, '吐': 2543, '显': 2544, '難': 2545, '泌': 2546, '舉': 2547, '剃': 2548, '∕': 2549, '無': 2550, '叔': 2551, '俗': 2552, '裕': 2553, '~': 2554, '讓': 2555, '卜': 2556, '奔': 2557, '凤': 2558, '畏': 2559, '6': 2560, '虐': 2561, '婆': 2562, '骆': 2563, '霧': 2564, '最': 2565, '缨': 2566, 'z': 2567, '晶': 2568, '粑': 2569, '觑': 2570, '砷': 2571, '劣': 2572, '濡': 2573, '骁': 2574, '附': 2575, '鱼': 2576, '综': 2577, '敷': 2578, '粟': 2579, 'x': 2580, '恩': 2581, '迫': 2582, 'з': 2583, '予': 2584, '谟': 2585, '辍': 2586, '螨': 2587, '幽': 2588, '讥': 2589, '填': 2590, '專': 2591, '报': 2592, '驴': 2593, '促': 2594, '语': 2595, '辣': 2596, '棵': 2597, '峙': 2598, '崎': 2599, '珑': 2600, '左': 2601, '東': 2602, '琥': 2603, '厢': 2604, '悦': 2605, '心': 2606, '莞': 2607, '☞': 2608, '阎': 2609, '琼': 2610, '赔': 2611, '厦': 2612, '瞑': 2613, '邃': 2614, '苍': 2615, '炉': 2616, '朗': 2617, '视': 2618, '劲': 2619, '臾': 2620, '颖': 2621, '哋': 2622, '堆': 2623, '课': 2624, '咪': 2625, '缘': 2626, '屍': 2627, '恻': 2628, '裹': 2629, '市': 2630, '魯': 2631, '卵': 2632, '扎': 2633, '钞': 2634, '禀': 2635, '瘋': 2636, '窿': 2637, '差': 2638, '脂': 2639, '化': 2640, '掺': 2641, '菩': 2642, '溟': 2643, '焰': 2644, '淳': 2645, '逢': 2646, '铎': 2647, '訂': 2648, '鬣': 2649, '括': 2650, '启': 2651, '吾': 2652, '输': 2653, '芽': 2654, '昆': 2655, '旦': 2656, '套': 2657, '韦': 2658, '姻': 2659, '弗': 2660, '戒': 2661, '遁': 2662, 'B': 2663, '蔬': 2664, '俠': 2665, '读': 2666, '早': 2667, '并': 2668, '三': 2669, '剿': 2670, '颈': 2671, '渭': 2672, '罒': 2673, '亭': 2674, '湛': 2675, '铛': 2676, '嗜': 2677, '巍': 2678, '讣': 2679, '恋': 2680, '酒': 2681, '蔓': 2682, '冠': 2683, '绚': 2684, '碉': 2685, '減': 2686, '抓': 2687, '眠': 2688, '%': 2689, 'q': 2690, '婚': 2691, '肛': 2692, '让': 2693, '梦': 2694, '李': 2695, '得': 2696, '乞': 2697, '赂': 2698, '圆': 2699, '擎': 2700, 'F': 2701, '务': 2702, '=': 2703, '解': 2704, '宴': 2705, '名': 2706, '鹂': 2707, '碑': 2708, '篮': 2709, '带': 2710, '议': 2711, '鲍': 2712, '慰': 2713, '舊': 2714, '感': 2715, '煥': 2716, '饰': 2717, '爆': 2718, '梁': 2719, '副': 2720, '米': 2721, '腹': 2722, '🐵': 2723, '耻': 2724, '赵': 2725, '蛛': 2726, '羯': 2727, '瑚': 2728, '忏': 2729, '箴': 2730, '驚': 2731, '除': 2732, '娃': 2733, '链': 2734, '嬉': 2735, '袱': 2736, '㎡': 2737, '噜': 2738, '中': 2739, '谐': 2740, '识': 2741, '禅': 2742, '秽': 2743, '眩': 2744, '彦': 2745, '塞': 2746, '摒': 2747, '魂': 2748, '秋': 2749, '铭': 2750, '\\': 2751, '泱': 2752, '胶': 2753, '樣': 2754, '妃': 2755, '厄': 2756, '尅': 2757, '术': 2758, '转': 2759, '途': 2760, '灯': 2761, '爹': 2762, '喻': 2763, '痒': 2764, '栎': 2765, '馬': 2766, '訓': 2767, '囂': 2768, '▽': 2769, '联': 2770, '熄': 2771, '周': 2772, '殷': 2773, '整': 2774, '睇': 2775, '便': 2776, '蜷': 2777, '硕': 2778, '彻': 2779, '试': 2780, '傭': 2781, '冼': 2782, '避': 2783, 'ノ': 2784, '镜': 2785, '瓣': 2786, '噤': 2787, '耐': 2788, '炸': 2789, '疾': 2790, '商': 2791, '愁': 2792, '腑': 2793, '吏': 2794, '贷': 2795, '算': 2796, '瞧': 2797, '孰': 2798, '婪': 2799, '氧': 2800, '详': 2801, '崛': 2802, '福': 2803, '营': 2804, '姓': 2805, '霾': 2806, '奈': 2807, '潜': 2808, '✨': 2809, '铱': 2810, '妝': 2811, '裸': 2812, '递': 2813, '番': 2814, '薇': 2815, '瑟': 2816, '挚': 2817, '默': 2818, '妍': 2819, '诽': 2820, '忠': 2821, '欠': 2822, '诋': 2823, '秘': 2824, '栗': 2825, '风': 2826, '跋': 2827, '師': 2828, '取': 2829, '灾': 2830, '瑪': 2831, '遏': 2832, '彝': 2833, '侦': 2834, '妩': 2835, '"': 2836, '院': 2837, '础': 2838, '藍': 2839, '也': 2840, '此': 2841, '灌': 2842, '兴': 2843, '覆': 2844, '馍': 2845, '公': 2846, '怎': 2847, '亚': 2848, '跳': 2849, '肠': 2850, '歡': 2851, '坡': 2852, '邂': 2853, '凹': 2854, '谁': 2855, '插': 2856, '荷': 2857, '琵': 2858, '兒': 2859, '槃': 2860, '芒': 2861, 'k': 2862, '豢': 2863, '她': 2864, '穿': 2865, '劈': 2866, '尴': 2867, '击': 2868, '滴': 2869, '茜': 2870, '募': 2871, '烙': 2872, '柱': 2873, '嘘': 2874, '夙': 2875, '】': 2876, '擇': 2877, '肢': 2878, '璐': 2879, '粮': 2880, '阻': 2881, '绞': 2882, '赤': 2883, '捂': 2884, '泵': 2885, '圃': 2886, '蓬': 2887, '赖': 2888, '悯': 2889, '底': 2890, '岩': 2891, '淤': 2892, '闲': 2893, '慶': 2894, '媛': 2895, '惕': 2896, '岂': 2897, '为': 2898, '贩': 2899, '田': 2900, '勒': 2901, '捅': 2902, '业': 2903, '黃': 2904, '话': 2905, '愛': 2906, '徒': 2907, '什': 2908, '屁': 2909, '孝': 2910, '胳': 2911, '闭': 2912, '雕': 2913, 'し': 2914, '卧': 2915, '农': 2916, '奥': 2917, '伟': 2918, '轰': 2919, '昏': 2920, '馥': 2921, '戚': 2922, '戶': 2923, '饿': 2924, '糸': 2925, '入': 2926, '逗': 2927, '豬': 2928, '波': 2929, '尋': 2930, '颠': 2931, '堂': 2932, '枚': 2933, '枝': 2934, '珉': 2935, '送': 2936, '脖': 2937, '成': 2938, '咬': 2939, '鲟': 2940, '抚': 2941, '与': 2942, '茬': 2943, '拱': 2944, '学': 2945, '?': 2946, '摸': 2947, '腌': 2948, '怒': 2949, '哗': 2950, '选': 2951, '眼': 2952, '芬': 2953, '罕': 2954, '创': 2955, '涂': 2956, '稻': 2957, '大': 2958, '腱': 2959, '辈': 2960, '億': 2961, '猴': 2962, '新': 2963, 'y': 2964, '射': 2965, '概': 2966, '娇': 2967, '败': 2968, '辞': 2969, '裱': 2970, '個': 2971, '额': 2972, '帖': 2973, '遂': 2974, '質': 2975, '頭': 2976, '绕': 2977, '噢': 2978, '래': 2979, '房': 2980, '丹': 2981, '条': 2982, '苒': 2983, '捐': 2984, '顶': 2985, '檬': 2986, '災': 2987, '返': 2988, '史': 2989, '逊': 2990, '糜': 2991, '题': 2992, '嫌': 2993, '蓝': 2994, '饲': 2995, '沙': 2996, '蘑': 2997, '雪': 2998, '材': 2999, '媚': 3000, '』': 3001, '葵': 3002, '妄': 3003, '穷': 3004, '贈': 3005, '焕': 3006, '嘱': 3007, '播': 3008, '援': 3009, '脸': 3010, '废': 3011, '菜': 3012, '糯': 3013, '-': 3014, '蘭': 3015, '!': 3016, '四': 3017, '临': 3018, '苹': 3019, '缕': 3020, '迄': 3021, '窗': 3022, '孤': 3023, '罹': 3024, '萄': 3025, '莹': 3026, '蜕': 3027, '遵': 3028, '橄': 3029, '乘': 3030, '那': 3031, '仿': 3032, '絲': 3033, '\ue109': 3034, '扫': 3035, '贫': 3036, '隅': 3037, '觎': 3038, '雲': 3039, '洛': 3040, '踢': 3041, '抛': 3042, '磁': 3043, '穆': 3044, '涛': 3045, 'H': 3046, '贼': 3047, '噩': 3048, '昭': 3049, '蝠': 3050, '墅': 3051, '屹': 3052, '堕': 3053, '祇': 3054, '靜': 3055, '禄': 3056, '购': 3057, '瑶': 3058, 'à': 3059, '言': 3060, '泽': 3061, '揚': 3062, '宣': 3063, '瀑': 3064, '书': 3065, '澈': 3066, '玑': 3067, '违': 3068, '劳': 3069, '較': 3070, '指': 3071, '詩': 3072, '纤': 3073, '笑': 3074, '華': 3075, '诗': 3076, '袂': 3077, '倪': 3078, '羞': 3079, '拾': 3080, '小': 3081, '¥': 3082, '轮': 3083, '纽': 3084, '蹬': 3085, '惯': 3086, '➌': 3087, '下': 3088, '宽': 3089, '好': 3090, '店': 3091, '芝': 3092, '藻': 3093, '暑': 3094, '跑': 3095, '褐': 3096, '響': 3097, '、': 3098, '☑': 3099, '短': 3100, '晚': 3101, '挪': 3102, '⒏': 3103, '哕': 3104, '形': 3105, '陪': 3106, '芭': 3107, '枣': 3108, '總': 3109, '〞': 3110, '涅': 3111, '但': 3112, '影': 3113, '据': 3114, '笫': 3115, '港': 3116, '月': 3117, '版': 3118, '彷': 3119, '柴': 3120, '阿': 3121, '玩': 3122, '损': 3123, '结': 3124, '虎': 3125, '殖': 3126, '韓': 3127, '鯉': 3128, '歇': 3129, '屯': 3130, '句': 3131, '坊': 3132, '酸': 3133, '某': 3134, '屏': 3135, '養': 3136, '迟': 3137, '萌': 3138, '产': 3139, '减': 3140, '嘍': 3141, '颚': 3142, '遇': 3143, '倦': 3144, '嘶': 3145, '獻': 3146, '枫': 3147, '置': 3148, '钗': 3149, '响': 3150, '奘': 3151, '现': 3152, '➏': 3153, '消': 3154, '屋': 3155, '粗': 3156, '痊': 3157, '狈': 3158, '海': 3159, '卓': 3160, '郭': 3161, '帛': 3162, '过': 3163, '坤': 3164, '晗': 3165, '杨': 3166, '賓': 3167, '岼': 3168, '嘿': 3169, '辉': 3170, '蜡': 3171, '愣': 3172, '伐': 3173, '张': 3174, '帆': 3175, '龈': 3176, '害': 3177, '團': 3178, '重': 3179, '自': 3180, '剧': 3181, '骂': 3182, '亲': 3183, '践': 3184, '寡': 3185, '荫': 3186, '用': 3187, '系': 3188, '\u200b': 3189, '橙': 3190, '愉': 3191, '缉': 3192, '哦': 3193, '窟': 3194, '砖': 3195, '鴻': 3196, '体': 3197, '空': 3198, '汉': 3199, '阅': 3200, '淡': 3201, '祭': 3202, '痈': 3203, '映': 3204, '卡': 3205, '牠': 3206, '夕': 3207, '财': 3208, '豊': 3209, '麟': 3210, '贵': 3211, 'X': 3212, '驼': 3213, '脱': 3214, '¥': 3215, '@': 3216, '(': 3217, '矛': 3218, '瓷': 3219, '汨': 3220, '框': 3221, '悱': 3222, '竖': 3223, '宾': 3224, '霸': 3225, '坟': 3226, '栋': 3227, 'a': 3228, '同': 3229, '正': 3230, '片': 3231, 'b': 3232, '边': 3233, '樱': 3234, '畑': 3235, '要': 3236, '斯': 3237, '咯': 3238, '的': 3239, '亦': 3240, '摊': 3241, '赁': 3242, '續': 3243, '呻': 3244, '司': 3245, '摆': 3246, '绳': 3247, '唠': 3248, '嬷': 3249, '煌': 3250, '章': 3251, '翅': 3252, '\': 3253, '腿': 3254, '棘': 3255, '老': 3256, '{': 3257, '姬': 3258, '惶': 3259, '晴': 3260, '兮': 3261, '咏': 3262, '号': 3263, '漠': 3264, '厅': 3265, '匙': 3266, '議': 3267, '滥': 3268, '飆': 3269, '锤': 3270, '屎': 3271, '幕': 3272, '祝': 3273, '阴': 3274, '盟': 3275, '壤': 3276, '胸': 3277, '妓': 3278, '囉': 3279, '瑕': 3280, '阮': 3281, '㎝': 3282, '峰': 3283, '溧': 3284, '轺': 3285, '止': 3286, '浩': 3287, '趕': 3288, '衛': 3289, '遷': 3290, '奶': 3291, '供': 3292, '这': 3293, '現': 3294, '塌': 3295, '慎': 3296, '提': 3297, '良': 3298, '津': 3299, '威': 3300, '州': 3301, '售': 3302, '筒': 3303, '┮': 3304, '🇺': 3305, ')': 3306, '溺': 3307, '春': 3308, '鳥': 3309, '驳': 3310, '辖': 3311, '苛': 3312, '赘': 3313, '敏': 3314, '飘': 3315, '筹': 3316, '激': 3317, '毫': 3318, '掀': 3319, '宇': 3320, '稿': 3321, '瘪': 3322, '誕': 3323, '✅': 3324, '赐': 3325, '恳': 3326, '岭': 3327, '白': 3328, '声': 3329, '村': 3330, '頁': 3331, '淚': 3332, '鲵': 3333, '恪': 3334, '错': 3335, '香': 3336, '靶': 3337, '骨': 3338, '雄': 3339, '萍': 3340, '昊': 3341, 'リ': 3342, '五': 3343, '挟': 3344, '鉛': 3345, '滨': 3346, '漱': 3347, '喷': 3348, '油': 3349, '状': 3350, '髓': 3351, '丰': 3352, '培': 3353, '裁': 3354, '繹': 3355, '蔑': 3356, '棉': 3357, '泼': 3358, '③': 3359, '掐': 3360, '喺': 3361, '克': 3362, '硬': 3363, '闪': 3364, '伺': 3365, '褪': 3366, '猬': 3367, '哭': 3368, '費': 3369, '薛': 3370, '淫': 3371, '矜': 3372, '丑': 3373, '清': 3374, '馋': 3375, '伍': 3376, '预': 3377, '駿': 3378, '丶': 3379, '其': 3380, '潸': 3381, '辗': 3382, '妮': 3383, '未': 3384, '疑': 3385, '盖': 3386, '刻': 3387, '悼': 3388, '◆': 3389, '评': 3390, '籍': 3391, '巨': 3392, '迅': 3393, '秒': 3394, '斩': 3395, '◇': 3396, '胀': 3397, '杀': 3398, '杭': 3399, '萨': 3400, '鑿': 3401, '該': 3402, '郁': 3403, '换': 3404, '距': 3405, '茨': 3406, '搁': 3407, '歹': 3408, '帕': 3409, '劉': 3410, '缔': 3411, '漢': 3412, '裡': 3413, '屡': 3414, '[': 3415, '毛': 3416, '誉': 3417, '涯': 3418, '儿': 3419, '躯': 3420, '驶': 3421, '荼': 3422, '啫': 3423, '彤': 3424, '烤': 3425, '收': 3426, '瓜': 3427, '侈': 3428, '斗': 3429, '里': 3430, '辩': 3431, '熙': 3432, '采': 3433, '忧': 3434, '穴': 3435, '符': 3436, '免': 3437, '握': 3438, '請': 3439, '鸠': 3440, '慈': 3441, '廈': 3442, '抬': 3443, '嚴': 3444, '身': 3445, '虔': 3446, '然': 3447, '斋': 3448, '控': 3449, '患': 3450, '飛': 3451, '赃': 3452, '撵': 3453, '燥': 3454, '舜': 3455, '國': 3456, '膝': 3457, '羅': 3458, '葱': 3459, '汀': 3460, '乖': 3461, '蛟': 3462, '露': 3463, '梆': 3464, '麽': 3465, '医': 3466, '條': 3467, '板': 3468, '割': 3469, '祖': 3470, '钢': 3471, '渺': 3472, '點': 3473, '惰': 3474, '戏': 3475, '具': 3476, '延': 3477, '刹': 3478, '塘': 3479, '铅': 3480, '诊': 3481, '凝': 3482, '綸': 3483, '☆': 3484, '壶': 3485, '計': 3486, '锋': 3487, '在': 3488, '颤': 3489, '伯': 3490, '固': 3491, '①': 3492, '游': 3493, '囚': 3494, '帼': 3495, '每': 3496, '亮': 3497, '蚊': 3498, '而': 3499, 'Q': 3500, '奢': 3501, '赠': 3502, '檔': 3503, '含': 3504, '继': 3505, '蛙': 3506, '顷': 3507, '艰': 3508, '撮': 3509, '`': 3510, '怕': 3511, '夺': 3512, '咳': 3513, '認': 3514, '隐': 3515, '⒈': 3516, '②': 3517, '蜃': 3518, '衬': 3519, '喬': 3520, '牲': 3521, '淇': 3522, '私': 3523, '哲': 3524, '雙': 3525, '痪': 3526, '嵘': 3527, '晕': 3528, '撒': 3529, '莉': 3530, '霍': 3531, '園': 3532, '摧': 3533, '➎': 3534, '艱': 3535, '🍀': 3536, '姆': 3537, '谍': 3538, '军': 3539, '越': 3540, '撰': 3541, '双': 3542, '唯': 3543, '嘻': 3544, '狗': 3545, '襄': 3546, ']': 3547, '脚': 3548, '貴': 3549, '湊': 3550, '懊': 3551, '斜': 3552, ',': 3553, '智': 3554, '蠢': 3555, '幅': 3556, '惨': 3557, '俺': 3558, '膀': 3559, '年': 3560, '震': 3561, '禁': 3562, '桌': 3563, '⋯': 3564, '厂': 3565, 'と': 3566, '翁': 3567, '瓯': 3568, '花': 3569, '詞': 3570, 'j': 3571, '战': 3572, '魇': 3573, '舒': 3574, '雹': 3575, '主': 3576, '鄉': 3577, '❀': 3578, '惹': 3579, '扰': 3580, '棍': 3581, '啥': 3582, '柿': 3583, '坠': 3584, '译': 3585, '泓': 3586, '否': 3587, '粒': 3588, '酝': 3589, '敗': 3590, '猿': 3591, '跃': 3592, '泉': 3593, '饕': 3594, '狮': 3595, '浪': 3596, '背': 3597, '至': 3598, '罂': 3599, '岚': 3600, '骑': 3601, '苏': 3602, '测': 3603, '仔': 3604, '>': 3605, '}': 3606, '毅': 3607, '突': 3608, '数': 3609, '齐': 3610, 'n': 3611, '丙': 3612, '敢': 3613, '掠': 3614, '犀': 3615, '码': 3616, '盒': 3617, '雜': 3618, '析': 3619, '乔': 3620, '🐒': 3621, '蒜': 3622, '♪': 3623, '架': 3624, '脐': 3625, '倩': 3626, '刘': 3627, '馄': 3628, '扳': 3629, '销': 3630, '彈': 3631, '滚': 3632, ']': 3633, '豌': 3634, '規': 3635, '羡': 3636, '佣': 3637, '讶': 3638, '代': 3639, '裳': 3640, '疤': 3641, '哪': 3642, '何': 3643, '聋': 3644, '绩': 3645, '發': 3646, '振': 3647, '鎮': 3648, '户': 3649, '亟': 3650, '虾': 3651, '沦': 3652, '泛': 3653, '淑': 3654, '寰': 3655, '黛': 3656, '溫': 3657, '粽': 3658, '溢': 3659, '蠻': 3660, '廿': 3661, '類': 3662, '椎': 3663, '扼': 3664, '😱': 3665, 'Z': 3666, '麦': 3667, '西': 3668, '卫': 3669, '瞻': 3670, '舵': 3671, '2': 3672, '富': 3673, '暹': 3674, '道': 3675, '渣': 3676, '查': 3677, '命': 3678, '噗': 3679, '令': 3680, '请': 3681, '腾': 3682, '决': 3683, '搡': 3684, '帶': 3685, '娉': 3686, '膏': 3687, '展': 3688, '累': 3689, '眉': 3690, '壁': 3691, '剎': 3692, '睾': 3693, '很': 3694, '八': 3695, '蟒': 3696, '茶': 3697, '朩': 3698, '銳': 3699, '描': 3700, '快': 3701, '嫂': 3702, '厚': 3703, '④': 3704, '≫': 3705, '陵': 3706, '签': 3707, '诬': 3708, '由': 3709, '马': 3710, '昂': 3711, '溪': 3712, '石': 3713, '暂': 3714, 's': 3715, '橡': 3716, '运': 3717, '漫': 3718, '刮': 3719, '呗': 3720, '綦': 3721, '勘': 3722, '亩': 3723, '布': 3724, '盈': 3725, '谛': 3726, '嗽': 3727, '罗': 3728, '宝': 3729, '痺': 3730, '漂': 3731, 'Y': 3732, '凉': 3733, '胆': 3734, '․': 3735, '婉': 3736, '艇': 3737, '鳗': 3738, '幹': 3739, '碧': 3740, '們': 3741, '催': 3742, '´': 3743, '讹': 3744, '隣': 3745, 'T': 3746, '骼': 3747, '颁': 3748, '罄': 3749, '木': 3750, '慢': 3751, '腫': 3752, '度': 3753, '恐': 3754, '百': 3755, '鹏': 3756, 'u': 3757, '往': 3758, ':': 3759, '模': 3760, '魔': 3761, '十': 3762, '郎': 3763, '讽': 3764, '婀': 3765, '揭': 3766, '耽': 3767, '栏': 3768, '绣': 3769, '頻': 3770, '拥': 3771, '層': 3772, '面': 3773, '酱': 3774, '😲': 3775, '書': 3776, '睽': 3777, '偷': 3778, '兔': 3779, '叛': 3780, '肯': 3781, '衫': 3782, '集': 3783, '络': 3784, '类': 3785, '翰': 3786, '磊': 3787, '牡': 3788, '氯': 3789, '特': 3790, '标': 3791, 'W': 3792, '妨': 3793, '效': 3794, '冀': 3795, '召': 3796, '政': 3797, '囧': 3798, '惜': 3799, '讪': 3800, '磨': 3801, '深': 3802, '璧': 3803, '犹': 3804, '瘤': 3805, '餐': 3806, '挽': 3807, '吉': 3808, '廷': 3809, '呲': 3810, '訊': 3811, '酗': 3812, '佬': 3813, '酶': 3814, '轨': 3815, '型': 3816, '偕': 3817, '诵': 3818, '漯': 3819, '似': 3820, '嗦': 3821, '乃': 3822, '梅': 3823, '⑧': 3824, '靖': 3825, '票': 3826, '滿': 3827, '色': 3828, '址': 3829, 'r': 3830, '屑': 3831, '衣': 3832, '%': 3833, '咋': 3834, '棚': 3835, '_': 3836, '帅': 3837, '娑': 3838, '窕': 3839, '拜': 3840, '酵': 3841, '埔': 3842, '茅': 3843, '他': 3844, '見': 3845, '操': 3846, '等': 3847, '境': 3848, '叉': 3849, '遭': 3850, '札': 3851, '来': 3852, '水': 3853, '鄭': 3854, '历': 3855, '劫': 3856, '署': 3857, '孙': 3858, '红': 3859, '养': 3860, '壳': 3861, '艳': 3862, '捣': 3863, '饶': 3864, '恤': 3865, '醋': 3866, '憐': 3867, '植': 3868, '翱': 3869, '辅': 3870, '蛋': 3871, '鄂': 3872, '媳': 3873, '泣': 3874, '替': 3875, '猎': 3876, '憔': 3877, '晋': 3878, '韌': 3879, '统': 3880, '雍': 3881, '翡': 3882, '偶': 3883, '弥': 3884, '兩': 3885, '戀': 3886, '嗎': 3887, '≦': 3888, '烫': 3889, '😢': 3890, '聪': 3891, '﹏': 3892, '佟': 3893, '厉': 3894, '甸': 3895, '普': 3896, '轴': 3897, '寅': 3898, '优': 3899, '坑': 3900, '哼': 3901, '拆': 3902, '验': 3903, '内': 3904, 'U': 3905, '婵': 3906, '搭': 3907, '時': 3908, 'D': 3909, '颜': 3910, '繼': 3911, '坞': 3912, '斷': 3913, '咱': 3914, '諒': 3915, '郸': 3916, '康': 3917, '六': 3918, '娶': 3919, '獸': 3920, '巩': 3921, '睁': 3922, '奇': 3923, '汁': 3924, '拿': 3925, '黔': 3926, '捍': 3927, '溶': 3928, '瓢': 3929, '阁': 3930, '阂': 3931, '蟑': 3932, '瑋': 3933, '谣': 3934, '去': 3935, '悸': 3936, '麥': 3937, '創': 3938, '袋': 3939, '立': 3940, '册': 3941, '榴': 3942, '荏': 3943, '乱': 3944, '常': 3945, '淹': 3946, '育': 3947, '藤': 3948, '汰': 3949, '缢': 3950, '倒': 3951, '偏': 3952, '瘫': 3953, '凡': 3954, ';': 3955, '辐': 3956, '诱': 3957, '忙': 3958, '熟': 3959, '零': 3960, '荒': 3961, '庵': 3962, '江': 3963, '逍': 3964, '煽': 3965, '佩': 3966, '凸': 3967, '泊': 3968, '巷': 3969, '凯': 3970, '丞': 3971, '學': 3972, '騰': 3973, '碾': 3974, '萱': 3975, '钓': 3976, '勿': 3977, '煤': 3978, '扈': 3979, '灰': 3980, '烹': 3981, '磐': 3982, '冻': 3983, '围': 3984, '筝': 3985, '嫡': 3986, '耶': 3987, '矫': 3988, '鼻': 3989, '粉': 3990, '踹': 3991, '捡': 3992, '赚': 3993, '绍': 3994, '泪': 3995, '善': 3996, '弟': 3997, '萃': 3998, '诶': 3999, '試': 4000, '垂': 4001, '庭': 4002, '费': 4003, '乡': 4004, '礁': 4005, '申': 4006, '呜': 4007, '坷': 4008, '坝': 4009, '飒': 4010, '证': 4011, '扮': 4012, '痿': 4013, '阐': 4014, '庚': 4015, '1': 4016, '问': 4017, '5': 4018, '俱': 4019, '祺': 4020, '嫩': 4021, '礼': 4022, '琶': 4023, '疫': 4024, '针': 4025, '盡': 4026, '汇': 4027, '暧': 4028, '乐': 4029, '尾': 4030, '德': 4031, '膜': 4032, '湖': 4033, '缪': 4034, '极': 4035, '☎': 4036, '獒': 4037, '恶': 4038, '熹': 4039, '谠': 4040, '凄': 4041, '买': 4042, '午': 4043, '狞': 4044, '伸': 4045, '贪': 4046, '兵': 4047, '唁': 4048, '察': 4049, '燕': 4050, '浏': 4051, '剛': 4052, '龟': 4053, '浅': 4054, '橇': 4055, '艹': 4056, '薄': 4057, '扛': 4058, '绛': 4059, '委': 4060, '勢': 4061, '憾': 4062, '污': 4063, '螃': 4064, '郊': 4065, '"': 4066, '官': 4067, '虽': 4068, '啤': 4069, '诲': 4070, '蓄': 4071, '喘': 4072, '软': 4073, '排': 4074, '遠': 4075, '彭': 4076, '倾': 4077, '授': 4078, '眸': 4079, 'p': 4080, '遮': 4081, '恒': 4082, '师': 4083, '崇': 4084, '般': 4085, '琐': 4086, '责': 4087, '宗': 4088, '呆': 4089, '鳌': 4090, '处': 4091, '攻': 4092, '钥': 4093, '松': 4094, '醺': 4095, '鼎': 4096, '储': 4097, '陌': 4098, '咲': 4099, '3': 4100, '幂': 4101, '恣': 4102, '谓': 4103, '過': 4104, '緊': 4105, '咨': 4106, '宵': 4107, '抖': 4108, '鑑': 4109, '到': 4110, '盔': 4111, '望': 4112, '浑': 4113, '给': 4114, '剪': 4115, '妙': 4116, '僵': 4117, '饱': 4118, '岳': 4119, '髮': 4120, '怺': 4121, '工': 4122, '鸦': 4123, '渐': 4124, '驾': 4125, '娛': 4126, '葛': 4127, '風': 4128, '愈': 4129, '糊': 4130, '週': 4131, '洲': 4132, '颂': 4133, '曲': 4134, '助': 4135, '懂': 4136, '王': 4137, '妻': 4138, '俚': 4139, '肋': 4140, '潼': 4141, '氓': 4142, '袭': 4143, '&': 4144, '🇨': 4145, '草': 4146, '広': 4147, '子': 4148, '🌟': 4149, '呈': 4150, '景': 4151, '二': 4152, '捕': 4153, '绒': 4154, '忍': 4155, '迎': 4156, '礴': 4157, '瘾': 4158, '序': 4159, '7': 4160, '胧': 4161, '锢': 4162, 'f': 4163, '掇': 4164, '咻': 4165, '吝': 4166, '寶': 4167, '氏': 4168, '窝': 4169, '阵': 4170, '坚': 4171, '疲': 4172, '兼': 4173, '皆': 4174, '攒': 4175, '酣': 4176, '仪': 4177, '變': 4178, '桂': 4179, '兆': 4180, '昶': 4181, '装': 4182, '尖': 4183, 'L': 4184, '瓶': 4185, '稀': 4186, '诡': 4187, '妒': 4188, '裂': 4189, '弦': 4190, '翔': 4191, '葬': 4192, '馈': 4193, '扉': 4194, '囔': 4195, '喧': 4196, '盛': 4197, '笛': 4198, '態': 4199, '町': 4200, '餮': 4201, '钛': 4202, '🍁': 4203, '灣': 4204, '鬥': 4205, '嵯': 4206, '粥': 4207, '慵': 4208, '如': 4209, '葆': 4210, '記': 4211, '足': 4212, '约': 4213, '屌': 4214, '移': 4215, '门': 4216, '詹': 4217, '價': 4218, '闽': 4219, '屆': 4220, '碱': 4221, '袖': 4222, '長': 4223, '画': 4224, '余': 4225, '琢': 4226, '帐': 4227, '嚎': 4228, '留': 4229, '跚': 4230, '床': 4231, '刚': 4232, '哒': 4233, '鸽': 4234, '知': 4235, '块': 4236, '杉': 4237, '尼': 4238, '’': 4239, '敛': 4240, '涨': 4241, '橫': 4242, '思': 4243, '媒': 4244, '朝': 4245, '輝': 4246, '例': 4247, '押': 4248, '槽': 4249, '挑': 4250, '狭': 4251, '間': 4252, '前': 4253, '考': 4254, '娱': 4255, '械': 4256, '✈': 4257, '嗓': 4258, '斥': 4259, '【': 4260, '紐': 4261, '罪': 4262, '皈': 4263, '长': 4264, '仇': 4265, '捭': 4266, '猜': 4267, 'm': 4268, '罩': 4269, '逾': 4270, '宜': 4271, '光': 4272, '后': 4273, '撑': 4274, '剖': 4275, '盆': 4276, '️': 4277, '峭': 4278, '牵': 4279, '砍': 4280, '沂': 4281, 'れ': 4282, '樊': 4283, '贺': 4284, '略': 4285, '🇳': 4286, '—': 4287, '吓': 4288, '拣': 4289, '亵': 4290, '静': 4291, '谴': 4292, '鬧': 4293, '論': 4294, '耿': 4295, '护': 4296, '苦': 4297, '艾': 4298, '∠': 4299, '猝': 4300, 'P': 4301, '黄': 4302, '君': 4303, 'こ': 4304, '弛': 4305, '恙': 4306, '笼': 4307, '柬': 4308, '猛': 4309, '酯': 4310, '划': 4311, '肖': 4312, '撬': 4313, '郫': 4314, '~': 4315, '缸': 4316, '種': 4317, '崭': 4318, '毗': 4319, '薯': 4320, '粪': 4321, '俭': 4322, '篷': 4323, '萤': 4324, '標': 4325, '糖': 4326, '裆': 4327, '熬': 4328, '一': 4329, '库': 4330, '▲': 4331, '冥': 4332, '锁': 4333, '俘': 4334, '抢': 4335, '征': 4336, '玫': 4337, '厲': 4338, '芯': 4339, '众': 4340, '吗': 4341, '歧': 4342, '楊': 4343, '篱': 4344, '夹': 4345, '悴': 4346, ';': 4347, '菁': 4348, '示': 4349, '衍': 4350, '抽': 4351, '纯': 4352, '您': 4353, '答': 4354, '法': 4355, '>': 4356, '窜': 4357, '坎': 4358, '柠': 4359, 'ら': 4360, '給': 4361, '♥': 4362, '噪': 4363, '⚫': 4364, '枕': 4365, '榆': 4366, '樂': 4367, '气': 4368, '末': 4369, '這': 4370, '矿': 4371, '員': 4372, '蚤': 4373, '梯': 4374, '通': 4375, '脆': 4376, '聲': 4377, '0': 4378, '弹': 4379, '怖': 4380, '俨': 4381, '域': 4382, '冉': 4383, '痹': 4384, '府': 4385, '啡': 4386, '绽': 4387, '頒': 4388, '辦': 4389, '发': 4390, '碌': 4391, '社': 4392, '🚬': 4393, '渗': 4394, '珠': 4395, '兄': 4396, '鸿': 4397, '哺': 4398, '俯': 4399, '妇': 4400, '蒙': 4401, '幢': 4402, '叽': 4403, '幡': 4404, '鎖': 4405, '安': 4406, '作': 4407, '情': 4408, '': 4409}
diff --git a/modules/text/text_generation/Rumor_prediction/module.py b/modules/text/text_generation/Rumor_prediction/module.py
index 24799f1d..f6f5a01a 100644
--- a/modules/text/text_generation/Rumor_prediction/module.py
+++ b/modules/text/text_generation/Rumor_prediction/module.py
@@ -27,12 +27,12 @@ import numpy as np
import paddle
import paddlehub as hub
+
@moduleinfo(
name="Rumor_prediction",
version="1.0.0",
type="nlp/semantic_model",
- summary=
- "Is the input text prediction a rumor",
+ summary="Is the input text prediction a rumor",
author="彭兆帅,郑博培",
author_email="1084667371@qq.com,2733821739@qq.com")
class Rumorprediction(hub.Module):
@@ -42,7 +42,7 @@ class Rumorprediction(hub.Module):
"""
# 加载模型路径
self.default_pretrained_model_path = os.path.join(self.directory, "infer_model")
-
+
def Rumor(self, texts, use_gpu=False):
"""
Get the input and program of the infer model
@@ -51,6 +51,7 @@ class Rumorprediction(hub.Module):
image (list(numpy.ndarray)): images data, shape of each is [H, W, C], the color space is BGR.
use_gpu(bool): Weather to use gpu
"""
+
# 获取数据
def get_data(sentence):
# 读取数据字典
@@ -66,6 +67,7 @@ class Rumorprediction(hub.Module):
s = ''
data.append(int(dict_txt[s]))
return data
+
data = []
for text in texts:
text = get_data(text)
@@ -75,16 +77,14 @@ class Rumorprediction(hub.Module):
place = paddle.CUDAPlace(0) if use_gpu else paddle.CPUPlace()
exe = paddle.static.Executor(place)
exe.run(paddle.static.default_startup_program())
- [infer_program, feeded_var_names, target_var] = paddle.fluid.io.load_inference_model(dirname=self.default_pretrained_model_path, executor=exe)
+ [infer_program, feeded_var_names, target_var] = paddle.fluid.io.load_inference_model(
+ dirname=self.default_pretrained_model_path, executor=exe)
# 生成预测数据
tensor_words = paddle.fluid.create_lod_tensor(data, base_shape, place)
# 执行预测
- result = exe.run(program=infer_program,
- feed={feeded_var_names[0]: tensor_words},
- fetch_list=target_var)
+ result = exe.run(program=infer_program, feed={feeded_var_names[0]: tensor_words}, fetch_list=target_var)
# 分类名称
- names = [ '谣言', '非谣言']
-
+ names = ['谣言', '非谣言']
results = []
@@ -93,36 +93,25 @@ class Rumorprediction(hub.Module):
content = texts[i]
lab = np.argsort(result)[0][i][-1]
- alltext = {
- 'content': content,
- 'prediction': names[lab],
- 'probability': result[0][i][lab]
- }
+ alltext = {'content': content, 'prediction': names[lab], 'probability': result[0][i][lab]}
alltext = [alltext]
results = results + alltext
-
+
return results
-
def add_module_config_arg(self):
"""
Add the command config options
"""
self.arg_config_group.add_argument(
- '--use_gpu',
- type=ast.literal_eval,
- default=False,
- help="whether use GPU for prediction")
+ '--use_gpu', type=ast.literal_eval, default=False, help="whether use GPU for prediction")
def add_module_input_arg(self):
"""
Add the command input options
"""
- self.arg_input_group.add_argument(
- '--input_text',
- type=str,
- default=None,
- help="input_text is str")
+ self.arg_input_group.add_argument('--input_text', type=str, default=None, help="input_text is str")
+
@runnable
def run_cmd(self, argvs):
"""
@@ -134,19 +123,15 @@ class Rumorprediction(hub.Module):
usage='%(prog)s',
add_help=True)
- self.arg_input_group = self.parser.add_argument_group(
- title="Input options", description="Input data. Required")
+ self.arg_input_group = self.parser.add_argument_group(title="Input options", description="Input data. Required")
self.arg_config_group = self.parser.add_argument_group(
- title="Config options",
- description=
- "Run configuration for controlling module behavior, optional.")
+ title="Config options", description="Run configuration for controlling module behavior, optional.")
self.add_module_config_arg()
self.add_module_input_arg()
args = self.parser.parse_args(argvs)
input_text = [args.input_text]
- results = self.Rumor(
- texts=input_text, use_gpu=args.use_gpu)
+ results = self.Rumor(texts=input_text, use_gpu=args.use_gpu)
return results
diff --git a/modules/text/text_generation/ernie_gen_leave/model/decode.py b/modules/text/text_generation/ernie_gen_leave/model/decode.py
index a42bfee1..d07a58b5 100644
--- a/modules/text/text_generation/ernie_gen_leave/model/decode.py
+++ b/modules/text/text_generation/ernie_gen_leave/model/decode.py
@@ -23,23 +23,14 @@ import paddle.fluid.dygraph as D
def gen_bias(encoder_inputs, decoder_inputs, step):
decoder_bsz, decoder_seqlen = decoder_inputs.shape[:2]
- attn_bias = L.reshape(
- L.range(0, decoder_seqlen, 1, dtype='float32') + 1, [1, -1, 1])
- decoder_bias = L.cast(
- (L.matmul(attn_bias, 1. / attn_bias, transpose_y=True) >= 1.),
- 'float32') #[1, 1, decoderlen, decoderlen]
- encoder_bias = L.unsqueeze(
- L.cast(L.ones_like(encoder_inputs), 'float32'),
- [1]) #[bsz, 1, encoderlen]
- encoder_bias = L.expand(
- encoder_bias, [1, decoder_seqlen, 1]) #[bsz,decoderlen, encoderlen]
- decoder_bias = L.expand(decoder_bias,
- [decoder_bsz, 1, 1]) #[bsz, decoderlen, decoderlen]
+ attn_bias = L.reshape(L.range(0, decoder_seqlen, 1, dtype='float32') + 1, [1, -1, 1])
+ decoder_bias = L.cast((L.matmul(attn_bias, 1. / attn_bias, transpose_y=True) >= 1.),
+ 'float32') #[1, 1, decoderlen, decoderlen]
+ encoder_bias = L.unsqueeze(L.cast(L.ones_like(encoder_inputs), 'float32'), [1]) #[bsz, 1, encoderlen]
+ encoder_bias = L.expand(encoder_bias, [1, decoder_seqlen, 1]) #[bsz,decoderlen, encoderlen]
+ decoder_bias = L.expand(decoder_bias, [decoder_bsz, 1, 1]) #[bsz, decoderlen, decoderlen]
if step > 0:
- bias = L.concat([
- encoder_bias,
- L.ones([decoder_bsz, decoder_seqlen, step], 'float32'), decoder_bias
- ], -1)
+ bias = L.concat([encoder_bias, L.ones([decoder_bsz, decoder_seqlen, step], 'float32'), decoder_bias], -1)
else:
bias = L.concat([encoder_bias, decoder_bias], -1)
return bias
@@ -71,27 +62,16 @@ def greedy_search_infilling(model,
ids = L.stack([cls_ids, attn_ids], -1)
for step in range(max_decode_len):
bias = gen_bias(q_ids, ids, step)
- pos_ids = D.to_variable(
- np.tile(np.array([[step, step + 1]], dtype=np.int64), [d_batch, 1]))
+ pos_ids = D.to_variable(np.tile(np.array([[step, step + 1]], dtype=np.int64), [d_batch, 1]))
pos_ids += seqlen
_, logits, info = model(
- ids,
- L.ones_like(ids) * tgt_type_id,
- pos_ids=pos_ids,
- attn_bias=bias,
- past_cache=past_cache)
+ ids, L.ones_like(ids) * tgt_type_id, pos_ids=pos_ids, attn_bias=bias, past_cache=past_cache)
gen_ids = L.argmax(logits, -1)
past_cached_k, past_cached_v = past_cache
cached_k, cached_v = info['caches']
- cached_k = [
- L.concat([pk, k[:, :1, :]], 1)
- for pk, k in zip(past_cached_k, cached_k)
- ] # concat cached
- cached_v = [
- L.concat([pv, v[:, :1, :]], 1)
- for pv, v in zip(past_cached_v, cached_v)
- ]
+ cached_k = [L.concat([pk, k[:, :1, :]], 1) for pk, k in zip(past_cached_k, cached_k)] # concat cached
+ cached_v = [L.concat([pv, v[:, :1, :]], 1) for pv, v in zip(past_cached_v, cached_v)]
past_cache = (cached_k, cached_v)
gen_ids = gen_ids[:, 1]
@@ -107,10 +87,8 @@ def greedy_search_infilling(model,
return output_ids
-BeamSearchState = namedtuple('BeamSearchState',
- ['log_probs', 'lengths', 'finished'])
-BeamSearchOutput = namedtuple('BeamSearchOutput',
- ['scores', 'predicted_ids', 'beam_parent_ids'])
+BeamSearchState = namedtuple('BeamSearchState', ['log_probs', 'lengths', 'finished'])
+BeamSearchOutput = namedtuple('BeamSearchOutput', ['scores', 'predicted_ids', 'beam_parent_ids'])
def log_softmax(x):
@@ -120,8 +98,7 @@ def log_softmax(x):
def mask_prob(p, onehot_eos, finished):
is_finished = L.cast(L.reshape(finished, [-1, 1]) != 0, 'float32')
- p = is_finished * (1. - L.cast(onehot_eos, 'float32')) * -9999. + (
- 1. - is_finished) * p
+ p = is_finished * (1. - L.cast(onehot_eos, 'float32')) * -9999. + (1. - is_finished) * p
return p
@@ -130,8 +107,7 @@ def hyp_score(log_probs, length, length_penalty):
return log_probs / lp
-def beam_search_step(state, logits, eos_id, beam_width, is_first_step,
- length_penalty):
+def beam_search_step(state, logits, eos_id, beam_width, is_first_step, length_penalty):
"""logits.shape == [B*W, V]"""
beam_size, vocab_size = logits.shape # as batch size=1 in this hub module. the first dim means bsz * beam_size equals beam_size
logits_np = logits.numpy()
@@ -140,8 +116,7 @@ def beam_search_step(state, logits, eos_id, beam_width, is_first_step,
logits = D.to_variable(logits_np)
bsz, beam_width = state.log_probs.shape
- onehot_eos = L.cast(
- F.one_hot(L.ones([1], 'int64') * eos_id, vocab_size), 'int64') #[1, V]
+ onehot_eos = L.cast(F.one_hot(L.ones([1], 'int64') * eos_id, vocab_size), 'int64') #[1, V]
probs = L.log(L.softmax(logits)) #[B*W, V]
probs = mask_prob(probs, onehot_eos, state.finished) #[B*W, V]
@@ -156,32 +131,24 @@ def beam_search_step(state, logits, eos_id, beam_width, is_first_step,
alllen = L.reshape(alllen, [-1, beam_width * vocab_size])
allscore = hyp_score(allprobs, alllen, length_penalty)
if is_first_step:
- allscore = L.reshape(
- allscore,
- [bsz, beam_width, -1])[:, 0, :] # first step only consiter beam 0
+ allscore = L.reshape(allscore, [bsz, beam_width, -1])[:, 0, :] # first step only consiter beam 0
scores, idx = L.topk(allscore, k=beam_width) #[B, W]
next_beam_id = idx // vocab_size #[B, W]
next_word_id = idx % vocab_size
- gather_idx = L.concat([L.where(idx != -1)[:, :1],
- L.reshape(idx, [-1, 1])], 1)
+ gather_idx = L.concat([L.where(idx != -1)[:, :1], L.reshape(idx, [-1, 1])], 1)
next_probs = L.reshape(L.gather_nd(allprobs, gather_idx), idx.shape)
next_len = L.reshape(L.gather_nd(alllen, gather_idx), idx.shape)
- gather_idx = L.concat(
- [L.where(next_beam_id != -1)[:, :1],
- L.reshape(next_beam_id, [-1, 1])], 1)
- next_finished = L.reshape(
- L.gather_nd(state.finished, gather_idx),
- state.finished.shape) #[gather new beam state according to new beam id]
+ gather_idx = L.concat([L.where(next_beam_id != -1)[:, :1], L.reshape(next_beam_id, [-1, 1])], 1)
+ next_finished = L.reshape(L.gather_nd(state.finished, gather_idx),
+ state.finished.shape) #[gather new beam state according to new beam id]
next_finished += L.cast(next_word_id == eos_id, 'int64')
next_finished = L.cast(next_finished > 0, 'int64')
- next_state = BeamSearchState(
- log_probs=next_probs, lengths=next_len, finished=next_finished)
- output = BeamSearchOutput(
- scores=scores, predicted_ids=next_word_id, beam_parent_ids=next_beam_id)
+ next_state = BeamSearchState(log_probs=next_probs, lengths=next_len, finished=next_finished)
+ output = BeamSearchOutput(scores=scores, predicted_ids=next_word_id, beam_parent_ids=next_beam_id)
return output, next_state
@@ -210,22 +177,20 @@ def beam_search_infilling(model,
def reorder_(t, parent_id):
"""reorder cache according to parent beam id"""
- gather_idx = L.where(parent_id != -1)[:, 0] * beam_width + L.reshape(
- parent_id, [-1])
+ gather_idx = L.where(parent_id != -1)[:, 0] * beam_width + L.reshape(parent_id, [-1])
t = L.gather(t, gather_idx)
return t
def tile_(t, times):
_shapes = list(t.shape[1:])
- ret = L.reshape(
- L.expand(L.unsqueeze(t, [1]), [
- 1,
- times,
- ] + [
- 1,
- ] * len(_shapes)), [
- -1,
- ] + _shapes)
+ ret = L.reshape(L.expand(L.unsqueeze(t, [1]), [
+ 1,
+ times,
+ ] + [
+ 1,
+ ] * len(_shapes)), [
+ -1,
+ ] + _shapes)
return ret
cached_k, cached_v = info['caches']
@@ -241,18 +206,11 @@ def beam_search_infilling(model,
ids = L.stack([cls_ids, attn_ids], -1)
for step in range(max_decode_len):
bias = gen_bias(q_ids, ids, step)
- pos_ids = D.to_variable(
- np.tile(
- np.array([[step, step + 1]], dtype=np.int64),
- [d_batch * beam_width, 1]))
+ pos_ids = D.to_variable(np.tile(np.array([[step, step + 1]], dtype=np.int64), [d_batch * beam_width, 1]))
pos_ids += seqlen
_, logits, info = model(
- ids,
- L.ones_like(ids) * tgt_type_id,
- pos_ids=pos_ids,
- attn_bias=bias,
- past_cache=past_cache)
+ ids, L.ones_like(ids) * tgt_type_id, pos_ids=pos_ids, attn_bias=bias, past_cache=past_cache)
output, state = beam_search_step(
state,
@@ -266,17 +224,14 @@ def beam_search_infilling(model,
past_cached_k, past_cached_v = past_cache
cached_k, cached_v = info['caches']
cached_k = [
- reorder_(L.concat([pk, k[:, :1, :]], 1), output.beam_parent_ids)
- for pk, k in zip(past_cached_k, cached_k)
+ reorder_(L.concat([pk, k[:, :1, :]], 1), output.beam_parent_ids) for pk, k in zip(past_cached_k, cached_k)
] # concat cached
cached_v = [
- reorder_(L.concat([pv, v[:, :1, :]], 1), output.beam_parent_ids)
- for pv, v in zip(past_cached_v, cached_v)
+ reorder_(L.concat([pv, v[:, :1, :]], 1), output.beam_parent_ids) for pv, v in zip(past_cached_v, cached_v)
]
past_cache = (cached_k, cached_v)
- pred_ids_flatten = L.reshape(output.predicted_ids,
- [d_batch * beam_width])
+ pred_ids_flatten = L.reshape(output.predicted_ids, [d_batch * beam_width])
ids = L.stack([pred_ids_flatten, attn_ids], 1)
if state.finished.numpy().all():
@@ -286,8 +241,7 @@ def beam_search_infilling(model,
final_parent_ids = L.stack([o.beam_parent_ids for o in outputs], 0)
final_ids = L.gather_tree(final_ids, final_parent_ids) #[:, :,
#0] #pick best beam
- final_ids = L.transpose(
- L.reshape(final_ids, [-1, d_batch * 1, beam_width]), [1, 2, 0])
+ final_ids = L.transpose(L.reshape(final_ids, [-1, d_batch * 1, beam_width]), [1, 2, 0])
return final_ids
diff --git a/modules/text/text_generation/ernie_gen_leave/model/file_utils.py b/modules/text/text_generation/ernie_gen_leave/model/file_utils.py
index 613a5213..608be4ef 100644
--- a/modules/text/text_generation/ernie_gen_leave/model/file_utils.py
+++ b/modules/text/text_generation/ernie_gen_leave/model/file_utils.py
@@ -27,10 +27,7 @@ def _fetch_from_remote(url, force_download=False):
r = requests.get(url, stream=True)
total_len = int(r.headers.get('content-length'))
for chunk in tqdm(
- r.iter_content(chunk_size=1024),
- total=total_len // 1024,
- desc='downloading %s' % url,
- unit='KB'):
+ r.iter_content(chunk_size=1024), total=total_len // 1024, desc='downloading %s' % url, unit='KB'):
if chunk:
f.write(chunk)
f.flush()
diff --git a/modules/text/text_generation/ernie_gen_leave/model/modeling_ernie.py b/modules/text/text_generation/ernie_gen_leave/model/modeling_ernie.py
index 7c2304f6..d5de28a5 100644
--- a/modules/text/text_generation/ernie_gen_leave/model/modeling_ernie.py
+++ b/modules/text/text_generation/ernie_gen_leave/model/modeling_ernie.py
@@ -30,9 +30,7 @@ def _build_linear(n_in, n_out, name, init, act=None):
return D.Linear(
n_in,
n_out,
- param_attr=F.ParamAttr(
- name='%s.w_0' % name if name is not None else None,
- initializer=init),
+ param_attr=F.ParamAttr(name='%s.w_0' % name if name is not None else None, initializer=init),
bias_attr='%s.b_0' % name if name is not None else None,
act=act)
@@ -41,11 +39,9 @@ def _build_ln(n_in, name):
return D.LayerNorm(
normalized_shape=n_in,
param_attr=F.ParamAttr(
- name='%s_layer_norm_scale' % name if name is not None else None,
- initializer=F.initializer.Constant(1.)),
+ name='%s_layer_norm_scale' % name if name is not None else None, initializer=F.initializer.Constant(1.)),
bias_attr=F.ParamAttr(
- name='%s_layer_norm_bias' % name if name is not None else None,
- initializer=F.initializer.Constant(1.)),
+ name='%s_layer_norm_bias' % name if name is not None else None, initializer=F.initializer.Constant(1.)),
)
@@ -61,25 +57,18 @@ def append_name(name, postfix):
class AttentionLayer(D.Layer):
def __init__(self, cfg, name=None):
super(AttentionLayer, self).__init__()
- initializer = F.initializer.TruncatedNormal(
- scale=cfg['initializer_range'])
+ initializer = F.initializer.TruncatedNormal(scale=cfg['initializer_range'])
d_model = cfg['hidden_size']
n_head = cfg['num_attention_heads']
assert d_model % n_head == 0
- d_model_q = cfg.get('query_hidden_size_per_head',
- d_model // n_head) * n_head
- d_model_v = cfg.get('value_hidden_size_per_head',
- d_model // n_head) * n_head
+ d_model_q = cfg.get('query_hidden_size_per_head', d_model // n_head) * n_head
+ d_model_v = cfg.get('value_hidden_size_per_head', d_model // n_head) * n_head
self.n_head = n_head
self.d_key = d_model_q // n_head
- self.q = _build_linear(d_model, d_model_q, append_name(
- name, 'query_fc'), initializer)
- self.k = _build_linear(d_model, d_model_q, append_name(name, 'key_fc'),
- initializer)
- self.v = _build_linear(d_model, d_model_v, append_name(
- name, 'value_fc'), initializer)
- self.o = _build_linear(d_model_v, d_model, append_name(
- name, 'output_fc'), initializer)
+ self.q = _build_linear(d_model, d_model_q, append_name(name, 'query_fc'), initializer)
+ self.k = _build_linear(d_model, d_model_q, append_name(name, 'key_fc'), initializer)
+ self.v = _build_linear(d_model, d_model_v, append_name(name, 'value_fc'), initializer)
+ self.o = _build_linear(d_model_v, d_model, append_name(name, 'output_fc'), initializer)
self.dropout = lambda i: L.dropout(
i,
dropout_prob=cfg['attention_probs_dropout_prob'],
@@ -99,15 +88,12 @@ class AttentionLayer(D.Layer):
k = L.concat([cached_k, k], 1)
v = L.concat([cached_v, v], 1)
- q = L.transpose(
- L.reshape(q, [0, 0, self.n_head, q.shape[-1] // self.n_head]),
- [0, 2, 1, 3]) #[batch, head, seq, dim]
- k = L.transpose(
- L.reshape(k, [0, 0, self.n_head, k.shape[-1] // self.n_head]),
- [0, 2, 1, 3]) #[batch, head, seq, dim]
- v = L.transpose(
- L.reshape(v, [0, 0, self.n_head, v.shape[-1] // self.n_head]),
- [0, 2, 1, 3]) #[batch, head, seq, dim]
+ q = L.transpose(L.reshape(q, [0, 0, self.n_head, q.shape[-1] // self.n_head]),
+ [0, 2, 1, 3]) #[batch, head, seq, dim]
+ k = L.transpose(L.reshape(k, [0, 0, self.n_head, k.shape[-1] // self.n_head]),
+ [0, 2, 1, 3]) #[batch, head, seq, dim]
+ v = L.transpose(L.reshape(v, [0, 0, self.n_head, v.shape[-1] // self.n_head]),
+ [0, 2, 1, 3]) #[batch, head, seq, dim]
q = L.scale(q, scale=self.d_key**-0.5)
score = L.matmul(q, k, transpose_y=True)
@@ -127,19 +113,12 @@ class AttentionLayer(D.Layer):
class PositionwiseFeedForwardLayer(D.Layer):
def __init__(self, cfg, name=None):
super(PositionwiseFeedForwardLayer, self).__init__()
- initializer = F.initializer.TruncatedNormal(
- scale=cfg['initializer_range'])
+ initializer = F.initializer.TruncatedNormal(scale=cfg['initializer_range'])
d_model = cfg['hidden_size']
d_ffn = cfg.get('intermediate_size', 4 * d_model)
assert cfg['hidden_act'] in ['relu', 'gelu']
- self.i = _build_linear(
- d_model,
- d_ffn,
- append_name(name, 'fc_0'),
- initializer,
- act=cfg['hidden_act'])
- self.o = _build_linear(d_ffn, d_model, append_name(name, 'fc_1'),
- initializer)
+ self.i = _build_linear(d_model, d_ffn, append_name(name, 'fc_0'), initializer, act=cfg['hidden_act'])
+ self.o = _build_linear(d_ffn, d_model, append_name(name, 'fc_1'), initializer)
prob = cfg.get('intermediate_dropout_prob', 0.)
self.dropout = lambda i: L.dropout(
i,
@@ -158,14 +137,11 @@ class ErnieBlock(D.Layer):
def __init__(self, cfg, name=None):
super(ErnieBlock, self).__init__()
d_model = cfg['hidden_size']
- initializer = F.initializer.TruncatedNormal(
- scale=cfg['initializer_range'])
+ initializer = F.initializer.TruncatedNormal(scale=cfg['initializer_range'])
- self.attn = AttentionLayer(
- cfg, name=append_name(name, 'multi_head_att'))
+ self.attn = AttentionLayer(cfg, name=append_name(name, 'multi_head_att'))
self.ln1 = _build_ln(d_model, name=append_name(name, 'post_att'))
- self.ffn = PositionwiseFeedForwardLayer(
- cfg, name=append_name(name, 'ffn'))
+ self.ffn = PositionwiseFeedForwardLayer(cfg, name=append_name(name, 'ffn'))
self.ln2 = _build_ln(d_model, name=append_name(name, 'post_ffn'))
prob = cfg.get('intermediate_dropout_prob', cfg['hidden_dropout_prob'])
self.dropout = lambda i: L.dropout(
@@ -175,9 +151,7 @@ class ErnieBlock(D.Layer):
) if self.training else i
def forward(self, inputs, attn_bias=None, past_cache=None):
- attn_out, cache = self.attn(
- inputs, inputs, inputs, attn_bias,
- past_cache=past_cache) #self attn
+ attn_out, cache = self.attn(inputs, inputs, inputs, attn_bias, past_cache=past_cache) #self attn
attn_out = self.dropout(attn_out)
hidden = attn_out + inputs
hidden = self.ln1(hidden) # dropout/ add/ norm
@@ -193,17 +167,13 @@ class ErnieEncoderStack(D.Layer):
def __init__(self, cfg, name=None):
super(ErnieEncoderStack, self).__init__()
n_layers = cfg['num_hidden_layers']
- self.block = D.LayerList([
- ErnieBlock(cfg, append_name(name, 'layer_%d' % i))
- for i in range(n_layers)
- ])
+ self.block = D.LayerList([ErnieBlock(cfg, append_name(name, 'layer_%d' % i)) for i in range(n_layers)])
def forward(self, inputs, attn_bias=None, past_cache=None):
if past_cache is not None:
assert isinstance(
- past_cache, tuple
- ), 'unknown type of `past_cache`, expect tuple or list. got %s' % repr(
- type(past_cache))
+ past_cache,
+ tuple), 'unknown type of `past_cache`, expect tuple or list. got %s' % repr(type(past_cache))
past_cache = list(zip(*past_cache))
else:
past_cache = [None] * len(self.block)
@@ -233,24 +203,18 @@ class ErnieModel(D.Layer):
d_sent = cfg.get("sent_type_vocab_size") or cfg['type_vocab_size']
self.n_head = cfg['num_attention_heads']
self.return_additional_info = cfg.get('return_additional_info', False)
- initializer = F.initializer.TruncatedNormal(
- scale=cfg['initializer_range'])
+ initializer = F.initializer.TruncatedNormal(scale=cfg['initializer_range'])
self.ln = _build_ln(d_model, name=append_name(name, 'pre_encoder'))
self.word_emb = D.Embedding([d_vocab, d_emb],
param_attr=F.ParamAttr(
- name=append_name(
- name, 'word_embedding'),
- initializer=initializer))
+ name=append_name(name, 'word_embedding'), initializer=initializer))
self.pos_emb = D.Embedding([d_pos, d_emb],
param_attr=F.ParamAttr(
- name=append_name(name, 'pos_embedding'),
- initializer=initializer))
+ name=append_name(name, 'pos_embedding'), initializer=initializer))
self.sent_emb = D.Embedding([d_sent, d_emb],
param_attr=F.ParamAttr(
- name=append_name(
- name, 'sent_embedding'),
- initializer=initializer))
+ name=append_name(name, 'sent_embedding'), initializer=initializer))
prob = cfg['hidden_dropout_prob']
self.dropout = lambda i: L.dropout(
i,
@@ -258,15 +222,10 @@ class ErnieModel(D.Layer):
dropout_implementation="upscale_in_train",
) if self.training else i
- self.encoder_stack = ErnieEncoderStack(cfg, append_name(
- name, 'encoder'))
+ self.encoder_stack = ErnieEncoderStack(cfg, append_name(name, 'encoder'))
if cfg.get('has_pooler', True):
self.pooler = _build_linear(
- cfg['hidden_size'],
- cfg['hidden_size'],
- append_name(name, 'pooled_fc'),
- initializer,
- act='tanh')
+ cfg['hidden_size'], cfg['hidden_size'], append_name(name, 'pooled_fc'), initializer, act='tanh')
else:
self.pooler = None
self.train()
@@ -317,10 +276,7 @@ class ErnieModel(D.Layer):
encoded(`Variable` of shape `[batch_size, seq_len, hidden_size]`):
output logits of transformer stack
"""
- assert len(
- src_ids.shape
- ) == 2, 'expect src_ids.shape = [batch, sequecen], got %s' % (repr(
- src_ids.shape))
+ assert len(src_ids.shape) == 2, 'expect src_ids.shape = [batch, sequecen], got %s' % (repr(src_ids.shape))
assert attn_bias is not None if past_cache else True, 'if `past_cache` is specified; attn_bias should not be None'
d_batch = L.shape(src_ids)[0]
d_seqlen = L.shape(src_ids)[1]
@@ -334,21 +290,14 @@ class ErnieModel(D.Layer):
input_mask = L.unsqueeze(input_mask, axes=[-1])
attn_bias = L.matmul(input_mask, input_mask, transpose_y=True)
if use_causal_mask:
- sequence = L.reshape(
- L.range(0, d_seqlen, 1, dtype='float32') + 1.,
- [1, 1, -1, 1])
- causal_mask = L.cast(
- (L.matmul(sequence, 1. / sequence, transpose_y=True) >= 1.),
- 'float32')
+ sequence = L.reshape(L.range(0, d_seqlen, 1, dtype='float32') + 1., [1, 1, -1, 1])
+ causal_mask = L.cast((L.matmul(sequence, 1. / sequence, transpose_y=True) >= 1.), 'float32')
attn_bias *= causal_mask
else:
- assert len(
- attn_bias.shape
- ) == 3, 'expect attn_bias tobe rank 3, got %r' % attn_bias.shape
+ assert len(attn_bias.shape) == 3, 'expect attn_bias tobe rank 3, got %r' % attn_bias.shape
attn_bias = (1. - attn_bias) * -10000.0
attn_bias = L.unsqueeze(attn_bias, [1])
- attn_bias = L.expand(attn_bias,
- [1, self.n_head, 1, 1]) # avoid broadcast =_=
+ attn_bias = L.expand(attn_bias, [1, self.n_head, 1, 1]) # avoid broadcast =_=
attn_bias.stop_gradient = True
if sent_ids is None:
@@ -361,8 +310,7 @@ class ErnieModel(D.Layer):
embedded = self.dropout(self.ln(embedded))
- encoded, hidden_list, cache_list = self.encoder_stack(
- embedded, attn_bias, past_cache=past_cache)
+ encoded, hidden_list, cache_list = self.encoder_stack(embedded, attn_bias, past_cache=past_cache)
if self.pooler is not None:
pooled = self.pooler(encoded[:, 0, :])
else:
diff --git a/modules/text/text_generation/ernie_gen_leave/model/modeling_ernie_gen.py b/modules/text/text_generation/ernie_gen_leave/model/modeling_ernie_gen.py
index 88f29c79..bc3d783d 100644
--- a/modules/text/text_generation/ernie_gen_leave/model/modeling_ernie_gen.py
+++ b/modules/text/text_generation/ernie_gen_leave/model/modeling_ernie_gen.py
@@ -24,25 +24,18 @@ class ErnieModelForGeneration(ErnieModel):
cfg['return_additional_info'] = True
cfg['has_pooler'] = False
super(ErnieModelForGeneration, self).__init__(cfg, name=name)
- initializer = F.initializer.TruncatedNormal(
- scale=cfg['initializer_range'])
+ initializer = F.initializer.TruncatedNormal(scale=cfg['initializer_range'])
d_model = cfg['hidden_size']
d_vocab = cfg['vocab_size']
self.mlm = _build_linear(
- d_model,
- d_model,
- append_name(name, 'mask_lm_trans_fc'),
- initializer,
- act=cfg['hidden_act'])
- self.mlm_ln = _build_ln(
- d_model, name=append_name(name, 'mask_lm_trans'))
+ d_model, d_model, append_name(name, 'mask_lm_trans_fc'), initializer, act=cfg['hidden_act'])
+ self.mlm_ln = _build_ln(d_model, name=append_name(name, 'mask_lm_trans'))
self.mlm_bias = L.create_parameter(
dtype='float32',
shape=[d_vocab],
attr=F.ParamAttr(
- name=append_name(name, 'mask_lm_out_fc.b_0'),
- initializer=F.initializer.Constant(value=0.0)),
+ name=append_name(name, 'mask_lm_out_fc.b_0'), initializer=F.initializer.Constant(value=0.0)),
is_bias=True,
)
@@ -56,23 +49,17 @@ class ErnieModelForGeneration(ErnieModel):
elif tgt_labels is None:
encoded = self.mlm(encoded)
encoded = self.mlm_ln(encoded)
- logits = L.matmul(
- encoded, self.word_emb.weight, transpose_y=True) + self.mlm_bias
+ logits = L.matmul(encoded, self.word_emb.weight, transpose_y=True) + self.mlm_bias
output_ids = L.argmax(logits, -1)
return output_ids, logits, info
else:
encoded_2d = L.gather_nd(encoded, tgt_pos)
encoded_2d = self.mlm(encoded_2d)
encoded_2d = self.mlm_ln(encoded_2d)
- logits_2d = L.matmul(
- encoded_2d, self.word_emb.weight,
- transpose_y=True) + self.mlm_bias
+ logits_2d = L.matmul(encoded_2d, self.word_emb.weight, transpose_y=True) + self.mlm_bias
if len(tgt_labels.shape) == 1:
tgt_labels = L.reshape(tgt_labels, [-1, 1])
loss = L.reduce_mean(
- L.softmax_with_cross_entropy(
- logits_2d,
- tgt_labels,
- soft_label=(tgt_labels.shape[-1] != 1)))
+ L.softmax_with_cross_entropy(logits_2d, tgt_labels, soft_label=(tgt_labels.shape[-1] != 1)))
return loss, logits_2d, info
diff --git a/modules/text/text_generation/ernie_gen_leave/model/tokenizing_ernie.py b/modules/text/text_generation/ernie_gen_leave/model/tokenizing_ernie.py
index 3039b702..c9e5638f 100644
--- a/modules/text/text_generation/ernie_gen_leave/model/tokenizing_ernie.py
+++ b/modules/text/text_generation/ernie_gen_leave/model/tokenizing_ernie.py
@@ -77,8 +77,7 @@ class ErnieTokenizer(object):
encoding='utf8',
special_token_list=[]):
if not isinstance(vocab, dict):
- raise ValueError(
- 'expect `vocab` to be instance of dict, got %s' % type(vocab))
+ raise ValueError('expect `vocab` to be instance of dict, got %s' % type(vocab))
self.vocab = vocab
self.lower = lower
self.prefix = wordpiece_prefix
@@ -89,9 +88,7 @@ class ErnieTokenizer(object):
self.unk_id = unk_token and self.vocab[unk_token]
self.mask_id = mask_token and self.vocab[mask_token]
self.unk_token = unk_token
- special_tokens = {
- pad_token, cls_token, sep_token, unk_token, mask_token
- } | set(special_token_list)
+ special_tokens = {pad_token, cls_token, sep_token, unk_token, mask_token} | set(special_token_list)
pat_str = ''
for t in special_tokens:
if t is None:
@@ -135,11 +132,9 @@ class ErnieTokenizer(object):
len2 = len(id2)
half = seqlen // 2
if len1 > len2:
- len1_truncated, len2_truncated = max(half, seqlen - len2), min(
- half, len2)
+ len1_truncated, len2_truncated = max(half, seqlen - len2), min(half, len2)
else:
- len1_truncated, len2_truncated = min(half, seqlen - len1), max(
- half, seqlen - len1)
+ len1_truncated, len2_truncated = min(half, seqlen - len1), max(half, seqlen - len1)
return id1[:len1_truncated], id2[:len2_truncated]
def build_for_ernie(self, text_id, pair_id=[]):
@@ -155,17 +150,14 @@ class ErnieTokenizer(object):
return ret_id, ret_id_type
def encode(self, text, pair=None, truncate_to=None):
- text_id = np.array(
- self.convert_tokens_to_ids(self.tokenize(text)), dtype=np.int64)
+ text_id = np.array(self.convert_tokens_to_ids(self.tokenize(text)), dtype=np.int64)
text_id_type = np.zeros_like(text_id, dtype=np.int64)
if pair is not None:
- pair_id = np.array(
- self.convert_tokens_to_ids(self.tokenize(pair)), dtype=np.int64)
+ pair_id = np.array(self.convert_tokens_to_ids(self.tokenize(pair)), dtype=np.int64)
else:
pair_id = []
if truncate_to is not None:
- text_id, pair_id = self.truncate(
- text_id, [] if pair_id is None else pair_id, truncate_to)
+ text_id, pair_id = self.truncate(text_id, [] if pair_id is None else pair_id, truncate_to)
ret_id, ret_id_type = self.build_for_ernie(text_id, pair_id)
return ret_id, ret_id_type
diff --git a/modules/text/text_generation/ernie_gen_leave/module.py b/modules/text/text_generation/ernie_gen_leave/module.py
index 24aefe24..04d5d733 100644
--- a/modules/text/text_generation/ernie_gen_leave/module.py
+++ b/modules/text/text_generation/ernie_gen_leave/module.py
@@ -35,8 +35,7 @@ from .model.modeling_ernie_gen import ErnieModelForGeneration
@moduleinfo(
name="ernie_gen_leave",
version="1.0.0",
- summary=
- "",
+ summary="",
author="彭兆帅,郑博培",
author_email="1084667371@qq.com,2733821739@qq.com",
type="nlp/text_generation",
@@ -53,10 +52,7 @@ class ErnieGen(hub.NLPPredictionModule):
ernie_cfg = dict(json.loads(ernie_cfg_file.read()))
ernie_vocab_path = os.path.join(assets_path, 'vocab.txt')
with open(ernie_vocab_path, encoding='utf8') as ernie_vocab_file:
- ernie_vocab = {
- j.strip().split('\t')[0]: i
- for i, j in enumerate(ernie_vocab_file.readlines())
- }
+ ernie_vocab = {j.strip().split('\t')[0]: i for i, j in enumerate(ernie_vocab_file.readlines())}
with fluid.dygraph.guard(fluid.CPUPlace()):
with fluid.unique_name.guard():
@@ -83,13 +79,10 @@ class ErnieGen(hub.NLPPredictionModule):
Returns:
results(list): the predict result.
"""
- if texts and isinstance(texts, list) and all(texts) and all(
- [isinstance(text, str) for text in texts]):
+ if texts and isinstance(texts, list) and all(texts) and all([isinstance(text, str) for text in texts]):
predicted_data = texts
else:
- raise ValueError(
- "The input texts should be a list with nonempty string elements."
- )
+ raise ValueError("The input texts should be a list with nonempty string elements.")
if use_gpu and "CUDA_VISIBLE_DEVICES" not in os.environ:
use_gpu = False
@@ -134,13 +127,9 @@ class ErnieGen(hub.NLPPredictionModule):
Add the command config options
"""
self.arg_config_group.add_argument(
- '--use_gpu',
- type=ast.literal_eval,
- default=False,
- help="whether use GPU for prediction")
+ '--use_gpu', type=ast.literal_eval, default=False, help="whether use GPU for prediction")
- self.arg_config_group.add_argument(
- '--beam_width', type=int, default=5, help="the beam search width")
+ self.arg_config_group.add_argument('--beam_width', type=int, default=5, help="the beam search width")
@runnable
def run_cmd(self, argvs):
@@ -153,12 +142,9 @@ class ErnieGen(hub.NLPPredictionModule):
usage='%(prog)s',
add_help=True)
- self.arg_input_group = self.parser.add_argument_group(
- title="Input options", description="Input data. Required")
+ self.arg_input_group = self.parser.add_argument_group(title="Input options", description="Input data. Required")
self.arg_config_group = self.parser.add_argument_group(
- title="Config options",
- description=
- "Run configuration for controlling module behavior, optional.")
+ title="Config options", description="Run configuration for controlling module behavior, optional.")
self.add_module_config_arg()
self.add_module_input_arg()
@@ -171,7 +157,6 @@ class ErnieGen(hub.NLPPredictionModule):
self.parser.print_help()
return None
- results = self.generate(
- texts=input_data, use_gpu=args.use_gpu, beam_width=args.beam_width)
+ results = self.generate(texts=input_data, use_gpu=args.use_gpu, beam_width=args.beam_width)
return results
diff --git a/modules/text/text_generation/ernie_gen_leave/test.py b/modules/text/text_generation/ernie_gen_leave/test.py
index e5b68140..a7abf1b8 100644
--- a/modules/text/text_generation/ernie_gen_leave/test.py
+++ b/modules/text/text_generation/ernie_gen_leave/test.py
@@ -5,4 +5,4 @@ module = hub.Module(name="ernie_gen_leave")
test_texts = ["理由"]
results = module.generate(texts=test_texts, use_gpu=False, beam_width=2)
for result in results:
- print(result)
\ No newline at end of file
+ print(result)
diff --git a/modules/text/text_generation/plato-mini/module.py b/modules/text/text_generation/plato-mini/module.py
index 9e5cde2b..c25f0990 100644
--- a/modules/text/text_generation/plato-mini/module.py
+++ b/modules/text/text_generation/plato-mini/module.py
@@ -46,10 +46,8 @@ class UnifiedTransformer(nn.Layer):
"""
Convert input strings to tokens.
"""
- return self.tokenizer.dialogue_encode(texts,
- max_seq_len=max_seq_len,
- add_start_token_as_response=True,
- is_split_into_words=False)
+ return self.tokenizer.dialogue_encode(
+ texts, max_seq_len=max_seq_len, add_start_token_as_response=True, is_split_into_words=False)
def _batchify(self, data: List[List[str]], max_seq_len: int, batch_size: int):
"""
@@ -127,20 +125,21 @@ class UnifiedTransformer(nn.Layer):
early_stopping=False,
num_return_sequences=1):
- ids, scores = self.model.generate(input_ids=input_ids,
- token_type_ids=token_type_ids,
- position_ids=position_ids,
- attention_mask=attention_mask,
- max_length=max_length,
- min_length=min_length,
- decode_strategy=decode_strategy,
- temperature=temperature,
- top_k=top_k,
- top_p=top_p,
- num_beams=num_beams,
- length_penalty=length_penalty,
- early_stopping=early_stopping,
- num_return_sequences=num_return_sequences)
+ ids, scores = self.model.generate(
+ input_ids=input_ids,
+ token_type_ids=token_type_ids,
+ position_ids=position_ids,
+ attention_mask=attention_mask,
+ max_length=max_length,
+ min_length=min_length,
+ decode_strategy=decode_strategy,
+ temperature=temperature,
+ top_k=top_k,
+ top_p=top_p,
+ num_beams=num_beams,
+ length_penalty=length_penalty,
+ early_stopping=early_stopping,
+ num_return_sequences=num_return_sequences)
return ids, scores
@@ -173,11 +172,8 @@ class UnifiedTransformer(nn.Layer):
num_return_sequences = 1 if 'num_return_sequences' not in kwargs\
else kwargs['num_return_sequences']
results.extend(
- select_response(ids,
- scores,
- self.tokenizer,
- num_return_sequences=num_return_sequences,
- keep_space=False))
+ select_response(
+ ids, scores, self.tokenizer, num_return_sequences=num_return_sequences, keep_space=False))
if self._interactive_mode:
self.context.append(results[0].strip())
diff --git a/modules/text/text_generation/unified_transformer-12L-cn-luge/module.py b/modules/text/text_generation/unified_transformer-12L-cn-luge/module.py
index 3124370f..e6bb87f5 100644
--- a/modules/text/text_generation/unified_transformer-12L-cn-luge/module.py
+++ b/modules/text/text_generation/unified_transformer-12L-cn-luge/module.py
@@ -46,10 +46,8 @@ class UnifiedTransformer(nn.Layer):
"""
Convert input strings to tokens.
"""
- return self.tokenizer.dialogue_encode(texts,
- max_seq_len=max_seq_len,
- add_start_token_as_response=True,
- is_split_into_words=False)
+ return self.tokenizer.dialogue_encode(
+ texts, max_seq_len=max_seq_len, add_start_token_as_response=True, is_split_into_words=False)
def _batchify(self, data: List[List[str]], max_seq_len: int, batch_size: int):
"""
@@ -127,20 +125,21 @@ class UnifiedTransformer(nn.Layer):
early_stopping=False,
num_return_sequences=1):
- ids, scores = self.model.generate(input_ids=input_ids,
- token_type_ids=token_type_ids,
- position_ids=position_ids,
- attention_mask=attention_mask,
- max_length=max_length,
- min_length=min_length,
- decode_strategy=decode_strategy,
- temperature=temperature,
- top_k=top_k,
- top_p=top_p,
- num_beams=num_beams,
- length_penalty=length_penalty,
- early_stopping=early_stopping,
- num_return_sequences=num_return_sequences)
+ ids, scores = self.model.generate(
+ input_ids=input_ids,
+ token_type_ids=token_type_ids,
+ position_ids=position_ids,
+ attention_mask=attention_mask,
+ max_length=max_length,
+ min_length=min_length,
+ decode_strategy=decode_strategy,
+ temperature=temperature,
+ top_k=top_k,
+ top_p=top_p,
+ num_beams=num_beams,
+ length_penalty=length_penalty,
+ early_stopping=early_stopping,
+ num_return_sequences=num_return_sequences)
return ids, scores
@@ -173,11 +172,8 @@ class UnifiedTransformer(nn.Layer):
num_return_sequences = 1 if 'num_return_sequences' not in kwargs\
else kwargs['num_return_sequences']
results.extend(
- select_response(ids,
- scores,
- self.tokenizer,
- num_return_sequences=num_return_sequences,
- keep_space=False))
+ select_response(
+ ids, scores, self.tokenizer, num_return_sequences=num_return_sequences, keep_space=False))
if self._interactive_mode:
self.context.append(results[0].strip())
diff --git a/modules/text/text_generation/unified_transformer-12L-cn/module.py b/modules/text/text_generation/unified_transformer-12L-cn/module.py
index 2e81148d..6292921b 100644
--- a/modules/text/text_generation/unified_transformer-12L-cn/module.py
+++ b/modules/text/text_generation/unified_transformer-12L-cn/module.py
@@ -46,10 +46,8 @@ class UnifiedTransformer(nn.Layer):
"""
Convert input strings to tokens.
"""
- return self.tokenizer.dialogue_encode(texts,
- max_seq_len=max_seq_len,
- add_start_token_as_response=True,
- is_split_into_words=False)
+ return self.tokenizer.dialogue_encode(
+ texts, max_seq_len=max_seq_len, add_start_token_as_response=True, is_split_into_words=False)
def _batchify(self, data: List[List[str]], max_seq_len: int, batch_size: int):
"""
@@ -127,20 +125,21 @@ class UnifiedTransformer(nn.Layer):
early_stopping=False,
num_return_sequences=1):
- ids, scores = self.model.generate(input_ids=input_ids,
- token_type_ids=token_type_ids,
- position_ids=position_ids,
- attention_mask=attention_mask,
- max_length=max_length,
- min_length=min_length,
- decode_strategy=decode_strategy,
- temperature=temperature,
- top_k=top_k,
- top_p=top_p,
- num_beams=num_beams,
- length_penalty=length_penalty,
- early_stopping=early_stopping,
- num_return_sequences=num_return_sequences)
+ ids, scores = self.model.generate(
+ input_ids=input_ids,
+ token_type_ids=token_type_ids,
+ position_ids=position_ids,
+ attention_mask=attention_mask,
+ max_length=max_length,
+ min_length=min_length,
+ decode_strategy=decode_strategy,
+ temperature=temperature,
+ top_k=top_k,
+ top_p=top_p,
+ num_beams=num_beams,
+ length_penalty=length_penalty,
+ early_stopping=early_stopping,
+ num_return_sequences=num_return_sequences)
return ids, scores
@@ -173,11 +172,8 @@ class UnifiedTransformer(nn.Layer):
num_return_sequences = 1 if 'num_return_sequences' not in kwargs\
else kwargs['num_return_sequences']
results.extend(
- select_response(ids,
- scores,
- self.tokenizer,
- num_return_sequences=num_return_sequences,
- keep_space=False))
+ select_response(
+ ids, scores, self.tokenizer, num_return_sequences=num_return_sequences, keep_space=False))
if self._interactive_mode:
self.context.append(results[0].strip())
diff --git a/modules/thirdparty/image/classification/DriverStatusRecognition/__init__.py b/modules/thirdparty/image/classification/DriverStatusRecognition/__init__.py
index 8b137891..e69de29b 100644
--- a/modules/thirdparty/image/classification/DriverStatusRecognition/__init__.py
+++ b/modules/thirdparty/image/classification/DriverStatusRecognition/__init__.py
@@ -1 +0,0 @@
-
diff --git a/modules/thirdparty/image/classification/DriverStatusRecognition/module.py b/modules/thirdparty/image/classification/DriverStatusRecognition/module.py
index df06b227..ab129744 100644
--- a/modules/thirdparty/image/classification/DriverStatusRecognition/module.py
+++ b/modules/thirdparty/image/classification/DriverStatusRecognition/module.py
@@ -41,18 +41,10 @@ def read_images(paths):
version='1.0.0')
class MODULE(hub.Module):
def _initialize(self, **kwargs):
- self.default_pretrained_model_path = os.path.join(
- self.directory, 'assets')
- self.model = pdx.deploy.Predictor(self.default_pretrained_model_path,
- **kwargs)
-
- def predict(self,
- images=None,
- paths=None,
- data=None,
- batch_size=1,
- use_gpu=False,
- **kwargs):
+ self.default_pretrained_model_path = os.path.join(self.directory, 'assets')
+ self.model = pdx.deploy.Predictor(self.default_pretrained_model_path, **kwargs)
+
+ def predict(self, images=None, paths=None, data=None, batch_size=1, use_gpu=False, **kwargs):
all_data = images if images is not None else read_images(paths)
total_num = len(all_data)
@@ -110,36 +102,27 @@ class MODULE(hub.Module):
prog='hub run {}'.format(self.name),
usage='%(prog)s',
add_help=True)
- self.arg_input_group = self.parser.add_argument_group(
- title="Input options", description="Input data. Required")
+ self.arg_input_group = self.parser.add_argument_group(title="Input options", description="Input data. Required")
self.arg_config_group = self.parser.add_argument_group(
- title="Config options",
- description=
- "Run configuration for controlling module behavior, not required.")
+ title="Config options", description="Run configuration for controlling module behavior, not required.")
self.add_module_config_arg()
self.add_module_input_arg()
args = self.parser.parse_args(argvs)
- results = self.predict(
- paths=[args.input_path],
- use_gpu=args.use_gpu)
+ results = self.predict(paths=[args.input_path], use_gpu=args.use_gpu)
return results
def add_module_config_arg(self):
"""
Add the command config options.
"""
- self.arg_config_group.add_argument(
- '--use_gpu',
- type=bool,
- default=False,
- help="whether use GPU or not")
+ self.arg_config_group.add_argument('--use_gpu', type=bool, default=False, help="whether use GPU or not")
def add_module_input_arg(self):
"""
Add the command input options.
"""
- self.arg_input_group.add_argument(
- '--input_path', type=str, help="path to image.")
+ self.arg_input_group.add_argument('--input_path', type=str, help="path to image.")
+
if __name__ == '__main__':
module = MODULE(directory='./new_model')
diff --git a/modules/thirdparty/image/classification/SnakeIdentification/__init__.py b/modules/thirdparty/image/classification/SnakeIdentification/__init__.py
index 8b137891..e69de29b 100644
--- a/modules/thirdparty/image/classification/SnakeIdentification/__init__.py
+++ b/modules/thirdparty/image/classification/SnakeIdentification/__init__.py
@@ -1 +0,0 @@
-
diff --git a/modules/thirdparty/image/classification/SnakeIdentification/module.py b/modules/thirdparty/image/classification/SnakeIdentification/module.py
index 3768fa02..e773f8dc 100644
--- a/modules/thirdparty/image/classification/SnakeIdentification/module.py
+++ b/modules/thirdparty/image/classification/SnakeIdentification/module.py
@@ -41,18 +41,10 @@ def read_images(paths):
version='1.0.0')
class MODULE(hub.Module):
def _initialize(self, **kwargs):
- self.default_pretrained_model_path = os.path.join(
- self.directory, 'assets')
- self.model = pdx.deploy.Predictor(self.default_pretrained_model_path,
- **kwargs)
-
- def predict(self,
- images=None,
- paths=None,
- data=None,
- batch_size=1,
- use_gpu=False,
- **kwargs):
+ self.default_pretrained_model_path = os.path.join(self.directory, 'assets')
+ self.model = pdx.deploy.Predictor(self.default_pretrained_model_path, **kwargs)
+
+ def predict(self, images=None, paths=None, data=None, batch_size=1, use_gpu=False, **kwargs):
all_data = images if images is not None else read_images(paths)
total_num = len(all_data)
@@ -110,36 +102,27 @@ class MODULE(hub.Module):
prog='hub run {}'.format(self.name),
usage='%(prog)s',
add_help=True)
- self.arg_input_group = self.parser.add_argument_group(
- title="Input options", description="Input data. Required")
+ self.arg_input_group = self.parser.add_argument_group(title="Input options", description="Input data. Required")
self.arg_config_group = self.parser.add_argument_group(
- title="Config options",
- description=
- "Run configuration for controlling module behavior, not required.")
+ title="Config options", description="Run configuration for controlling module behavior, not required.")
self.add_module_config_arg()
self.add_module_input_arg()
args = self.parser.parse_args(argvs)
- results = self.predict(
- paths=[args.input_path],
- use_gpu=args.use_gpu)
+ results = self.predict(paths=[args.input_path], use_gpu=args.use_gpu)
return results
def add_module_config_arg(self):
"""
Add the command config options.
"""
- self.arg_config_group.add_argument(
- '--use_gpu',
- type=bool,
- default=False,
- help="whether use GPU or not")
+ self.arg_config_group.add_argument('--use_gpu', type=bool, default=False, help="whether use GPU or not")
def add_module_input_arg(self):
"""
Add the command input options.
"""
- self.arg_input_group.add_argument(
- '--input_path', type=str, help="path to image.")
+ self.arg_input_group.add_argument('--input_path', type=str, help="path to image.")
+
if __name__ == '__main__':
module = MODULE(directory='./new_model')
diff --git a/modules/thirdparty/image/classification/SpinalNet_Gemstones/gem_dataset.py b/modules/thirdparty/image/classification/SpinalNet_Gemstones/gem_dataset.py
index 5e77a899..810843ce 100644
--- a/modules/thirdparty/image/classification/SpinalNet_Gemstones/gem_dataset.py
+++ b/modules/thirdparty/image/classification/SpinalNet_Gemstones/gem_dataset.py
@@ -3,16 +3,18 @@ import numpy as np
from typing import Callable
from code.config import config_parameters
+
class GemStones(paddle.io.Dataset):
"""
step 1:paddle.io.Dataset
"""
- def __init__(self, transforms: Callable, mode: str ='train'):
+
+ def __init__(self, transforms: Callable, mode: str = 'train'):
"""
step 2:create reader
"""
super(GemStones, self).__init__()
-
+
self.mode = mode
self.transforms = transforms
@@ -25,15 +27,14 @@ class GemStones(paddle.io.Dataset):
test_data_folder = paddle.vision.DatasetFolder(test_image_dir)
config_parameters['label_dict'] = train_data_folder.class_to_idx
-
- if self.mode == 'train':
+
+ if self.mode == 'train':
self.data = train_data_folder
- elif self.mode == 'eval':
+ elif self.mode == 'eval':
self.data = eval_data_folder
- elif self.mode == 'test':
+ elif self.mode == 'test':
self.data = test_data_folder
-
def __getitem__(self, index):
"""
step 3:implement __getitem__
@@ -43,11 +44,11 @@ class GemStones(paddle.io.Dataset):
data = self.transforms(data)
label = np.array(self.data[index][1]).astype('int64')
-
+
return data, label
def __len__(self):
"""
step 4:implement __len__
"""
- return len(self.data)
\ No newline at end of file
+ return len(self.data)
diff --git a/modules/thirdparty/image/classification/SpinalNet_Gemstones/spinalnet_res101_gemstone/module.py b/modules/thirdparty/image/classification/SpinalNet_Gemstones/spinalnet_res101_gemstone/module.py
index e4a67b7f..318132b3 100755
--- a/modules/thirdparty/image/classification/SpinalNet_Gemstones/spinalnet_res101_gemstone/module.py
+++ b/modules/thirdparty/image/classification/SpinalNet_Gemstones/spinalnet_res101_gemstone/module.py
@@ -43,20 +43,11 @@ class BottleneckBlock(nn.Layer):
self.conv1 = nn.Conv2D(inplanes, width, 1, bias_attr=False)
self.bn1 = norm_layer(width)
- self.conv2 = nn.Conv2D(width,
- width,
- 3,
- padding=dilation,
- stride=stride,
- groups=groups,
- dilation=dilation,
- bias_attr=False)
+ self.conv2 = nn.Conv2D(
+ width, width, 3, padding=dilation, stride=stride, groups=groups, dilation=dilation, bias_attr=False)
self.bn2 = norm_layer(width)
- self.conv3 = nn.Conv2D(width,
- planes * self.expansion,
- 1,
- bias_attr=False)
+ self.conv3 = nn.Conv2D(width, planes * self.expansion, 1, bias_attr=False)
self.bn3 = norm_layer(planes * self.expansion)
self.relu = nn.ReLU()
self.downsample = downsample
@@ -88,13 +79,7 @@ class BottleneckBlock(nn.Layer):
class ResNet(nn.Layer):
def __init__(self, block=BottleneckBlock, depth=101, with_pool=True):
super(ResNet, self).__init__()
- layer_cfg = {
- 18: [2, 2, 2, 2],
- 34: [3, 4, 6, 3],
- 50: [3, 4, 6, 3],
- 101: [3, 4, 23, 3],
- 152: [3, 8, 36, 3]
- }
+ layer_cfg = {18: [2, 2, 2, 2], 34: [3, 4, 6, 3], 50: [3, 4, 6, 3], 101: [3, 4, 23, 3], 152: [3, 8, 36, 3]}
layers = layer_cfg[depth]
self.with_pool = with_pool
self._norm_layer = nn.BatchNorm2D
@@ -102,12 +87,7 @@ class ResNet(nn.Layer):
self.inplanes = 64
self.dilation = 1
- self.conv1 = nn.Conv2D(3,
- self.inplanes,
- kernel_size=7,
- stride=2,
- padding=3,
- bias_attr=False)
+ self.conv1 = nn.Conv2D(3, self.inplanes, kernel_size=7, stride=2, padding=3, bias_attr=False)
self.bn1 = self._norm_layer(self.inplanes)
self.relu = nn.ReLU()
self.maxpool = nn.MaxPool2D(kernel_size=3, stride=2, padding=1)
@@ -127,18 +107,12 @@ class ResNet(nn.Layer):
stride = 1
if stride != 1 or self.inplanes != planes * block.expansion:
downsample = nn.Sequential(
- nn.Conv2D(self.inplanes,
- planes * block.expansion,
- 1,
- stride=stride,
- bias_attr=False),
+ nn.Conv2D(self.inplanes, planes * block.expansion, 1, stride=stride, bias_attr=False),
norm_layer(planes * block.expansion),
)
layers = []
- layers.append(
- block(self.inplanes, planes, stride, downsample, 1, 64,
- previous_dilation, norm_layer))
+ layers.append(block(self.inplanes, planes, stride, downsample, 1, 64, previous_dilation, norm_layer))
self.inplanes = planes * block.expansion
for _ in range(1, blocks):
layers.append(block(self.inplanes, planes, norm_layer=norm_layer))
@@ -161,14 +135,15 @@ class ResNet(nn.Layer):
return x
-@moduleinfo(name="spinalnet_res101_gemstone",
- type="CV/classification",
- author="nanting03",
- author_email="975348977@qq.com",
- summary="spinalnet_res101_gemstone is a classification model, "
- "this module is trained with Gemstone dataset.",
- version="1.0.0",
- meta=ImageClassifierModule)
+@moduleinfo(
+ name="spinalnet_res101_gemstone",
+ type="CV/classification",
+ author="nanting03",
+ author_email="975348977@qq.com",
+ summary="spinalnet_res101_gemstone is a classification model, "
+ "this module is trained with Gemstone dataset.",
+ version="1.0.0",
+ meta=ImageClassifierModule)
class SpinalNet_ResNet101(nn.Layer):
def __init__(self, label_list: list = None, load_checkpoint: str = None):
super(SpinalNet_ResNet101, self).__init__()
@@ -194,20 +169,16 @@ class SpinalNet_ResNet101(nn.Layer):
self.half_in_size = half_in_size
self.fc_spinal_layer1 = nn.Sequential(
- nn.Dropout(p=0.5), nn.Linear(half_in_size, layer_width),
- nn.BatchNorm1D(layer_width), nn.ReLU())
+ nn.Dropout(p=0.5), nn.Linear(half_in_size, layer_width), nn.BatchNorm1D(layer_width), nn.ReLU())
self.fc_spinal_layer2 = nn.Sequential(
- nn.Dropout(p=0.5), nn.Linear(half_in_size + layer_width,
- layer_width),
- nn.BatchNorm1D(layer_width), nn.ReLU())
+ nn.Dropout(p=0.5), nn.Linear(half_in_size + layer_width, layer_width), nn.BatchNorm1D(layer_width),
+ nn.ReLU())
self.fc_spinal_layer3 = nn.Sequential(
- nn.Dropout(p=0.5), nn.Linear(half_in_size + layer_width,
- layer_width),
- nn.BatchNorm1D(layer_width), nn.ReLU())
+ nn.Dropout(p=0.5), nn.Linear(half_in_size + layer_width, layer_width), nn.BatchNorm1D(layer_width),
+ nn.ReLU())
self.fc_spinal_layer4 = nn.Sequential(
- nn.Dropout(p=0.5), nn.Linear(half_in_size + layer_width,
- layer_width),
- nn.BatchNorm1D(layer_width), nn.ReLU())
+ nn.Dropout(p=0.5), nn.Linear(half_in_size + layer_width, layer_width), nn.BatchNorm1D(layer_width),
+ nn.ReLU())
self.fc_out = nn.Sequential(
nn.Dropout(p=0.5),
nn.Linear(layer_width * 4, class_dim),
@@ -219,8 +190,7 @@ class SpinalNet_ResNet101(nn.Layer):
print("load custom checkpoint success")
else:
- checkpoint = os.path.join(self.directory,
- 'spinalnet_res101.pdparams')
+ checkpoint = os.path.join(self.directory, 'spinalnet_res101.pdparams')
self.model_dict = paddle.load(checkpoint)
self.set_dict(self.model_dict)
print("load pretrained checkpoint success")
@@ -240,14 +210,9 @@ class SpinalNet_ResNet101(nn.Layer):
y = paddle.flatten(y, 1)
y1 = self.fc_spinal_layer1(y[:, 0:self.half_in_size])
- y2 = self.fc_spinal_layer2(
- paddle.concat([y[:, self.half_in_size:2 * self.half_in_size], y1],
- axis=1))
- y3 = self.fc_spinal_layer3(
- paddle.concat([y[:, 0:self.half_in_size], y2], axis=1))
- y4 = self.fc_spinal_layer4(
- paddle.concat([y[:, self.half_in_size:2 * self.half_in_size], y3],
- axis=1))
+ y2 = self.fc_spinal_layer2(paddle.concat([y[:, self.half_in_size:2 * self.half_in_size], y1], axis=1))
+ y3 = self.fc_spinal_layer3(paddle.concat([y[:, 0:self.half_in_size], y2], axis=1))
+ y4 = self.fc_spinal_layer4(paddle.concat([y[:, self.half_in_size:2 * self.half_in_size], y3], axis=1))
y = paddle.concat([y1, y2, y3, y4], axis=1)
diff --git a/modules/thirdparty/image/classification/SpinalNet_Gemstones/spinalnet_res50_gemstone/module.py b/modules/thirdparty/image/classification/SpinalNet_Gemstones/spinalnet_res50_gemstone/module.py
index a3ad0e3d..a83ad842 100755
--- a/modules/thirdparty/image/classification/SpinalNet_Gemstones/spinalnet_res50_gemstone/module.py
+++ b/modules/thirdparty/image/classification/SpinalNet_Gemstones/spinalnet_res50_gemstone/module.py
@@ -43,20 +43,11 @@ class BottleneckBlock(nn.Layer):
self.conv1 = nn.Conv2D(inplanes, width, 1, bias_attr=False)
self.bn1 = norm_layer(width)
- self.conv2 = nn.Conv2D(width,
- width,
- 3,
- padding=dilation,
- stride=stride,
- groups=groups,
- dilation=dilation,
- bias_attr=False)
+ self.conv2 = nn.Conv2D(
+ width, width, 3, padding=dilation, stride=stride, groups=groups, dilation=dilation, bias_attr=False)
self.bn2 = norm_layer(width)
- self.conv3 = nn.Conv2D(width,
- planes * self.expansion,
- 1,
- bias_attr=False)
+ self.conv3 = nn.Conv2D(width, planes * self.expansion, 1, bias_attr=False)
self.bn3 = norm_layer(planes * self.expansion)
self.relu = nn.ReLU()
self.downsample = downsample
@@ -88,13 +79,7 @@ class BottleneckBlock(nn.Layer):
class ResNet(nn.Layer):
def __init__(self, block=BottleneckBlock, depth=50, with_pool=True):
super(ResNet, self).__init__()
- layer_cfg = {
- 18: [2, 2, 2, 2],
- 34: [3, 4, 6, 3],
- 50: [3, 4, 6, 3],
- 101: [3, 4, 23, 3],
- 152: [3, 8, 36, 3]
- }
+ layer_cfg = {18: [2, 2, 2, 2], 34: [3, 4, 6, 3], 50: [3, 4, 6, 3], 101: [3, 4, 23, 3], 152: [3, 8, 36, 3]}
layers = layer_cfg[depth]
self.with_pool = with_pool
self._norm_layer = nn.BatchNorm2D
@@ -102,12 +87,7 @@ class ResNet(nn.Layer):
self.inplanes = 64
self.dilation = 1
- self.conv1 = nn.Conv2D(3,
- self.inplanes,
- kernel_size=7,
- stride=2,
- padding=3,
- bias_attr=False)
+ self.conv1 = nn.Conv2D(3, self.inplanes, kernel_size=7, stride=2, padding=3, bias_attr=False)
self.bn1 = self._norm_layer(self.inplanes)
self.relu = nn.ReLU()
self.maxpool = nn.MaxPool2D(kernel_size=3, stride=2, padding=1)
@@ -127,18 +107,12 @@ class ResNet(nn.Layer):
stride = 1
if stride != 1 or self.inplanes != planes * block.expansion:
downsample = nn.Sequential(
- nn.Conv2D(self.inplanes,
- planes * block.expansion,
- 1,
- stride=stride,
- bias_attr=False),
+ nn.Conv2D(self.inplanes, planes * block.expansion, 1, stride=stride, bias_attr=False),
norm_layer(planes * block.expansion),
)
layers = []
- layers.append(
- block(self.inplanes, planes, stride, downsample, 1, 64,
- previous_dilation, norm_layer))
+ layers.append(block(self.inplanes, planes, stride, downsample, 1, 64, previous_dilation, norm_layer))
self.inplanes = planes * block.expansion
for _ in range(1, blocks):
layers.append(block(self.inplanes, planes, norm_layer=norm_layer))
@@ -161,14 +135,15 @@ class ResNet(nn.Layer):
return x
-@moduleinfo(name="spinalnet_res50_gemstone",
- type="CV/classification",
- author="nanting03",
- author_email="975348977@qq.com",
- summary="spinalnet_res50_gemstone is a classification model, "
- "this module is trained with Gemstone dataset.",
- version="1.0.0",
- meta=ImageClassifierModule)
+@moduleinfo(
+ name="spinalnet_res50_gemstone",
+ type="CV/classification",
+ author="nanting03",
+ author_email="975348977@qq.com",
+ summary="spinalnet_res50_gemstone is a classification model, "
+ "this module is trained with Gemstone dataset.",
+ version="1.0.0",
+ meta=ImageClassifierModule)
class SpinalNet_ResNet50(nn.Layer):
def __init__(self, label_list: list = None, load_checkpoint: str = None):
super(SpinalNet_ResNet50, self).__init__()
@@ -194,20 +169,16 @@ class SpinalNet_ResNet50(nn.Layer):
self.half_in_size = half_in_size
self.fc_spinal_layer1 = nn.Sequential(
- nn.Dropout(p=0.5), nn.Linear(half_in_size, layer_width),
- nn.BatchNorm1D(layer_width), nn.ReLU())
+ nn.Dropout(p=0.5), nn.Linear(half_in_size, layer_width), nn.BatchNorm1D(layer_width), nn.ReLU())
self.fc_spinal_layer2 = nn.Sequential(
- nn.Dropout(p=0.5), nn.Linear(half_in_size + layer_width,
- layer_width),
- nn.BatchNorm1D(layer_width), nn.ReLU())
+ nn.Dropout(p=0.5), nn.Linear(half_in_size + layer_width, layer_width), nn.BatchNorm1D(layer_width),
+ nn.ReLU())
self.fc_spinal_layer3 = nn.Sequential(
- nn.Dropout(p=0.5), nn.Linear(half_in_size + layer_width,
- layer_width),
- nn.BatchNorm1D(layer_width), nn.ReLU())
+ nn.Dropout(p=0.5), nn.Linear(half_in_size + layer_width, layer_width), nn.BatchNorm1D(layer_width),
+ nn.ReLU())
self.fc_spinal_layer4 = nn.Sequential(
- nn.Dropout(p=0.5), nn.Linear(half_in_size + layer_width,
- layer_width),
- nn.BatchNorm1D(layer_width), nn.ReLU())
+ nn.Dropout(p=0.5), nn.Linear(half_in_size + layer_width, layer_width), nn.BatchNorm1D(layer_width),
+ nn.ReLU())
self.fc_out = nn.Sequential(
nn.Dropout(p=0.5),
nn.Linear(layer_width * 4, class_dim),
@@ -219,8 +190,7 @@ class SpinalNet_ResNet50(nn.Layer):
print("load custom checkpoint success")
else:
- checkpoint = os.path.join(self.directory,
- 'spinalnet_res50.pdparams')
+ checkpoint = os.path.join(self.directory, 'spinalnet_res50.pdparams')
self.model_dict = paddle.load(checkpoint)
self.set_dict(self.model_dict)
print("load pretrained checkpoint success")
@@ -240,14 +210,9 @@ class SpinalNet_ResNet50(nn.Layer):
y = paddle.flatten(y, 1)
y1 = self.fc_spinal_layer1(y[:, 0:self.half_in_size])
- y2 = self.fc_spinal_layer2(
- paddle.concat([y[:, self.half_in_size:2 * self.half_in_size], y1],
- axis=1))
- y3 = self.fc_spinal_layer3(
- paddle.concat([y[:, 0:self.half_in_size], y2], axis=1))
- y4 = self.fc_spinal_layer4(
- paddle.concat([y[:, self.half_in_size:2 * self.half_in_size], y3],
- axis=1))
+ y2 = self.fc_spinal_layer2(paddle.concat([y[:, self.half_in_size:2 * self.half_in_size], y1], axis=1))
+ y3 = self.fc_spinal_layer3(paddle.concat([y[:, 0:self.half_in_size], y2], axis=1))
+ y4 = self.fc_spinal_layer4(paddle.concat([y[:, self.half_in_size:2 * self.half_in_size], y3], axis=1))
y = paddle.concat([y1, y2, y3, y4], axis=1)
diff --git a/modules/thirdparty/image/classification/SpinalNet_Gemstones/spinalnet_vgg16_gemstone/module.py b/modules/thirdparty/image/classification/SpinalNet_Gemstones/spinalnet_vgg16_gemstone/module.py
index a0ae5b77..b2be994b 100755
--- a/modules/thirdparty/image/classification/SpinalNet_Gemstones/spinalnet_vgg16_gemstone/module.py
+++ b/modules/thirdparty/image/classification/SpinalNet_Gemstones/spinalnet_vgg16_gemstone/module.py
@@ -61,16 +61,9 @@ def make_layers(cfg, batch_norm=False):
cfgs = {
'A': [64, 'M', 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512, 'M'],
- 'B':
- [64, 64, 'M', 128, 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512, 'M'],
- 'D': [
- 64, 64, 'M', 128, 128, 'M', 256, 256, 256, 'M', 512, 512, 512, 'M', 512,
- 512, 512, 'M'
- ],
- 'E': [
- 64, 64, 'M', 128, 128, 'M', 256, 256, 256, 256, 'M', 512, 512, 512, 512,
- 'M', 512, 512, 512, 512, 'M'
- ],
+ 'B': [64, 64, 'M', 128, 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512, 'M'],
+ 'D': [64, 64, 'M', 128, 128, 'M', 256, 256, 256, 'M', 512, 512, 512, 'M', 512, 512, 512, 'M'],
+ 'E': [64, 64, 'M', 128, 128, 'M', 256, 256, 256, 256, 'M', 512, 512, 512, 512, 'M', 512, 512, 512, 512, 'M'],
}
@@ -86,14 +79,15 @@ def vgg16(batch_norm=False, **kwargs):
return _vgg(model_name, 'D', batch_norm, **kwargs)
-@moduleinfo(name="spinalnet_vgg16_gemstone",
- type="CV/classification",
- author="nanting03",
- author_email="975348977@qq.com",
- summary="spinalnet_vgg16_gemstone is a classification model, "
- "this module is trained with Gemstone dataset.",
- version="1.0.0",
- meta=ImageClassifierModule)
+@moduleinfo(
+ name="spinalnet_vgg16_gemstone",
+ type="CV/classification",
+ author="nanting03",
+ author_email="975348977@qq.com",
+ summary="spinalnet_vgg16_gemstone is a classification model, "
+ "this module is trained with Gemstone dataset.",
+ version="1.0.0",
+ meta=ImageClassifierModule)
class SpinalNet_VGG16(nn.Layer):
def __init__(self, label_list: list = None, load_checkpoint: str = None):
super(SpinalNet_VGG16, self).__init__()
@@ -142,8 +136,7 @@ class SpinalNet_VGG16(nn.Layer):
nn.BatchNorm1D(layer_width),
nn.ReLU(),
)
- self.fc_out = nn.Sequential(nn.Dropout(p=0.5),
- nn.Linear(layer_width * 4, class_dim))
+ self.fc_out = nn.Sequential(nn.Dropout(p=0.5), nn.Linear(layer_width * 4, class_dim))
if load_checkpoint is not None:
self.model_dict = paddle.load(load_checkpoint)[0]
@@ -151,8 +144,7 @@ class SpinalNet_VGG16(nn.Layer):
print("load custom checkpoint success")
else:
- checkpoint = os.path.join(self.directory,
- 'spinalnet_vgg16.pdparams')
+ checkpoint = os.path.join(self.directory, 'spinalnet_vgg16.pdparams')
self.model_dict = paddle.load(checkpoint)
self.set_dict(self.model_dict)
print("load pretrained checkpoint success")
@@ -173,14 +165,9 @@ class SpinalNet_VGG16(nn.Layer):
y = paddle.flatten(y, 1)
y1 = self.fc_spinal_layer1(y[:, 0:self.half_in_size])
- y2 = self.fc_spinal_layer2(
- paddle.concat([y[:, self.half_in_size:2 * self.half_in_size], y1],
- axis=1))
- y3 = self.fc_spinal_layer3(
- paddle.concat([y[:, 0:self.half_in_size], y2], axis=1))
- y4 = self.fc_spinal_layer4(
- paddle.concat([y[:, self.half_in_size:2 * self.half_in_size], y3],
- axis=1))
+ y2 = self.fc_spinal_layer2(paddle.concat([y[:, self.half_in_size:2 * self.half_in_size], y1], axis=1))
+ y3 = self.fc_spinal_layer3(paddle.concat([y[:, 0:self.half_in_size], y2], axis=1))
+ y4 = self.fc_spinal_layer4(paddle.concat([y[:, self.half_in_size:2 * self.half_in_size], y3], axis=1))
y = paddle.concat([y1, y2, y3, y4], axis=1)
diff --git a/modules/thirdparty/image/classification/food_classification/__init__.py b/modules/thirdparty/image/classification/food_classification/__init__.py
index 8b137891..e69de29b 100644
--- a/modules/thirdparty/image/classification/food_classification/__init__.py
+++ b/modules/thirdparty/image/classification/food_classification/__init__.py
@@ -1 +0,0 @@
-
diff --git a/modules/thirdparty/image/classification/food_classification/module.py b/modules/thirdparty/image/classification/food_classification/module.py
index af42cd40..bc5730e2 100644
--- a/modules/thirdparty/image/classification/food_classification/module.py
+++ b/modules/thirdparty/image/classification/food_classification/module.py
@@ -41,18 +41,10 @@ def read_images(paths):
version='1.0.0')
class MODULE(hub.Module):
def _initialize(self, **kwargs):
- self.default_pretrained_model_path = os.path.join(
- self.directory, 'assets')
- self.model = pdx.deploy.Predictor(self.default_pretrained_model_path,
- **kwargs)
-
- def predict(self,
- images=None,
- paths=None,
- data=None,
- batch_size=1,
- use_gpu=False,
- **kwargs):
+ self.default_pretrained_model_path = os.path.join(self.directory, 'assets')
+ self.model = pdx.deploy.Predictor(self.default_pretrained_model_path, **kwargs)
+
+ def predict(self, images=None, paths=None, data=None, batch_size=1, use_gpu=False, **kwargs):
all_data = images if images is not None else read_images(paths)
total_num = len(all_data)
@@ -110,36 +102,27 @@ class MODULE(hub.Module):
prog='hub run {}'.format(self.name),
usage='%(prog)s',
add_help=True)
- self.arg_input_group = self.parser.add_argument_group(
- title="Input options", description="Input data. Required")
+ self.arg_input_group = self.parser.add_argument_group(title="Input options", description="Input data. Required")
self.arg_config_group = self.parser.add_argument_group(
- title="Config options",
- description=
- "Run configuration for controlling module behavior, not required.")
+ title="Config options", description="Run configuration for controlling module behavior, not required.")
self.add_module_config_arg()
self.add_module_input_arg()
args = self.parser.parse_args(argvs)
- results = self.predict(
- paths=[args.input_path],
- use_gpu=args.use_gpu)
+ results = self.predict(paths=[args.input_path], use_gpu=args.use_gpu)
return results
def add_module_config_arg(self):
"""
Add the command config options.
"""
- self.arg_config_group.add_argument(
- '--use_gpu',
- type=bool,
- default=False,
- help="whether use GPU or not")
+ self.arg_config_group.add_argument('--use_gpu', type=bool, default=False, help="whether use GPU or not")
def add_module_input_arg(self):
"""
Add the command input options.
"""
- self.arg_input_group.add_argument(
- '--input_path', type=str, help="path to image.")
+ self.arg_input_group.add_argument('--input_path', type=str, help="path to image.")
+
if __name__ == '__main__':
module = MODULE(directory='./new_model')
diff --git a/modules/thirdparty/image/classification/marine_biometrics/__init__.py b/modules/thirdparty/image/classification/marine_biometrics/__init__.py
index 8b137891..e69de29b 100644
--- a/modules/thirdparty/image/classification/marine_biometrics/__init__.py
+++ b/modules/thirdparty/image/classification/marine_biometrics/__init__.py
@@ -1 +0,0 @@
-
diff --git a/modules/thirdparty/image/classification/marine_biometrics/module.py b/modules/thirdparty/image/classification/marine_biometrics/module.py
index f20cf1ae..d511ba38 100644
--- a/modules/thirdparty/image/classification/marine_biometrics/module.py
+++ b/modules/thirdparty/image/classification/marine_biometrics/module.py
@@ -37,22 +37,15 @@ def read_images(paths):
type='cv/classification',
author='郑博培、彭兆帅',
author_email='2733821739@qq.com, 1084667371@qq.com',
- summary='The model uses convolution neural network to tell you the key to identify marine fish, so that anyone can call out the names of the creatures.',
+ summary=
+ 'The model uses convolution neural network to tell you the key to identify marine fish, so that anyone can call out the names of the creatures.',
version='1.0.0')
class MODULE(hub.Module):
def _initialize(self, **kwargs):
- self.default_pretrained_model_path = os.path.join(
- self.directory, 'assets')
- self.model = pdx.deploy.Predictor(self.default_pretrained_model_path,
- **kwargs)
-
- def predict(self,
- images=None,
- paths=None,
- data=None,
- batch_size=1,
- use_gpu=False,
- **kwargs):
+ self.default_pretrained_model_path = os.path.join(self.directory, 'assets')
+ self.model = pdx.deploy.Predictor(self.default_pretrained_model_path, **kwargs)
+
+ def predict(self, images=None, paths=None, data=None, batch_size=1, use_gpu=False, **kwargs):
all_data = images if images is not None else read_images(paths)
total_num = len(all_data)
@@ -110,36 +103,27 @@ class MODULE(hub.Module):
prog='hub run {}'.format(self.name),
usage='%(prog)s',
add_help=True)
- self.arg_input_group = self.parser.add_argument_group(
- title="Input options", description="Input data. Required")
+ self.arg_input_group = self.parser.add_argument_group(title="Input options", description="Input data. Required")
self.arg_config_group = self.parser.add_argument_group(
- title="Config options",
- description=
- "Run configuration for controlling module behavior, not required.")
+ title="Config options", description="Run configuration for controlling module behavior, not required.")
self.add_module_config_arg()
self.add_module_input_arg()
args = self.parser.parse_args(argvs)
- results = self.predict(
- paths=[args.input_path],
- use_gpu=args.use_gpu)
+ results = self.predict(paths=[args.input_path], use_gpu=args.use_gpu)
return results
def add_module_config_arg(self):
"""
Add the command config options.
"""
- self.arg_config_group.add_argument(
- '--use_gpu',
- type=bool,
- default=False,
- help="whether use GPU or not")
+ self.arg_config_group.add_argument('--use_gpu', type=bool, default=False, help="whether use GPU or not")
def add_module_input_arg(self):
"""
Add the command input options.
"""
- self.arg_input_group.add_argument(
- '--input_path', type=str, help="path to image.")
+ self.arg_input_group.add_argument('--input_path', type=str, help="path to image.")
+
if __name__ == '__main__':
module = MODULE(directory='./new_model')
diff --git a/modules/thirdparty/image/semantic_segmentation/WatermeterSegmentation/__init__.py b/modules/thirdparty/image/semantic_segmentation/WatermeterSegmentation/__init__.py
index 8b137891..e69de29b 100644
--- a/modules/thirdparty/image/semantic_segmentation/WatermeterSegmentation/__init__.py
+++ b/modules/thirdparty/image/semantic_segmentation/WatermeterSegmentation/__init__.py
@@ -1 +0,0 @@
-
diff --git a/modules/thirdparty/image/semantic_segmentation/WatermeterSegmentation/module.py b/modules/thirdparty/image/semantic_segmentation/WatermeterSegmentation/module.py
index df00673f..0bca333b 100644
--- a/modules/thirdparty/image/semantic_segmentation/WatermeterSegmentation/module.py
+++ b/modules/thirdparty/image/semantic_segmentation/WatermeterSegmentation/module.py
@@ -34,32 +34,38 @@ def read_images(paths):
images.append(cv2.imread(path))
return images
+
'''旋转图像并剪裁'''
+
+
def rotate(
img, # 图片
- pt1, pt2, pt3, pt4,
+ pt1,
+ pt2,
+ pt3,
+ pt4,
imgOutSrc):
# print(pt1,pt2,pt3,pt4)
- withRect = math.sqrt((pt4[0] - pt1[0]) ** 2 + (pt4[1] - pt1[1]) ** 2) # 矩形框的宽度
- heightRect = math.sqrt((pt1[0] - pt2[0]) ** 2 + (pt1[1] - pt2[1]) **2)
+ withRect = math.sqrt((pt4[0] - pt1[0])**2 + (pt4[1] - pt1[1])**2) # 矩形框的宽度
+ heightRect = math.sqrt((pt1[0] - pt2[0])**2 + (pt1[1] - pt2[1])**2)
# print("矩形的宽度",withRect, "矩形的高度", heightRect)
angle = acos((pt4[0] - pt1[0]) / withRect) * (180 / math.pi) # 矩形框旋转角度
# print("矩形框旋转角度", angle)
if withRect > heightRect:
- if pt4[1]>pt1[1]:
+ if pt4[1] > pt1[1]:
pass
# print("顺时针旋转")
else:
# print("逆时针旋转")
- angle=-angle
+ angle = -angle
else:
# print("逆时针旋转")
- angle=90 - angle
+ angle = 90 - angle
height = img.shape[0] # 原始图像高度
- width = img.shape[1] # 原始图像宽度
+ width = img.shape[1] # 原始图像宽度
rotateMat = cv2.getRotationMatrix2D((width / 2, height / 2), angle, 1) # 按angle角度旋转图像
heightNew = int(width * fabs(sin(radians(angle))) + height * fabs(cos(radians(angle))))
widthNew = int(height * fabs(sin(radians(angle))) + width * fabs(cos(radians(angle))))
@@ -67,7 +73,7 @@ def rotate(
rotateMat[0, 2] += (widthNew - width) / 2
rotateMat[1, 2] += (heightNew - height) / 2
imgRotation = cv2.warpAffine(img, rotateMat, (widthNew, heightNew), borderValue=(255, 255, 255))
- # cv2.imwrite("imgRotation.jpg", imgRotation)
+ # cv2.imwrite("imgRotation.jpg", imgRotation)
# 旋转后图像的四点坐标
[[pt1[0]], [pt1[1]]] = np.dot(rotateMat, np.array([[pt1[0]], [pt1[1]], [1]]))
@@ -76,13 +82,14 @@ def rotate(
[[pt4[0]], [pt4[1]]] = np.dot(rotateMat, np.array([[pt4[0]], [pt4[1]], [1]]))
# 处理反转的情况
- if pt2[1]>pt4[1]:
- pt2[1],pt4[1]=pt4[1],pt2[1]
- if pt1[0]>pt3[0]:
- pt1[0],pt3[0]=pt3[0],pt1[0]
+ if pt2[1] > pt4[1]:
+ pt2[1], pt4[1] = pt4[1], pt2[1]
+ if pt1[0] > pt3[0]:
+ pt1[0], pt3[0] = pt3[0], pt1[0]
imgOut = imgRotation[int(pt2[1]):int(pt4[1]), int(pt1[0]):int(pt3[0])]
- cv2.imwrite(imgOutSrc, imgOut) # 裁减得到的旋转矩形框
+ cv2.imwrite(imgOutSrc, imgOut) # 裁减得到的旋转矩形框
+
@moduleinfo(
name='WatermeterSegmentation',
@@ -93,18 +100,10 @@ def rotate(
version='1.0.0')
class MODULE(hub.Module):
def _initialize(self, **kwargs):
- self.default_pretrained_model_path = os.path.join(
- self.directory, 'assets')
- self.model = pdx.deploy.Predictor(self.default_pretrained_model_path,
- **kwargs)
-
- def predict(self,
- images=None,
- paths=None,
- data=None,
- batch_size=1,
- use_gpu=False,
- **kwargs):
+ self.default_pretrained_model_path = os.path.join(self.directory, 'assets')
+ self.model = pdx.deploy.Predictor(self.default_pretrained_model_path, **kwargs)
+
+ def predict(self, images=None, paths=None, data=None, batch_size=1, use_gpu=False, **kwargs):
all_data = images if images is not None else read_images(paths)
total_num = len(all_data)
@@ -130,11 +129,11 @@ class MODULE(hub.Module):
result = self.predict(images=[im])
# 将多边形polygon转矩形
- contours, hier = cv2.findContours(result[0]['label_map'], cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
+ contours, hier = cv2.findContours(result[0]['label_map'], cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
print(type(contours[0]))
n = 0
m = 0
- for index,contour in enumerate(contours):
+ for index, contour in enumerate(contours):
if len(contour) > n:
n = len(contour)
m = index
@@ -181,7 +180,6 @@ class MODULE(hub.Module):
res.append(result)
return res
-
@runnable
def run_cmd(self, argvs):
"""
@@ -192,36 +190,27 @@ class MODULE(hub.Module):
prog='hub run {}'.format(self.name),
usage='%(prog)s',
add_help=True)
- self.arg_input_group = self.parser.add_argument_group(
- title="Input options", description="Input data. Required")
+ self.arg_input_group = self.parser.add_argument_group(title="Input options", description="Input data. Required")
self.arg_config_group = self.parser.add_argument_group(
- title="Config options",
- description=
- "Run configuration for controlling module behavior, not required.")
+ title="Config options", description="Run configuration for controlling module behavior, not required.")
self.add_module_config_arg()
self.add_module_input_arg()
args = self.parser.parse_args(argvs)
- results = self.predict(
- paths=[args.input_path],
- use_gpu=args.use_gpu)
+ results = self.predict(paths=[args.input_path], use_gpu=args.use_gpu)
return results
def add_module_config_arg(self):
"""
Add the command config options.
"""
- self.arg_config_group.add_argument(
- '--use_gpu',
- type=bool,
- default=False,
- help="whether use GPU or not")
+ self.arg_config_group.add_argument('--use_gpu', type=bool, default=False, help="whether use GPU or not")
def add_module_input_arg(self):
"""
Add the command input options.
"""
- self.arg_input_group.add_argument(
- '--input_path', type=str, help="path to image.")
+ self.arg_input_group.add_argument('--input_path', type=str, help="path to image.")
+
if __name__ == '__main__':
module = MODULE(directory='./new_model')
diff --git a/modules/thirdparty/image/text_recognition/Vehicle_License_Plate_Recognition/README.md b/modules/thirdparty/image/text_recognition/Vehicle_License_Plate_Recognition/README.md
index 595a364e..2ff2cc18 100644
--- a/modules/thirdparty/image/text_recognition/Vehicle_License_Plate_Recognition/README.md
+++ b/modules/thirdparty/image/text_recognition/Vehicle_License_Plate_Recognition/README.md
@@ -80,4 +80,4 @@ paddlepaddle >= 2.0.0
paddlehub >= 2.0.4
-paddleocr >= 2.0.2
\ No newline at end of file
+paddleocr >= 2.0.2
diff --git a/modules/thirdparty/image/text_recognition/Vehicle_License_Plate_Recognition/module.py b/modules/thirdparty/image/text_recognition/Vehicle_License_Plate_Recognition/module.py
index 4ed307b0..ddef9ab7 100644
--- a/modules/thirdparty/image/text_recognition/Vehicle_License_Plate_Recognition/module.py
+++ b/modules/thirdparty/image/text_recognition/Vehicle_License_Plate_Recognition/module.py
@@ -13,16 +13,13 @@ from paddlehub.module.module import moduleinfo, serving
author="jm12138",
author_email="",
summary="Vehicle_License_Plate_Recognition",
- version="1.0.0"
-)
+ version="1.0.0")
class Vehicle_License_Plate_Recognition(nn.Layer):
def __init__(self):
super(Vehicle_License_Plate_Recognition, self).__init__()
self.vlpr = PaddleOCR(
det_model_dir=os.path.join(self.directory, 'det_vlpr'),
- rec_model_dir=os.path.join(
- self.directory, 'ch_ppocr_server_v2.0_rec_infer')
- )
+ rec_model_dir=os.path.join(self.directory, 'ch_ppocr_server_v2.0_rec_infer'))
@staticmethod
def base64_to_cv2(b64str):
@@ -38,17 +35,11 @@ class Vehicle_License_Plate_Recognition(nn.Layer):
if isinstance(images, list):
for item in images:
for bbox, text in self.vlpr.ocr(item):
- results.append({
- 'license': text[0],
- 'bbox': bbox
- })
+ results.append({'license': text[0], 'bbox': bbox})
elif isinstance(images, (str, np.ndarray)):
for bbox, text in self.vlpr.ocr(images):
- results.append({
- 'license': text[0],
- 'bbox': bbox
- })
+ results.append({'license': text[0], 'bbox': bbox})
return results
diff --git a/modules/thirdparty/text/text_generation/GPT2_Base_CN/README.md b/modules/thirdparty/text/text_generation/GPT2_Base_CN/README.md
index c5960bdf..f355dd0c 100644
--- a/modules/thirdparty/text/text_generation/GPT2_Base_CN/README.md
+++ b/modules/thirdparty/text/text_generation/GPT2_Base_CN/README.md
@@ -159,7 +159,7 @@ import json
text = "今天是个好日子"
data = {
- "text": text,
+ "text": text,
"mode": "sample", # 'search' or 'sample'
# 可以更加需要设置上述 API 中提到的其他参数
}
@@ -173,8 +173,8 @@ r = requests.post(url=url, headers=headers, data=json.dumps(data))
https://github.com/PaddlePaddle/PaddleNLP
## 依赖
-paddlepaddle >= 2.0.0
+paddlepaddle >= 2.0.0
paddlehub >= 2.0.0
-sentencepiece==0.1.92
\ No newline at end of file
+sentencepiece==0.1.92
diff --git a/modules/thirdparty/text/text_generation/GPT2_Base_CN/module.py b/modules/thirdparty/text/text_generation/GPT2_Base_CN/module.py
index e5faf316..df1c61ea 100644
--- a/modules/thirdparty/text/text_generation/GPT2_Base_CN/module.py
+++ b/modules/thirdparty/text/text_generation/GPT2_Base_CN/module.py
@@ -38,18 +38,15 @@ class GPT2_Base_CN(nn.Layer):
# 初始预测
ids = self.tokenizer.encode(text)
- input_id = paddle.to_tensor(
- np.array(ids).reshape(1, -1).astype('int64'))
+ input_id = paddle.to_tensor(np.array(ids).reshape(1, -1).astype('int64'))
output, cached_kvs = self.model(input_id, use_cache=True)
next_token = int(np.argmax(output[0, -1].numpy()))
ids.append(next_token)
# 使用缓存进行继续预测
- for i in range(max_len-1):
- input_id = paddle.to_tensor(
- np.array([next_token]).reshape(1, -1).astype('int64'))
- output, cached_kvs = self.model(
- input_id, use_cache=True, cache=cached_kvs)
+ for i in range(max_len - 1):
+ input_id = paddle.to_tensor(np.array([next_token]).reshape(1, -1).astype('int64'))
+ output, cached_kvs = self.model(input_id, use_cache=True, cache=cached_kvs)
next_token = int(np.argmax(output[0, -1].numpy()))
ids.append(next_token)
@@ -79,14 +76,12 @@ class GPT2_Base_CN(nn.Layer):
if top_p < 1.0:
sorted_logits = paddle.sort(logits, descending=True)
sorted_indices = paddle.argsort(logits, descending=True).numpy()
- cumulative_probs = paddle.cumsum(paddle.nn.functional.softmax(
- sorted_logits, axis=-1), axis=-1).numpy()
+ cumulative_probs = paddle.cumsum(paddle.nn.functional.softmax(sorted_logits, axis=-1), axis=-1).numpy()
# Remove tokens with cumulative probability above the threshold
sorted_indices_to_remove = cumulative_probs > top_p
# Shift the indices to the right to keep also the first token above the threshold
- sorted_indices_to_remove[...,
- 1:] = sorted_indices_to_remove[..., :-1]
+ sorted_indices_to_remove[..., 1:] = sorted_indices_to_remove[..., :-1]
sorted_indices_to_remove[..., 0] = 0
indices_to_remove = sorted_indices[sorted_indices_to_remove]
@@ -94,7 +89,14 @@ class GPT2_Base_CN(nn.Layer):
return paddle.to_tensor(logits_np)
- def nucleus_sample(self, text, max_len=32, end_word=None, repitition_penalty=1.0, temperature=1.0, top_k=0, top_p=1.0):
+ def nucleus_sample(self,
+ text,
+ max_len=32,
+ end_word=None,
+ repitition_penalty=1.0,
+ temperature=1.0,
+ top_k=0,
+ top_p=1.0):
with paddle.no_grad():
# 终止标志
if end_word is not None:
@@ -103,33 +105,28 @@ class GPT2_Base_CN(nn.Layer):
# 初始预测
ids = self.tokenizer.encode(text)
- input_id = paddle.to_tensor(
- np.array(ids).reshape(1, -1).astype('int64'))
+ input_id = paddle.to_tensor(np.array(ids).reshape(1, -1).astype('int64'))
output, cached_kvs = self.model(input_id, use_cache=True)
next_token_logits = output[0, -1, :]
for id in set(ids):
next_token_logits[id] /= repitition_penalty
next_token_logits = next_token_logits / temperature
- filtered_logits = self.top_k_top_p_filtering(
- next_token_logits, top_k=top_k, top_p=top_p)
- next_token = paddle.multinomial(paddle.nn.functional.softmax(
- filtered_logits, axis=-1), num_samples=1).numpy()
+ filtered_logits = self.top_k_top_p_filtering(next_token_logits, top_k=top_k, top_p=top_p)
+ next_token = paddle.multinomial(
+ paddle.nn.functional.softmax(filtered_logits, axis=-1), num_samples=1).numpy()
ids += [int(next_token)]
# 使用缓存进行继续预测
- for i in range(max_len-1):
- input_id = paddle.to_tensor(
- np.array([next_token]).reshape(1, -1).astype('int64'))
- output, cached_kvs = self.model(
- input_id, use_cache=True, cache=cached_kvs)
+ for i in range(max_len - 1):
+ input_id = paddle.to_tensor(np.array([next_token]).reshape(1, -1).astype('int64'))
+ output, cached_kvs = self.model(input_id, use_cache=True, cache=cached_kvs)
next_token_logits = output[0, -1, :]
for id in set(ids):
next_token_logits[id] /= repitition_penalty
next_token_logits = next_token_logits / temperature
- filtered_logits = self.top_k_top_p_filtering(
- next_token_logits, top_k=top_k, top_p=top_p)
- next_token = paddle.multinomial(paddle.nn.functional.softmax(
- filtered_logits, axis=-1), num_samples=1).numpy()
+ filtered_logits = self.top_k_top_p_filtering(next_token_logits, top_k=top_k, top_p=top_p)
+ next_token = paddle.multinomial(
+ paddle.nn.functional.softmax(filtered_logits, axis=-1), num_samples=1).numpy()
ids += [int(next_token)]
# 根据终止标志停止预测
diff --git a/modules/thirdparty/text/text_generation/GPT2_CPM_LM/README.md b/modules/thirdparty/text/text_generation/GPT2_CPM_LM/README.md
index 137269c0..b8330d47 100644
--- a/modules/thirdparty/text/text_generation/GPT2_CPM_LM/README.md
+++ b/modules/thirdparty/text/text_generation/GPT2_CPM_LM/README.md
@@ -165,7 +165,7 @@ import json
text = "今天是个好日子"
data = {
- "text": text,
+ "text": text,
"mode": "sample", # 'search' or 'sample'
# 可以更加需要设置上述 API 中提到的其他参数
}
@@ -180,8 +180,8 @@ r = requests.post(url=url, headers=headers, data=json.dumps(data))
https://github.com/jm12138/CPM-Generate-Paddle
## 依赖
-paddlepaddle >= 2.0.0
+paddlepaddle >= 2.0.0
paddlehub >= 2.0.0
-sentencepiece==0.1.92
\ No newline at end of file
+sentencepiece==0.1.92
diff --git a/modules/thirdparty/text/text_generation/GPT2_CPM_LM/module.py b/modules/thirdparty/text/text_generation/GPT2_CPM_LM/module.py
index 00c0b569..1d26e088 100644
--- a/modules/thirdparty/text/text_generation/GPT2_CPM_LM/module.py
+++ b/modules/thirdparty/text/text_generation/GPT2_CPM_LM/module.py
@@ -30,13 +30,11 @@ class GPT2_CPM_LM(nn.Layer):
max_position_embeddings=1024,
type_vocab_size=1,
initializer_range=0.02,
- pad_token_id=0
- )
+ pad_token_id=0)
self.model = GPT2ForPretraining(gpt2)
# 读取CPM-LM模型参数(FP16)
- state_dict = paddle.load(os.path.join(
- self.directory, 'CPM-LM.pdparams'))
+ state_dict = paddle.load(os.path.join(self.directory, 'CPM-LM.pdparams'))
# FP16 -> FP32
for param in state_dict:
@@ -51,8 +49,7 @@ class GPT2_CPM_LM(nn.Layer):
# 加载编解码器
self.tokenizer = GPT2ChineseTokenizer(
vocab_file=os.path.join(self.directory, 'vocab.json'),
- model_file=os.path.join(self.directory, 'chinese_vocab.model')
- )
+ model_file=os.path.join(self.directory, 'chinese_vocab.model'))
# 初始化编码器
_ = self.tokenizer.encode('_')
@@ -67,18 +64,15 @@ class GPT2_CPM_LM(nn.Layer):
# 初始预测
ids = self.tokenizer.encode(text)
- input_id = paddle.to_tensor(
- np.array(ids).reshape(1, -1).astype('int64'))
+ input_id = paddle.to_tensor(np.array(ids).reshape(1, -1).astype('int64'))
output, cached_kvs = self.model(input_id, use_cache=True)
next_token = int(np.argmax(output[0, -1].numpy()))
ids.append(next_token)
# 使用缓存进行继续预测
- for i in range(max_len-1):
- input_id = paddle.to_tensor(
- np.array([next_token]).reshape(1, -1).astype('int64'))
- output, cached_kvs = self.model(
- input_id, use_cache=True, cache=cached_kvs)
+ for i in range(max_len - 1):
+ input_id = paddle.to_tensor(np.array([next_token]).reshape(1, -1).astype('int64'))
+ output, cached_kvs = self.model(input_id, use_cache=True, cache=cached_kvs)
next_token = int(np.argmax(output[0, -1].numpy()))
ids.append(next_token)
@@ -108,14 +102,12 @@ class GPT2_CPM_LM(nn.Layer):
if top_p < 1.0:
sorted_logits = paddle.sort(logits, descending=True)
sorted_indices = paddle.argsort(logits, descending=True).numpy()
- cumulative_probs = paddle.cumsum(paddle.nn.functional.softmax(
- sorted_logits, axis=-1), axis=-1).numpy()
+ cumulative_probs = paddle.cumsum(paddle.nn.functional.softmax(sorted_logits, axis=-1), axis=-1).numpy()
# Remove tokens with cumulative probability above the threshold
sorted_indices_to_remove = cumulative_probs > top_p
# Shift the indices to the right to keep also the first token above the threshold
- sorted_indices_to_remove[...,
- 1:] = sorted_indices_to_remove[..., :-1]
+ sorted_indices_to_remove[..., 1:] = sorted_indices_to_remove[..., :-1]
sorted_indices_to_remove[..., 0] = 0
indices_to_remove = sorted_indices[sorted_indices_to_remove]
@@ -123,7 +115,14 @@ class GPT2_CPM_LM(nn.Layer):
return paddle.to_tensor(logits_np)
- def nucleus_sample(self, text, max_len=32, end_word=None, repitition_penalty=1.0, temperature=1.0, top_k=0, top_p=1.0):
+ def nucleus_sample(self,
+ text,
+ max_len=32,
+ end_word=None,
+ repitition_penalty=1.0,
+ temperature=1.0,
+ top_k=0,
+ top_p=1.0):
with paddle.no_grad():
# 终止标志
if end_word is not None:
@@ -132,35 +131,30 @@ class GPT2_CPM_LM(nn.Layer):
# 初始预测
ids = self.tokenizer.encode(text)
- input_id = paddle.to_tensor(
- np.array(ids).reshape(1, -1).astype('int64'))
+ input_id = paddle.to_tensor(np.array(ids).reshape(1, -1).astype('int64'))
output, cached_kvs = self.model(input_id, use_cache=True)
next_token_logits = output[0, -1, :]
for id in set(ids):
next_token_logits[id] /= repitition_penalty
next_token_logits = next_token_logits / temperature
next_token_logits[self.tokenizer.encoder['']] = -float('Inf')
- filtered_logits = self.top_k_top_p_filtering(
- next_token_logits, top_k=top_k, top_p=top_p)
- next_token = paddle.multinomial(paddle.nn.functional.softmax(
- filtered_logits, axis=-1), num_samples=1).numpy()
+ filtered_logits = self.top_k_top_p_filtering(next_token_logits, top_k=top_k, top_p=top_p)
+ next_token = paddle.multinomial(
+ paddle.nn.functional.softmax(filtered_logits, axis=-1), num_samples=1).numpy()
ids += [int(next_token)]
# 使用缓存进行继续预测
- for i in range(max_len-1):
- input_id = paddle.to_tensor(
- np.array([next_token]).reshape(1, -1).astype('int64'))
- output, cached_kvs = self.model(
- input_id, use_cache=True, cache=cached_kvs)
+ for i in range(max_len - 1):
+ input_id = paddle.to_tensor(np.array([next_token]).reshape(1, -1).astype('int64'))
+ output, cached_kvs = self.model(input_id, use_cache=True, cache=cached_kvs)
next_token_logits = output[0, -1, :]
for id in set(ids):
next_token_logits[id] /= repitition_penalty
next_token_logits = next_token_logits / temperature
next_token_logits[self.tokenizer.encoder['']] = -float('Inf')
- filtered_logits = self.top_k_top_p_filtering(
- next_token_logits, top_k=top_k, top_p=top_p)
- next_token = paddle.multinomial(paddle.nn.functional.softmax(
- filtered_logits, axis=-1), num_samples=1).numpy()
+ filtered_logits = self.top_k_top_p_filtering(next_token_logits, top_k=top_k, top_p=top_p)
+ next_token = paddle.multinomial(
+ paddle.nn.functional.softmax(filtered_logits, axis=-1), num_samples=1).numpy()
ids += [int(next_token)]
# 根据终止标志停止预测
diff --git a/modules/thirdparty/video/Video_editing/SkyAR/__init__.py b/modules/thirdparty/video/Video_editing/SkyAR/__init__.py
index 8b137891..e69de29b 100644
--- a/modules/thirdparty/video/Video_editing/SkyAR/__init__.py
+++ b/modules/thirdparty/video/Video_editing/SkyAR/__init__.py
@@ -1 +0,0 @@
-
diff --git a/modules/thirdparty/video/Video_editing/SkyAR/module.py b/modules/thirdparty/video/Video_editing/SkyAR/module.py
index 1f5c476e..78ed1341 100644
--- a/modules/thirdparty/video/Video_editing/SkyAR/module.py
+++ b/modules/thirdparty/video/Video_editing/SkyAR/module.py
@@ -4,41 +4,42 @@ from .skyfilter import SkyFilter
from paddlehub.module.module import moduleinfo
-@moduleinfo(
- name="SkyAR",
- type="CV/Video_editing",
- author="jm12138",
- author_email="",
- summary="SkyAR",
- version="1.0.0"
-)
+@moduleinfo(name="SkyAR", type="CV/Video_editing", author="jm12138", author_email="", summary="SkyAR", version="1.0.0")
class SkyAR(nn.Layer):
def __init__(self, model_path=None):
super(SkyAR, self).__init__()
- self.imgs = ['cloudy', 'district9ship', 'floatingcastle',
- 'galaxy', 'jupiter', 'rainy', 'sunny', 'sunset', 'supermoon']
+ self.imgs = [
+ 'cloudy', 'district9ship', 'floatingcastle', 'galaxy', 'jupiter', 'rainy', 'sunny', 'sunset', 'supermoon'
+ ]
self.videos = ['thunderstorm']
if model_path:
self.model_path = model_path
else:
self.model_path = os.path.join(self.directory, './ResNet50FCN')
- def MagicSky(
- self, video_path, save_path, config='jupiter',
- is_rainy=False, preview_frames_num=0, is_video_sky=False, is_show=False,
- skybox_img=None, skybox_video=None, rain_cap_path=None,
- halo_effect=True, auto_light_matching=False,
- relighting_factor=0.8, recoloring_factor=0.5, skybox_center_crop=0.5
- ):
+ def MagicSky(self,
+ video_path,
+ save_path,
+ config='jupiter',
+ is_rainy=False,
+ preview_frames_num=0,
+ is_video_sky=False,
+ is_show=False,
+ skybox_img=None,
+ skybox_video=None,
+ rain_cap_path=None,
+ halo_effect=True,
+ auto_light_matching=False,
+ relighting_factor=0.8,
+ recoloring_factor=0.5,
+ skybox_center_crop=0.5):
if config in self.imgs:
- skybox_img = os.path.join(
- self.directory, 'skybox', '%s.jpg' % config)
+ skybox_img = os.path.join(self.directory, 'skybox', '%s.jpg' % config)
skybox_video = None
is_video_sky = False
elif config in self.videos:
skybox_img = None
- skybox_video = os.path.join(
- self.directory, 'skybox', '%s.mp4' % config)
+ skybox_video = os.path.join(self.directory, 'skybox', '%s.mp4' % config)
is_video_sky = True
elif skybox_img:
is_video_sky = False
@@ -49,8 +50,7 @@ class SkyAR(nn.Layer):
raise 'please check your configs'
if not rain_cap_path:
- rain_cap_path = os.path.join(
- self.directory, 'rain_streaks', 'videoplayback.mp4')
+ rain_cap_path = os.path.join(self.directory, 'rain_streaks', 'videoplayback.mp4')
skyfilter = SkyFilter(
model_path=self.model_path,
@@ -67,7 +67,6 @@ class SkyAR(nn.Layer):
skybox_video=skybox_video,
is_video=is_video_sky,
is_rainy=is_rainy,
- is_show=is_show
- )
+ is_show=is_show)
skyfilter.run(preview_frames_num)
diff --git a/modules/thirdparty/video/Video_editing/SkyAR/rain.py b/modules/thirdparty/video/Video_editing/SkyAR/rain.py
index 859ec51a..f6cfd224 100644
--- a/modules/thirdparty/video/Video_editing/SkyAR/rain.py
+++ b/modules/thirdparty/video/Video_editing/SkyAR/rain.py
@@ -29,7 +29,7 @@ class Rain():
return rain_layer
def _create_haze_layer(self, rain_layer):
- return 0.1*np.ones_like(rain_layer)
+ return 0.1 * np.ones_like(rain_layer)
def forward(self, img):
# get input image size
@@ -54,7 +54,7 @@ class Rain():
img_out = 1 - (1 - rain_layer) * (1 - img)
# gamma and light correction
- img_out = self.light_correction*(img_out**self.gamma)
+ img_out = self.light_correction * (img_out**self.gamma)
# check boundary
img_out = np.clip(img_out, a_min=0, a_max=1.)
diff --git a/modules/thirdparty/video/Video_editing/SkyAR/skybox.py b/modules/thirdparty/video/Video_editing/SkyAR/skybox.py
index 31d71292..748e9c15 100644
--- a/modules/thirdparty/video/Video_editing/SkyAR/skybox.py
+++ b/modules/thirdparty/video/Video_editing/SkyAR/skybox.py
@@ -6,10 +6,8 @@ from .utils import build_transformation_matrix, update_transformation_matrix, es
class SkyBox():
- def __init__(
- self, out_size, skybox_img, skybox_video, halo_effect,
- auto_light_matching, relighting_factor, recoloring_factor,
- skybox_center_crop, rain_cap_path, is_video, is_rainy):
+ def __init__(self, out_size, skybox_img, skybox_video, halo_effect, auto_light_matching, relighting_factor,
+ recoloring_factor, skybox_center_crop, rain_cap_path, is_video, is_rainy):
self.out_size_w, self.out_size_h = out_size
@@ -28,12 +26,7 @@ class SkyBox():
self.skybox_center_crop = skybox_center_crop
self.load_skybox()
self.rainmodel = Rain(
- rain_cap_path=rain_cap_path,
- rain_intensity=0.8,
- haze_intensity=0.0,
- gamma=1.0,
- light_correction=1.0
- )
+ rain_cap_path=rain_cap_path, rain_intensity=0.8, haze_intensity=0.0, gamma=1.0, light_correction=1.0)
# motion parameters
self.M = np.array([[1, 0, 0], [0, 1, 0]], dtype=np.float32)
@@ -43,10 +36,8 @@ class SkyBox():
def tile_skybox_img(self, imgtile):
screen_y1 = int(imgtile.shape[0] / 2 - self.out_size_h / 2)
screen_x1 = int(imgtile.shape[1] / 2 - self.out_size_w / 2)
- imgtile = np.concatenate(
- [imgtile[screen_y1:, :, :], imgtile[0:screen_y1, :, :]], axis=0)
- imgtile = np.concatenate(
- [imgtile[:, screen_x1:, :], imgtile[:, 0:screen_x1, :]], axis=1)
+ imgtile = np.concatenate([imgtile[screen_y1:, :, :], imgtile[0:screen_y1, :, :]], axis=0)
+ imgtile = np.concatenate([imgtile[:, screen_x1:, :], imgtile[:, 0:screen_x1, :]], axis=1)
return imgtile
@@ -57,12 +48,9 @@ class SkyBox():
skybox_img = cv2.imread(self.skybox_img, cv2.IMREAD_COLOR)
skybox_img = cv2.cvtColor(skybox_img, cv2.COLOR_BGR2RGB)
- self.skybox_img = cv2.resize(
- skybox_img, (self.out_size_w, self.out_size_h))
+ self.skybox_img = cv2.resize(skybox_img, (self.out_size_w, self.out_size_h))
cc = 1. / self.skybox_center_crop
- imgtile = cv2.resize(
- skybox_img, (int(cc * self.out_size_w),
- int(cc*self.out_size_h)))
+ imgtile = cv2.resize(skybox_img, (int(cc * self.out_size_w), int(cc * self.out_size_h)))
self.skybox_imgx2 = self.tile_skybox_img(imgtile)
self.skybox_imgx2 = np.expand_dims(self.skybox_imgx2, axis=0)
@@ -71,15 +59,11 @@ class SkyBox():
cap = cv2.VideoCapture(self.skybox_video)
m_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
cc = 1. / self.skybox_center_crop
- self.skybox_imgx2 = np.zeros(
- [m_frames, int(cc*self.out_size_h),
- int(cc*self.out_size_w), 3], np.uint8)
+ self.skybox_imgx2 = np.zeros([m_frames, int(cc * self.out_size_h), int(cc * self.out_size_w), 3], np.uint8)
for i in range(m_frames):
_, skybox_img = cap.read()
skybox_img = cv2.cvtColor(skybox_img, cv2.COLOR_BGR2RGB)
- imgtile = cv2.resize(
- skybox_img, (int(cc * self.out_size_w),
- int(cc * self.out_size_h)))
+ imgtile = cv2.resize(skybox_img, (int(cc * self.out_size_w), int(cc * self.out_size_h)))
skybox_imgx2 = self.tile_skybox_img(imgtile)
self.skybox_imgx2[i, :] = skybox_imgx2
@@ -87,8 +71,7 @@ class SkyBox():
r, eps = 20, 0.01
refined_skymask = guidedfilter(img[:, :, 2], G_pred[:, :, 0], r, eps)
- refined_skymask = np.stack(
- [refined_skymask, refined_skymask, refined_skymask], axis=-1)
+ refined_skymask = np.stack([refined_skymask, refined_skymask, refined_skymask], axis=-1)
return np.clip(refined_skymask, a_min=0, a_max=1)
@@ -98,14 +81,13 @@ class SkyBox():
nbgs, bgh, bgw, c = self.skybox_imgx2.shape
fetch_id = self.frame_id % nbgs
skybg_warp = cv2.warpAffine(
- self.skybox_imgx2[fetch_id, :, :, :], self.M,
- (bgw, bgh), borderMode=cv2.BORDER_WRAP)
+ self.skybox_imgx2[fetch_id, :, :, :], self.M, (bgw, bgh), borderMode=cv2.BORDER_WRAP)
skybg = skybg_warp[0:self.out_size_h, 0:self.out_size_w, :]
self.frame_id += 1
- return np.array(skybg, np.float32)/255.
+ return np.array(skybg, np.float32) / 255.
def skybox_tracking(self, frame, frame_prev, skymask):
if np.mean(skymask) < 0.05:
@@ -113,27 +95,25 @@ class SkyBox():
return np.array([[1, 0, 0], [0, 1, 0]], dtype=np.float32)
prev_gray = cv2.cvtColor(frame_prev, cv2.COLOR_RGB2GRAY)
- prev_gray = np.array(255*prev_gray, dtype=np.uint8)
+ prev_gray = np.array(255 * prev_gray, dtype=np.uint8)
curr_gray = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)
- curr_gray = np.array(255*curr_gray, dtype=np.uint8)
+ curr_gray = np.array(255 * curr_gray, dtype=np.uint8)
mask = np.array(skymask[:, :, 0] > 0.99, dtype=np.uint8)
- template_size = int(0.05*mask.shape[0])
+ template_size = int(0.05 * mask.shape[0])
mask = cv2.erode(mask, np.ones([template_size, template_size]))
# ShiTomasi corner detection
prev_pts = cv2.goodFeaturesToTrack(
- prev_gray, mask=mask, maxCorners=200,
- qualityLevel=0.01, minDistance=30, blockSize=3)
+ prev_gray, mask=mask, maxCorners=200, qualityLevel=0.01, minDistance=30, blockSize=3)
if prev_pts is None:
print('no feature point detected')
return np.array([[1, 0, 0], [0, 1, 0]], dtype=np.float32)
# Calculate optical flow (i.e. track feature points)
- curr_pts, status, err = cv2.calcOpticalFlowPyrLK(
- prev_gray, curr_gray, prev_pts, None)
+ curr_pts, status, err = cv2.calcOpticalFlowPyrLK(prev_gray, curr_gray, prev_pts, None)
# Filter only valid points
idx = np.where(status == 1)[0]
if idx.size == 0:
@@ -147,15 +127,14 @@ class SkyBox():
return np.array([[1, 0, 0], [0, 1, 0]], dtype=np.float32)
# limit the motion to translation + rotation
- dxdyda = estimate_partial_transform((
- np.array(prev_pts), np.array(curr_pts)))
+ dxdyda = estimate_partial_transform((np.array(prev_pts), np.array(curr_pts)))
m = build_transformation_matrix(dxdyda)
return m
def relighting(self, img, skybg, skymask):
# color matching, reference: skybox_img
- step = int(img.shape[0]/20)
+ step = int(img.shape[0] / 20)
skybg_thumb = skybg[::step, ::step, :]
img_thumb = img[::step, ::step, :]
skymask_thumb = skymask[::step, ::step, :]
@@ -163,7 +142,7 @@ class SkyBox():
img_mean = np.sum(img_thumb * (1-skymask_thumb), axis=(0, 1), keepdims=True) \
/ ((1-skymask_thumb).sum(axis=(0, 1), keepdims=True) + 1e-9)
diff = skybg_mean - img_mean
- img_colortune = img + self.recoloring_factor*diff
+ img_colortune = img + self.recoloring_factor * diff
if self.auto_light_matching:
img = img_colortune
@@ -176,11 +155,9 @@ class SkyBox():
def halo(self, syneth, skybg, skymask):
# reflection
- halo = 0.5*cv2.blur(
- skybg*skymask, (int(self.out_size_w/5),
- int(self.out_size_w/5)))
+ halo = 0.5 * cv2.blur(skybg * skymask, (int(self.out_size_w / 5), int(self.out_size_w / 5)))
# screen blend 1 - (1-a)(1-b)
- syneth_with_halo = 1 - (1-syneth) * (1-halo)
+ syneth_with_halo = 1 - (1 - syneth) * (1 - halo)
return syneth_with_halo
diff --git a/modules/thirdparty/video/Video_editing/SkyAR/skyfilter.py b/modules/thirdparty/video/Video_editing/SkyAR/skyfilter.py
index 6166b281..42f2b097 100644
--- a/modules/thirdparty/video/Video_editing/SkyAR/skyfilter.py
+++ b/modules/thirdparty/video/Video_editing/SkyAR/skyfilter.py
@@ -8,37 +8,37 @@ __all__ = ['SkyFilter']
class SkyFilter():
- def __init__(self, model_path, video_path, save_path, in_size,
- halo_effect, auto_light_matching, relighting_factor,
- recoloring_factor, skybox_center_crop, rain_cap_path,
- skybox_img, skybox_video, is_video, is_rainy, is_show
- ):
+ def __init__(self, model_path, video_path, save_path, in_size, halo_effect, auto_light_matching, relighting_factor,
+ recoloring_factor, skybox_center_crop, rain_cap_path, skybox_img, skybox_video, is_video, is_rainy,
+ is_show):
self.in_size = in_size
self.is_show = is_show
self.cap = cv2.VideoCapture(video_path)
self.m_frames = int(self.cap.get(cv2.CAP_PROP_FRAME_COUNT))
self.fps = self.cap.get(cv2.CAP_PROP_FPS)
- self.out_size = int(self.cap.get(
- cv2.CAP_PROP_FRAME_WIDTH)), int(self.cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
+ self.out_size = int(self.cap.get(cv2.CAP_PROP_FRAME_WIDTH)), int(self.cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
- self.model = paddle.jit.load(
- model_path, model_filename='__model__', params_filename='__params__')
+ self.model = paddle.jit.load(model_path, model_filename='__model__', params_filename='__params__')
self.model.eval()
self.skyboxengine = SkyBox(
- out_size=self.out_size, skybox_img=skybox_img, skybox_video=skybox_video,
- halo_effect=halo_effect, auto_light_matching=auto_light_matching,
- relighting_factor=relighting_factor, recoloring_factor=recoloring_factor,
- skybox_center_crop=skybox_center_crop, rain_cap_path=rain_cap_path,
- is_video=is_video, is_rainy=is_rainy
- )
+ out_size=self.out_size,
+ skybox_img=skybox_img,
+ skybox_video=skybox_video,
+ halo_effect=halo_effect,
+ auto_light_matching=auto_light_matching,
+ relighting_factor=relighting_factor,
+ recoloring_factor=recoloring_factor,
+ skybox_center_crop=skybox_center_crop,
+ rain_cap_path=rain_cap_path,
+ is_video=is_video,
+ is_rainy=is_rainy)
path, _ = os.path.split(save_path)
if path == '':
path = '.'
if not os.path.exists(path):
os.mkdir(path)
- self.video_writer = cv2.VideoWriter(save_path, cv2.VideoWriter_fourcc(*'MP4V'),
- self.fps, self.out_size)
+ self.video_writer = cv2.VideoWriter(save_path, cv2.VideoWriter_fourcc(*'MP4V'), self.fps, self.out_size)
def synthesize(self, img_HD, img_HD_prev):
h, w, _ = img_HD.shape
@@ -50,8 +50,7 @@ class SkyFilter():
img = paddle.to_tensor(img)
G_pred = self.model(img)
- G_pred = paddle.nn.functional.interpolate(
- G_pred, (h, w), mode='bicubic', align_corners=False)
+ G_pred = paddle.nn.functional.interpolate(G_pred, (h, w), mode='bicubic', align_corners=False)
G_pred = G_pred[0, :].transpose([1, 2, 0])
G_pred = paddle.concat([G_pred, G_pred, G_pred], axis=-1)
G_pred = G_pred.detach().numpy()
@@ -68,7 +67,7 @@ class SkyFilter():
frames_num = preview_frames_num if 0 < preview_frames_num < self.m_frames else self.m_frames
print('frames_num: %d, running evaluation...' % frames_num)
- for idx in range(1, frames_num+1):
+ for idx in range(1, frames_num + 1):
ret, frame = self.cap.read()
if ret:
frame = cv2.resize(frame, self.out_size)
@@ -84,7 +83,7 @@ class SkyFilter():
if self.is_show:
show_img = np.concatenate([frame, result], 1)
h, w = show_img.shape[:2]
- show_img = cv2.resize(show_img, (720, int(720/w*h)))
+ show_img = cv2.resize(show_img, (720, int(720 / w * h)))
cv2.imshow('preview', show_img)
k = cv2.waitKey(1)
if (k == 27) or (cv2.getWindowProperty('preview', 0) == -1):
diff --git a/modules/thirdparty/video/Video_editing/SkyAR/utils.py b/modules/thirdparty/video/Video_editing/SkyAR/utils.py
index 923c79a4..1dbe3cb1 100644
--- a/modules/thirdparty/video/Video_editing/SkyAR/utils.py
+++ b/modules/thirdparty/video/Video_editing/SkyAR/utils.py
@@ -3,10 +3,7 @@ import numpy as np
from sklearn.neighbors import KernelDensity
__all__ = [
- 'build_transformation_matrix',
- 'update_transformation_matrix',
- 'estimate_partial_transform',
- 'removeOutliers',
+ 'build_transformation_matrix', 'update_transformation_matrix', 'estimate_partial_transform', 'removeOutliers',
'guidedfilter'
]
@@ -48,8 +45,7 @@ def estimate_partial_transform(matched_keypoints):
:return: transform as list of [dx, dy, da]
"""
prev_matched_kp, cur_matched_kp = matched_keypoints
- transform = cv2.estimateAffinePartial2D(np.array(prev_matched_kp),
- np.array(cur_matched_kp))[0]
+ transform = cv2.estimateAffinePartial2D(np.array(prev_matched_kp), np.array(cur_matched_kp))[0]
if transform is not None:
# translation x
@@ -83,16 +79,14 @@ def boxfilter(img, r):
imDst = np.zeros_like(img)
imCum = np.cumsum(img, 0)
- imDst[0: r+1, :] = imCum[r: 2*r+1, :]
- imDst[r+1: rows-r, :] = imCum[2*r+1: rows, :] - imCum[0: rows-2*r-1, :]
- imDst[rows-r: rows, :] = np.tile(imCum[rows-1, :],
- [r, 1]) - imCum[rows-2*r-1: rows-r-1, :]
+ imDst[0:r + 1, :] = imCum[r:2 * r + 1, :]
+ imDst[r + 1:rows - r, :] = imCum[2 * r + 1:rows, :] - imCum[0:rows - 2 * r - 1, :]
+ imDst[rows - r:rows, :] = np.tile(imCum[rows - 1, :], [r, 1]) - imCum[rows - 2 * r - 1:rows - r - 1, :]
imCum = np.cumsum(imDst, 1)
- imDst[:, 0: r+1] = imCum[:, r: 2*r+1]
- imDst[:, r+1: cols-r] = imCum[:, 2*r+1: cols] - imCum[:, 0: cols-2*r-1]
- imDst[:, cols-r: cols] = np.tile(imCum[:, cols-1],
- [r, 1]).T - imCum[:, cols-2*r-1: cols-r-1]
+ imDst[:, 0:r + 1] = imCum[:, r:2 * r + 1]
+ imDst[:, r + 1:cols - r] = imCum[:, 2 * r + 1:cols] - imCum[:, 0:cols - 2 * r - 1]
+ imDst[:, cols - r:cols] = np.tile(imCum[:, cols - 1], [r, 1]).T - imCum[:, cols - 2 * r - 1:cols - r - 1]
return imDst
diff --git a/paddlehub/compat/module/module_desc_pb2.py b/paddlehub/compat/module/module_desc_pb2.py
index ed927da7..30e647dc 100644
--- a/paddlehub/compat/module/module_desc_pb2.py
+++ b/paddlehub/compat/module/module_desc_pb2.py
@@ -64,36 +64,38 @@ _KVDATA_KEYTYPEENTRY = _descriptor.Descriptor(
file=DESCRIPTOR,
containing_type=None,
fields=[
- _descriptor.FieldDescriptor(name='key',
- full_name='paddlehub.module.desc.KVData.KeyTypeEntry.key',
- index=0,
- number=1,
- type=9,
- cpp_type=9,
- label=1,
- has_default_value=False,
- default_value=_b("").decode('utf-8'),
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- options=None),
- _descriptor.FieldDescriptor(name='value',
- full_name='paddlehub.module.desc.KVData.KeyTypeEntry.value',
- index=1,
- number=2,
- type=14,
- cpp_type=8,
- label=1,
- has_default_value=False,
- default_value=0,
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- options=None),
+ _descriptor.FieldDescriptor(
+ name='key',
+ full_name='paddlehub.module.desc.KVData.KeyTypeEntry.key',
+ index=0,
+ number=1,
+ type=9,
+ cpp_type=9,
+ label=1,
+ has_default_value=False,
+ default_value=_b("").decode('utf-8'),
+ message_type=None,
+ enum_type=None,
+ containing_type=None,
+ is_extension=False,
+ extension_scope=None,
+ options=None),
+ _descriptor.FieldDescriptor(
+ name='value',
+ full_name='paddlehub.module.desc.KVData.KeyTypeEntry.value',
+ index=1,
+ number=2,
+ type=14,
+ cpp_type=8,
+ label=1,
+ has_default_value=False,
+ default_value=0,
+ message_type=None,
+ enum_type=None,
+ containing_type=None,
+ is_extension=False,
+ extension_scope=None,
+ options=None),
],
extensions=[],
nested_types=[],
@@ -114,36 +116,38 @@ _KVDATA_DATAENTRY = _descriptor.Descriptor(
file=DESCRIPTOR,
containing_type=None,
fields=[
- _descriptor.FieldDescriptor(name='key',
- full_name='paddlehub.module.desc.KVData.DataEntry.key',
- index=0,
- number=1,
- type=9,
- cpp_type=9,
- label=1,
- has_default_value=False,
- default_value=_b("").decode('utf-8'),
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- options=None),
- _descriptor.FieldDescriptor(name='value',
- full_name='paddlehub.module.desc.KVData.DataEntry.value',
- index=1,
- number=2,
- type=11,
- cpp_type=10,
- label=1,
- has_default_value=False,
- default_value=None,
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- options=None),
+ _descriptor.FieldDescriptor(
+ name='key',
+ full_name='paddlehub.module.desc.KVData.DataEntry.key',
+ index=0,
+ number=1,
+ type=9,
+ cpp_type=9,
+ label=1,
+ has_default_value=False,
+ default_value=_b("").decode('utf-8'),
+ message_type=None,
+ enum_type=None,
+ containing_type=None,
+ is_extension=False,
+ extension_scope=None,
+ options=None),
+ _descriptor.FieldDescriptor(
+ name='value',
+ full_name='paddlehub.module.desc.KVData.DataEntry.value',
+ index=1,
+ number=2,
+ type=11,
+ cpp_type=10,
+ label=1,
+ has_default_value=False,
+ default_value=None,
+ message_type=None,
+ enum_type=None,
+ containing_type=None,
+ is_extension=False,
+ extension_scope=None,
+ options=None),
],
extensions=[],
nested_types=[],
@@ -164,36 +168,38 @@ _KVDATA = _descriptor.Descriptor(
file=DESCRIPTOR,
containing_type=None,
fields=[
- _descriptor.FieldDescriptor(name='key_type',
- full_name='paddlehub.module.desc.KVData.key_type',
- index=0,
- number=1,
- type=11,
- cpp_type=10,
- label=3,
- has_default_value=False,
- default_value=[],
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- options=None),
- _descriptor.FieldDescriptor(name='data',
- full_name='paddlehub.module.desc.KVData.data',
- index=1,
- number=2,
- type=11,
- cpp_type=10,
- label=3,
- has_default_value=False,
- default_value=[],
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- options=None),
+ _descriptor.FieldDescriptor(
+ name='key_type',
+ full_name='paddlehub.module.desc.KVData.key_type',
+ index=0,
+ number=1,
+ type=11,
+ cpp_type=10,
+ label=3,
+ has_default_value=False,
+ default_value=[],
+ message_type=None,
+ enum_type=None,
+ containing_type=None,
+ is_extension=False,
+ extension_scope=None,
+ options=None),
+ _descriptor.FieldDescriptor(
+ name='data',
+ full_name='paddlehub.module.desc.KVData.data',
+ index=1,
+ number=2,
+ type=11,
+ cpp_type=10,
+ label=3,
+ has_default_value=False,
+ default_value=[],
+ message_type=None,
+ enum_type=None,
+ containing_type=None,
+ is_extension=False,
+ extension_scope=None,
+ options=None),
],
extensions=[],
nested_types=[
@@ -217,171 +223,182 @@ _MODULEATTR = _descriptor.Descriptor(
file=DESCRIPTOR,
containing_type=None,
fields=[
- _descriptor.FieldDescriptor(name='type',
- full_name='paddlehub.module.desc.ModuleAttr.type',
- index=0,
- number=1,
- type=14,
- cpp_type=8,
- label=1,
- has_default_value=False,
- default_value=0,
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- options=None),
- _descriptor.FieldDescriptor(name='i',
- full_name='paddlehub.module.desc.ModuleAttr.i',
- index=1,
- number=2,
- type=3,
- cpp_type=2,
- label=1,
- has_default_value=False,
- default_value=0,
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- options=None),
- _descriptor.FieldDescriptor(name='f',
- full_name='paddlehub.module.desc.ModuleAttr.f',
- index=2,
- number=3,
- type=1,
- cpp_type=5,
- label=1,
- has_default_value=False,
- default_value=float(0),
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- options=None),
- _descriptor.FieldDescriptor(name='b',
- full_name='paddlehub.module.desc.ModuleAttr.b',
- index=3,
- number=4,
- type=8,
- cpp_type=7,
- label=1,
- has_default_value=False,
- default_value=False,
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- options=None),
- _descriptor.FieldDescriptor(name='s',
- full_name='paddlehub.module.desc.ModuleAttr.s',
- index=4,
- number=5,
- type=9,
- cpp_type=9,
- label=1,
- has_default_value=False,
- default_value=_b("").decode('utf-8'),
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- options=None),
- _descriptor.FieldDescriptor(name='map',
- full_name='paddlehub.module.desc.ModuleAttr.map',
- index=5,
- number=6,
- type=11,
- cpp_type=10,
- label=1,
- has_default_value=False,
- default_value=None,
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- options=None),
- _descriptor.FieldDescriptor(name='list',
- full_name='paddlehub.module.desc.ModuleAttr.list',
- index=6,
- number=7,
- type=11,
- cpp_type=10,
- label=1,
- has_default_value=False,
- default_value=None,
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- options=None),
- _descriptor.FieldDescriptor(name='set',
- full_name='paddlehub.module.desc.ModuleAttr.set',
- index=7,
- number=8,
- type=11,
- cpp_type=10,
- label=1,
- has_default_value=False,
- default_value=None,
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- options=None),
- _descriptor.FieldDescriptor(name='object',
- full_name='paddlehub.module.desc.ModuleAttr.object',
- index=8,
- number=9,
- type=11,
- cpp_type=10,
- label=1,
- has_default_value=False,
- default_value=None,
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- options=None),
- _descriptor.FieldDescriptor(name='name',
- full_name='paddlehub.module.desc.ModuleAttr.name',
- index=9,
- number=10,
- type=9,
- cpp_type=9,
- label=1,
- has_default_value=False,
- default_value=_b("").decode('utf-8'),
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- options=None),
- _descriptor.FieldDescriptor(name='info',
- full_name='paddlehub.module.desc.ModuleAttr.info',
- index=10,
- number=11,
- type=9,
- cpp_type=9,
- label=1,
- has_default_value=False,
- default_value=_b("").decode('utf-8'),
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- options=None),
+ _descriptor.FieldDescriptor(
+ name='type',
+ full_name='paddlehub.module.desc.ModuleAttr.type',
+ index=0,
+ number=1,
+ type=14,
+ cpp_type=8,
+ label=1,
+ has_default_value=False,
+ default_value=0,
+ message_type=None,
+ enum_type=None,
+ containing_type=None,
+ is_extension=False,
+ extension_scope=None,
+ options=None),
+ _descriptor.FieldDescriptor(
+ name='i',
+ full_name='paddlehub.module.desc.ModuleAttr.i',
+ index=1,
+ number=2,
+ type=3,
+ cpp_type=2,
+ label=1,
+ has_default_value=False,
+ default_value=0,
+ message_type=None,
+ enum_type=None,
+ containing_type=None,
+ is_extension=False,
+ extension_scope=None,
+ options=None),
+ _descriptor.FieldDescriptor(
+ name='f',
+ full_name='paddlehub.module.desc.ModuleAttr.f',
+ index=2,
+ number=3,
+ type=1,
+ cpp_type=5,
+ label=1,
+ has_default_value=False,
+ default_value=float(0),
+ message_type=None,
+ enum_type=None,
+ containing_type=None,
+ is_extension=False,
+ extension_scope=None,
+ options=None),
+ _descriptor.FieldDescriptor(
+ name='b',
+ full_name='paddlehub.module.desc.ModuleAttr.b',
+ index=3,
+ number=4,
+ type=8,
+ cpp_type=7,
+ label=1,
+ has_default_value=False,
+ default_value=False,
+ message_type=None,
+ enum_type=None,
+ containing_type=None,
+ is_extension=False,
+ extension_scope=None,
+ options=None),
+ _descriptor.FieldDescriptor(
+ name='s',
+ full_name='paddlehub.module.desc.ModuleAttr.s',
+ index=4,
+ number=5,
+ type=9,
+ cpp_type=9,
+ label=1,
+ has_default_value=False,
+ default_value=_b("").decode('utf-8'),
+ message_type=None,
+ enum_type=None,
+ containing_type=None,
+ is_extension=False,
+ extension_scope=None,
+ options=None),
+ _descriptor.FieldDescriptor(
+ name='map',
+ full_name='paddlehub.module.desc.ModuleAttr.map',
+ index=5,
+ number=6,
+ type=11,
+ cpp_type=10,
+ label=1,
+ has_default_value=False,
+ default_value=None,
+ message_type=None,
+ enum_type=None,
+ containing_type=None,
+ is_extension=False,
+ extension_scope=None,
+ options=None),
+ _descriptor.FieldDescriptor(
+ name='list',
+ full_name='paddlehub.module.desc.ModuleAttr.list',
+ index=6,
+ number=7,
+ type=11,
+ cpp_type=10,
+ label=1,
+ has_default_value=False,
+ default_value=None,
+ message_type=None,
+ enum_type=None,
+ containing_type=None,
+ is_extension=False,
+ extension_scope=None,
+ options=None),
+ _descriptor.FieldDescriptor(
+ name='set',
+ full_name='paddlehub.module.desc.ModuleAttr.set',
+ index=7,
+ number=8,
+ type=11,
+ cpp_type=10,
+ label=1,
+ has_default_value=False,
+ default_value=None,
+ message_type=None,
+ enum_type=None,
+ containing_type=None,
+ is_extension=False,
+ extension_scope=None,
+ options=None),
+ _descriptor.FieldDescriptor(
+ name='object',
+ full_name='paddlehub.module.desc.ModuleAttr.object',
+ index=8,
+ number=9,
+ type=11,
+ cpp_type=10,
+ label=1,
+ has_default_value=False,
+ default_value=None,
+ message_type=None,
+ enum_type=None,
+ containing_type=None,
+ is_extension=False,
+ extension_scope=None,
+ options=None),
+ _descriptor.FieldDescriptor(
+ name='name',
+ full_name='paddlehub.module.desc.ModuleAttr.name',
+ index=9,
+ number=10,
+ type=9,
+ cpp_type=9,
+ label=1,
+ has_default_value=False,
+ default_value=_b("").decode('utf-8'),
+ message_type=None,
+ enum_type=None,
+ containing_type=None,
+ is_extension=False,
+ extension_scope=None,
+ options=None),
+ _descriptor.FieldDescriptor(
+ name='info',
+ full_name='paddlehub.module.desc.ModuleAttr.info',
+ index=10,
+ number=11,
+ type=9,
+ cpp_type=9,
+ label=1,
+ has_default_value=False,
+ default_value=_b("").decode('utf-8'),
+ message_type=None,
+ enum_type=None,
+ containing_type=None,
+ is_extension=False,
+ extension_scope=None,
+ options=None),
],
extensions=[],
nested_types=[],
@@ -402,36 +419,38 @@ _FEEDDESC = _descriptor.Descriptor(
file=DESCRIPTOR,
containing_type=None,
fields=[
- _descriptor.FieldDescriptor(name='var_name',
- full_name='paddlehub.module.desc.FeedDesc.var_name',
- index=0,
- number=1,
- type=9,
- cpp_type=9,
- label=1,
- has_default_value=False,
- default_value=_b("").decode('utf-8'),
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- options=None),
- _descriptor.FieldDescriptor(name='alias',
- full_name='paddlehub.module.desc.FeedDesc.alias',
- index=1,
- number=2,
- type=9,
- cpp_type=9,
- label=1,
- has_default_value=False,
- default_value=_b("").decode('utf-8'),
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- options=None),
+ _descriptor.FieldDescriptor(
+ name='var_name',
+ full_name='paddlehub.module.desc.FeedDesc.var_name',
+ index=0,
+ number=1,
+ type=9,
+ cpp_type=9,
+ label=1,
+ has_default_value=False,
+ default_value=_b("").decode('utf-8'),
+ message_type=None,
+ enum_type=None,
+ containing_type=None,
+ is_extension=False,
+ extension_scope=None,
+ options=None),
+ _descriptor.FieldDescriptor(
+ name='alias',
+ full_name='paddlehub.module.desc.FeedDesc.alias',
+ index=1,
+ number=2,
+ type=9,
+ cpp_type=9,
+ label=1,
+ has_default_value=False,
+ default_value=_b("").decode('utf-8'),
+ message_type=None,
+ enum_type=None,
+ containing_type=None,
+ is_extension=False,
+ extension_scope=None,
+ options=None),
],
extensions=[],
nested_types=[],
@@ -452,36 +471,38 @@ _FETCHDESC = _descriptor.Descriptor(
file=DESCRIPTOR,
containing_type=None,
fields=[
- _descriptor.FieldDescriptor(name='var_name',
- full_name='paddlehub.module.desc.FetchDesc.var_name',
- index=0,
- number=1,
- type=9,
- cpp_type=9,
- label=1,
- has_default_value=False,
- default_value=_b("").decode('utf-8'),
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- options=None),
- _descriptor.FieldDescriptor(name='alias',
- full_name='paddlehub.module.desc.FetchDesc.alias',
- index=1,
- number=2,
- type=9,
- cpp_type=9,
- label=1,
- has_default_value=False,
- default_value=_b("").decode('utf-8'),
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- options=None),
+ _descriptor.FieldDescriptor(
+ name='var_name',
+ full_name='paddlehub.module.desc.FetchDesc.var_name',
+ index=0,
+ number=1,
+ type=9,
+ cpp_type=9,
+ label=1,
+ has_default_value=False,
+ default_value=_b("").decode('utf-8'),
+ message_type=None,
+ enum_type=None,
+ containing_type=None,
+ is_extension=False,
+ extension_scope=None,
+ options=None),
+ _descriptor.FieldDescriptor(
+ name='alias',
+ full_name='paddlehub.module.desc.FetchDesc.alias',
+ index=1,
+ number=2,
+ type=9,
+ cpp_type=9,
+ label=1,
+ has_default_value=False,
+ default_value=_b("").decode('utf-8'),
+ message_type=None,
+ enum_type=None,
+ containing_type=None,
+ is_extension=False,
+ extension_scope=None,
+ options=None),
],
extensions=[],
nested_types=[],
@@ -502,36 +523,38 @@ _MODULEVAR = _descriptor.Descriptor(
file=DESCRIPTOR,
containing_type=None,
fields=[
- _descriptor.FieldDescriptor(name='fetch_desc',
- full_name='paddlehub.module.desc.ModuleVar.fetch_desc',
- index=0,
- number=1,
- type=11,
- cpp_type=10,
- label=3,
- has_default_value=False,
- default_value=[],
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- options=None),
- _descriptor.FieldDescriptor(name='feed_desc',
- full_name='paddlehub.module.desc.ModuleVar.feed_desc',
- index=1,
- number=2,
- type=11,
- cpp_type=10,
- label=3,
- has_default_value=False,
- default_value=[],
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- options=None),
+ _descriptor.FieldDescriptor(
+ name='fetch_desc',
+ full_name='paddlehub.module.desc.ModuleVar.fetch_desc',
+ index=0,
+ number=1,
+ type=11,
+ cpp_type=10,
+ label=3,
+ has_default_value=False,
+ default_value=[],
+ message_type=None,
+ enum_type=None,
+ containing_type=None,
+ is_extension=False,
+ extension_scope=None,
+ options=None),
+ _descriptor.FieldDescriptor(
+ name='feed_desc',
+ full_name='paddlehub.module.desc.ModuleVar.feed_desc',
+ index=1,
+ number=2,
+ type=11,
+ cpp_type=10,
+ label=3,
+ has_default_value=False,
+ default_value=[],
+ message_type=None,
+ enum_type=None,
+ containing_type=None,
+ is_extension=False,
+ extension_scope=None,
+ options=None),
],
extensions=[],
nested_types=[],
@@ -552,36 +575,38 @@ _MODULEDESC_SIGN2VARENTRY = _descriptor.Descriptor(
file=DESCRIPTOR,
containing_type=None,
fields=[
- _descriptor.FieldDescriptor(name='key',
- full_name='paddlehub.module.desc.ModuleDesc.Sign2varEntry.key',
- index=0,
- number=1,
- type=9,
- cpp_type=9,
- label=1,
- has_default_value=False,
- default_value=_b("").decode('utf-8'),
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- options=None),
- _descriptor.FieldDescriptor(name='value',
- full_name='paddlehub.module.desc.ModuleDesc.Sign2varEntry.value',
- index=1,
- number=2,
- type=11,
- cpp_type=10,
- label=1,
- has_default_value=False,
- default_value=None,
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- options=None),
+ _descriptor.FieldDescriptor(
+ name='key',
+ full_name='paddlehub.module.desc.ModuleDesc.Sign2varEntry.key',
+ index=0,
+ number=1,
+ type=9,
+ cpp_type=9,
+ label=1,
+ has_default_value=False,
+ default_value=_b("").decode('utf-8'),
+ message_type=None,
+ enum_type=None,
+ containing_type=None,
+ is_extension=False,
+ extension_scope=None,
+ options=None),
+ _descriptor.FieldDescriptor(
+ name='value',
+ full_name='paddlehub.module.desc.ModuleDesc.Sign2varEntry.value',
+ index=1,
+ number=2,
+ type=11,
+ cpp_type=10,
+ label=1,
+ has_default_value=False,
+ default_value=None,
+ message_type=None,
+ enum_type=None,
+ containing_type=None,
+ is_extension=False,
+ extension_scope=None,
+ options=None),
],
extensions=[],
nested_types=[],
@@ -602,36 +627,38 @@ _MODULEDESC = _descriptor.Descriptor(
file=DESCRIPTOR,
containing_type=None,
fields=[
- _descriptor.FieldDescriptor(name='sign2var',
- full_name='paddlehub.module.desc.ModuleDesc.sign2var',
- index=0,
- number=2,
- type=11,
- cpp_type=10,
- label=3,
- has_default_value=False,
- default_value=[],
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- options=None),
- _descriptor.FieldDescriptor(name='attr',
- full_name='paddlehub.module.desc.ModuleDesc.attr',
- index=1,
- number=3,
- type=11,
- cpp_type=10,
- label=1,
- has_default_value=False,
- default_value=None,
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- options=None),
+ _descriptor.FieldDescriptor(
+ name='sign2var',
+ full_name='paddlehub.module.desc.ModuleDesc.sign2var',
+ index=0,
+ number=2,
+ type=11,
+ cpp_type=10,
+ label=3,
+ has_default_value=False,
+ default_value=[],
+ message_type=None,
+ enum_type=None,
+ containing_type=None,
+ is_extension=False,
+ extension_scope=None,
+ options=None),
+ _descriptor.FieldDescriptor(
+ name='attr',
+ full_name='paddlehub.module.desc.ModuleDesc.attr',
+ index=1,
+ number=3,
+ type=11,
+ cpp_type=10,
+ label=1,
+ has_default_value=False,
+ default_value=None,
+ message_type=None,
+ enum_type=None,
+ containing_type=None,
+ is_extension=False,
+ extension_scope=None,
+ options=None),
],
extensions=[],
nested_types=[
@@ -679,17 +706,19 @@ KVData = _reflection.GeneratedProtocolMessageType(
KeyTypeEntry=_reflection.GeneratedProtocolMessageType(
'KeyTypeEntry',
(_message.Message, ),
- dict(DESCRIPTOR=_KVDATA_KEYTYPEENTRY,
- __module__='module_desc_pb2'
- # @@protoc_insertion_point(class_scope:paddlehub.module.desc.KVData.KeyTypeEntry)
- )),
+ dict(
+ DESCRIPTOR=_KVDATA_KEYTYPEENTRY,
+ __module__='module_desc_pb2'
+ # @@protoc_insertion_point(class_scope:paddlehub.module.desc.KVData.KeyTypeEntry)
+ )),
DataEntry=_reflection.GeneratedProtocolMessageType(
'DataEntry',
(_message.Message, ),
- dict(DESCRIPTOR=_KVDATA_DATAENTRY,
- __module__='module_desc_pb2'
- # @@protoc_insertion_point(class_scope:paddlehub.module.desc.KVData.DataEntry)
- )),
+ dict(
+ DESCRIPTOR=_KVDATA_DATAENTRY,
+ __module__='module_desc_pb2'
+ # @@protoc_insertion_point(class_scope:paddlehub.module.desc.KVData.DataEntry)
+ )),
DESCRIPTOR=_KVDATA,
__module__='module_desc_pb2'
# @@protoc_insertion_point(class_scope:paddlehub.module.desc.KVData)
@@ -701,37 +730,41 @@ _sym_db.RegisterMessage(KVData.DataEntry)
ModuleAttr = _reflection.GeneratedProtocolMessageType(
'ModuleAttr',
(_message.Message, ),
- dict(DESCRIPTOR=_MODULEATTR,
- __module__='module_desc_pb2'
- # @@protoc_insertion_point(class_scope:paddlehub.module.desc.ModuleAttr)
- ))
+ dict(
+ DESCRIPTOR=_MODULEATTR,
+ __module__='module_desc_pb2'
+ # @@protoc_insertion_point(class_scope:paddlehub.module.desc.ModuleAttr)
+ ))
_sym_db.RegisterMessage(ModuleAttr)
FeedDesc = _reflection.GeneratedProtocolMessageType(
'FeedDesc',
(_message.Message, ),
- dict(DESCRIPTOR=_FEEDDESC,
- __module__='module_desc_pb2'
- # @@protoc_insertion_point(class_scope:paddlehub.module.desc.FeedDesc)
- ))
+ dict(
+ DESCRIPTOR=_FEEDDESC,
+ __module__='module_desc_pb2'
+ # @@protoc_insertion_point(class_scope:paddlehub.module.desc.FeedDesc)
+ ))
_sym_db.RegisterMessage(FeedDesc)
FetchDesc = _reflection.GeneratedProtocolMessageType(
'FetchDesc',
(_message.Message, ),
- dict(DESCRIPTOR=_FETCHDESC,
- __module__='module_desc_pb2'
- # @@protoc_insertion_point(class_scope:paddlehub.module.desc.FetchDesc)
- ))
+ dict(
+ DESCRIPTOR=_FETCHDESC,
+ __module__='module_desc_pb2'
+ # @@protoc_insertion_point(class_scope:paddlehub.module.desc.FetchDesc)
+ ))
_sym_db.RegisterMessage(FetchDesc)
ModuleVar = _reflection.GeneratedProtocolMessageType(
'ModuleVar',
(_message.Message, ),
- dict(DESCRIPTOR=_MODULEVAR,
- __module__='module_desc_pb2'
- # @@protoc_insertion_point(class_scope:paddlehub.module.desc.ModuleVar)
- ))
+ dict(
+ DESCRIPTOR=_MODULEVAR,
+ __module__='module_desc_pb2'
+ # @@protoc_insertion_point(class_scope:paddlehub.module.desc.ModuleVar)
+ ))
_sym_db.RegisterMessage(ModuleVar)
ModuleDesc = _reflection.GeneratedProtocolMessageType(
@@ -741,10 +774,11 @@ ModuleDesc = _reflection.GeneratedProtocolMessageType(
Sign2varEntry=_reflection.GeneratedProtocolMessageType(
'Sign2varEntry',
(_message.Message, ),
- dict(DESCRIPTOR=_MODULEDESC_SIGN2VARENTRY,
- __module__='module_desc_pb2'
- # @@protoc_insertion_point(class_scope:paddlehub.module.desc.ModuleDesc.Sign2varEntry)
- )),
+ dict(
+ DESCRIPTOR=_MODULEDESC_SIGN2VARENTRY,
+ __module__='module_desc_pb2'
+ # @@protoc_insertion_point(class_scope:paddlehub.module.desc.ModuleDesc.Sign2varEntry)
+ )),
DESCRIPTOR=_MODULEDESC,
__module__='module_desc_pb2'
# @@protoc_insertion_point(class_scope:paddlehub.module.desc.ModuleDesc)
diff --git a/paddlehub/datasets/base_audio_dataset.py b/paddlehub/datasets/base_audio_dataset.py
index 18b70e7e..bd6d0037 100644
--- a/paddlehub/datasets/base_audio_dataset.py
+++ b/paddlehub/datasets/base_audio_dataset.py
@@ -27,6 +27,7 @@ class InputExample(object):
"""
Input example of one audio sample.
"""
+
def __init__(self, guid: int, source: Union[list, str], label: Optional[str] = None):
self.guid = guid
self.source = source
@@ -37,6 +38,7 @@ class BaseAudioDataset(object):
"""
Base class of speech dataset.
"""
+
def __init__(self, base_path: str, data_file: str, mode: Optional[str] = "train"):
self.data_file = os.path.join(base_path, data_file)
self.mode = mode
@@ -92,19 +94,20 @@ class AudioClassificationDataset(BaseAudioDataset, paddle.io.Dataset):
if self.feat_type == 'raw':
record['feat'] = example.source
elif self.feat_type == 'mel':
- record['feat'] = extract_melspectrogram(example.source,
- sample_rate=self.feat_cfg['sample_rate'],
- window_size=self.feat_cfg['window_size'],
- hop_size=self.feat_cfg['hop_size'],
- mel_bins=self.feat_cfg['mel_bins'],
- fmin=self.feat_cfg['fmin'],
- fmax=self.feat_cfg['fmax'],
- window=self.feat_cfg['window'],
- center=True,
- pad_mode='reflect',
- ref=1.0,
- amin=1e-10,
- top_db=None)
+ record['feat'] = extract_melspectrogram(
+ example.source,
+ sample_rate=self.feat_cfg['sample_rate'],
+ window_size=self.feat_cfg['window_size'],
+ hop_size=self.feat_cfg['hop_size'],
+ mel_bins=self.feat_cfg['mel_bins'],
+ fmin=self.feat_cfg['fmin'],
+ fmax=self.feat_cfg['fmax'],
+ window=self.feat_cfg['window'],
+ center=True,
+ pad_mode='reflect',
+ ref=1.0,
+ amin=1e-10,
+ top_db=None)
else:
raise RuntimeError(\
f"Unknown type of self.feat_type: {self.feat_type}, it must be one in {self._supported_features}")
diff --git a/paddlehub/datasets/base_nlp_dataset.py b/paddlehub/datasets/base_nlp_dataset.py
index a98fd93e..cd4d2a3d 100644
--- a/paddlehub/datasets/base_nlp_dataset.py
+++ b/paddlehub/datasets/base_nlp_dataset.py
@@ -557,7 +557,9 @@ class TextMatchingDataset(BaseNLPDataset, paddle.io.Dataset):
pad_to_max_seq_len=True, return_length=True)
record = {'text_a': record_a, 'text_b': record_b}
else:
- raise RuntimeError("Unknown type of self.tokenizer: {}, it must be an instance of PretrainedTokenizer".format(type(self.tokenizer)))
+ raise RuntimeError(
+ "Unknown type of self.tokenizer: {}, it must be an instance of PretrainedTokenizer".format(
+ type(self.tokenizer)))
if not record:
logger.info(
@@ -582,7 +584,9 @@ class TextMatchingDataset(BaseNLPDataset, paddle.io.Dataset):
else:
return query_input_ids, query_token_type_ids, title_input_ids, title_token_type_ids
else:
- raise RuntimeError("Unknown type of self.tokenizer: {}, it must be an instance of PretrainedTokenizer".format(type(self.tokenizer)))
+ raise RuntimeError(
+ "Unknown type of self.tokenizer: {}, it must be an instance of PretrainedTokenizer".format(
+ type(self.tokenizer)))
def __len__(self):
return len(self.records)
diff --git a/paddlehub/datasets/base_seg_dataset.py b/paddlehub/datasets/base_seg_dataset.py
index 1cea3e9e..0c51496d 100644
--- a/paddlehub/datasets/base_seg_dataset.py
+++ b/paddlehub/datasets/base_seg_dataset.py
@@ -63,46 +63,34 @@ class SegDataset(paddle.io.Dataset):
self.edge = edge
if mode.lower() not in ['train', 'val', 'test']:
- raise ValueError(
- "mode should be 'train', 'val' or 'test', but got {}.".format(
- mode))
+ raise ValueError("mode should be 'train', 'val' or 'test', but got {}.".format(mode))
if self.transforms is None:
raise ValueError("`transforms` is necessary, but it is None.")
self.dataset_root = dataset_root
if not os.path.exists(self.dataset_root):
- raise FileNotFoundError('there is not `dataset_root`: {}.'.format(
- self.dataset_root))
+ raise FileNotFoundError('there is not `dataset_root`: {}.'.format(self.dataset_root))
if mode == 'train':
if train_path is None:
- raise ValueError(
- 'When `mode` is "train", `train_path` is necessary, but it is None.'
- )
+ raise ValueError('When `mode` is "train", `train_path` is necessary, but it is None.')
elif not os.path.exists(train_path):
- raise FileNotFoundError(
- '`train_path` is not found: {}'.format(train_path))
+ raise FileNotFoundError('`train_path` is not found: {}'.format(train_path))
else:
file_path = train_path
elif mode == 'val':
if val_path is None:
- raise ValueError(
- 'When `mode` is "val", `val_path` is necessary, but it is None.'
- )
+ raise ValueError('When `mode` is "val", `val_path` is necessary, but it is None.')
elif not os.path.exists(val_path):
- raise FileNotFoundError(
- '`val_path` is not found: {}'.format(val_path))
+ raise FileNotFoundError('`val_path` is not found: {}'.format(val_path))
else:
file_path = val_path
else:
if test_path is None:
- raise ValueError(
- 'When `mode` is "test", `test_path` is necessary, but it is None.'
- )
+ raise ValueError('When `mode` is "test", `test_path` is necessary, but it is None.')
elif not os.path.exists(test_path):
- raise FileNotFoundError(
- '`test_path` is not found: {}'.format(test_path))
+ raise FileNotFoundError('`test_path` is not found: {}'.format(test_path))
else:
file_path = test_path
@@ -111,9 +99,8 @@ class SegDataset(paddle.io.Dataset):
items = line.strip().split(separator)
if len(items) != 2:
if mode == 'train' or mode == 'val':
- raise ValueError(
- "File list format incorrect! In training or evaluation task it should be"
- " image_name{}label_name\\n".format(separator))
+ raise ValueError("File list format incorrect! In training or evaluation task it should be"
+ " image_name{}label_name\\n".format(separator))
image_path = os.path.join(self.dataset_root, items[0])
label_path = None
else:
@@ -138,4 +125,3 @@ class SegDataset(paddle.io.Dataset):
def __len__(self) -> int:
return len(self.file_list)
-
diff --git a/paddlehub/datasets/esc50.py b/paddlehub/datasets/esc50.py
index 6081609e..8b542a99 100644
--- a/paddlehub/datasets/esc50.py
+++ b/paddlehub/datasets/esc50.py
@@ -91,20 +91,22 @@ class ESC50(AudioClassificationDataset):
else:
data_file = 'dev.npz'
- feat_cfg = dict(sample_rate=self.sample_rate,
- window_size=1024,
- hop_size=320,
- mel_bins=64,
- fmin=50,
- fmax=14000,
- window='hann')
+ feat_cfg = dict(
+ sample_rate=self.sample_rate,
+ window_size=1024,
+ hop_size=320,
+ mel_bins=64,
+ fmin=50,
+ fmax=14000,
+ window='hann')
- super().__init__(base_path=base_path,
- data_file=data_file,
- file_type='npz',
- mode=mode,
- feat_type=feat_type,
- feat_cfg=feat_cfg)
+ super().__init__(
+ base_path=base_path,
+ data_file=data_file,
+ file_type='npz',
+ mode=mode,
+ feat_type=feat_type,
+ feat_cfg=feat_cfg)
if __name__ == "__main__":
diff --git a/paddlehub/datasets/lcqmc.py b/paddlehub/datasets/lcqmc.py
index 10919a52..115a000d 100644
--- a/paddlehub/datasets/lcqmc.py
+++ b/paddlehub/datasets/lcqmc.py
@@ -57,4 +57,4 @@ if __name__ == "__main__":
model = hub.Module(name='ernie_tiny')
tokenizer = model.get_tokenizer()
- ds = LCQMC(tokenizer=tokenizer, max_seq_len=128, mode='dev')
\ No newline at end of file
+ ds = LCQMC(tokenizer=tokenizer, max_seq_len=128, mode='dev')
diff --git a/paddlehub/datasets/opticdiscseg.py b/paddlehub/datasets/opticdiscseg.py
index 2d100194..e413e262 100644
--- a/paddlehub/datasets/opticdiscseg.py
+++ b/paddlehub/datasets/opticdiscseg.py
@@ -24,6 +24,7 @@ import paddlehub.env as hubenv
from paddlehub.utils.download import download_data
from paddlehub.datasets.base_seg_dataset import SegDataset
+
@download_data(url='https://paddleseg.bj.bcebos.com/dataset/optic_disc_seg.zip')
class OpticDiscSeg(SegDataset):
"""
@@ -36,9 +37,7 @@ class OpticDiscSeg(SegDataset):
edge (bool, optional): Whether to compute edge while training. Default: False
"""
- def __init__(self,
- transforms: Callable = None,
- mode: str = 'train'):
+ def __init__(self, transforms: Callable = None, mode: str = 'train'):
self.transforms = transforms
mode = mode.lower()
self.mode = mode
@@ -47,14 +46,11 @@ class OpticDiscSeg(SegDataset):
self.ignore_index = 255
if mode not in ['train', 'val', 'test']:
- raise ValueError(
- "`mode` should be 'train', 'val' or 'test', but got {}.".format(
- mode))
+ raise ValueError("`mode` should be 'train', 'val' or 'test', but got {}.".format(mode))
if self.transforms is None:
raise ValueError("`transforms` is necessary, but it is None.")
-
if mode == 'train':
file_path = os.path.join(hubenv.DATA_HOME, 'optic_disc_seg', 'train_list.txt')
elif mode == 'test':
@@ -67,12 +63,10 @@ class OpticDiscSeg(SegDataset):
items = line.strip().split()
if len(items) != 2:
if mode == 'train' or mode == 'val':
- raise Exception(
- "File list format incorrect! It should be"
- " image_name label_name\\n")
+ raise Exception("File list format incorrect! It should be" " image_name label_name\\n")
image_path = os.path.join(hubenv.DATA_HOME, 'optic_disc_seg', items[0])
grt_path = None
else:
image_path = os.path.join(hubenv.DATA_HOME, 'optic_disc_seg', items[0])
grt_path = os.path.join(hubenv.DATA_HOME, 'optic_disc_seg', items[1])
- self.file_list.append([image_path, grt_path])
\ No newline at end of file
+ self.file_list.append([image_path, grt_path])
diff --git a/paddlehub/datasets/pascalvoc.py b/paddlehub/datasets/pascalvoc.py
index 85945dfa..9efed98d 100644
--- a/paddlehub/datasets/pascalvoc.py
+++ b/paddlehub/datasets/pascalvoc.py
@@ -35,6 +35,7 @@ class DetectCatagory:
label_ids(List(int)): The dataset label ids.
category_to_id_map(dict): Mapping relations of category and id for images.
"""
+
def __init__(self, attrbox: Callable, data_dir: str):
self.attrbox = attrbox
self.img_dir = data_dir
@@ -62,6 +63,7 @@ class ParseImages:
Returns:
imgs(dict): The input for detection model, it is a dict.
"""
+
def __init__(self, attrbox: Callable, data_dir: str, category_to_id_map: dict):
self.attrbox = attrbox
self.img_dir = data_dir
@@ -94,6 +96,7 @@ class GTAnotations:
Returns:
img(dict): Set specific value on the attributes of 'gt boxes' and 'gt labels' for input.
"""
+
def __init__(self, attrbox: Callable, category_to_id_map: dict):
self.attrbox = attrbox
self.category_to_id_map = category_to_id_map
@@ -154,6 +157,7 @@ class DetectionData(paddle.io.Dataset):
Returns:
DataSet: An iterable object for data iterating
"""
+
def __init__(self, transform: Callable, size: int = 416, mode: str = 'train'):
self.mode = mode
self.transform = transform
diff --git a/paddlehub/finetune/trainer.py b/paddlehub/finetune/trainer.py
index 33d3fe32..041361d6 100644
--- a/paddlehub/finetune/trainer.py
+++ b/paddlehub/finetune/trainer.py
@@ -67,7 +67,6 @@ class Trainer(object):
if not isinstance(self.model, paddle.nn.Layer):
raise TypeError('The model {} is not a `paddle.nn.Layer` object.'.format(self.model.__name__))
-
if self.local_rank == 0 and not os.path.exists(self.checkpoint_dir):
os.makedirs(self.checkpoint_dir)
@@ -302,7 +301,7 @@ class Trainer(object):
with logger.processing('Evaluation on validation dataset'):
for batch_idx, batch in enumerate(loader):
result = self.validation_step(batch, batch_idx)
-
+
loss = result.get('loss', None)
metrics = result.get('metrics', {})
bs = batch[0].shape[0]
@@ -368,7 +367,7 @@ class Trainer(object):
batch_idx(int) : The index of batch.
'''
if self.nranks > 1:
- result = self.model._layers.validation_step(batch, batch_idx)
+ result = self.model._layers.validation_step(batch, batch_idx)
else:
result = self.model.validation_step(batch, batch_idx)
return result
diff --git a/paddlehub/module/cv_module.py b/paddlehub/module/cv_module.py
index 4c4102f6..562f0e92 100644
--- a/paddlehub/module/cv_module.py
+++ b/paddlehub/module/cv_module.py
@@ -72,7 +72,7 @@ class ImageClassifierModule(RunModule, ImageServing):
labels = paddle.unsqueeze(batch[1], axis=-1)
preds, feature = self(images)
-
+
loss, _ = F.softmax_with_cross_entropy(preds, labels, return_softmax=True, axis=1)
loss = paddle.mean(loss)
acc = paddle.metric.accuracy(preds, labels)
@@ -94,7 +94,7 @@ class ImageClassifierModule(RunModule, ImageServing):
res = []
total_num = len(images)
loop_num = int(np.ceil(total_num / batch_size))
-
+
for iter_id in range(loop_num):
batch_data = []
handle_id = iter_id * batch_size
@@ -108,14 +108,14 @@ class ImageClassifierModule(RunModule, ImageServing):
preds, feature = self(paddle.to_tensor(batch_image))
preds = F.softmax(preds, axis=1).numpy()
pred_idxs = np.argsort(preds)[:, ::-1][:, :top_k]
-
+
for i, pred in enumerate(pred_idxs):
res_dict = {}
for k in pred:
class_name = self.labels[int(k)]
res_dict[class_name] = preds[i][k]
-
- res.append(res_dict)
+
+ res.append(res_dict)
return res
@@ -126,8 +126,8 @@ class ImageClassifierModule(RunModule, ImageServing):
"""
top_k = int(top_k)
images_decode = [base64_to_cv2(image) for image in images]
- resdicts = self.predict(images=images_decode, top_k=top_k,**kwargs)
- final={}
+ resdicts = self.predict(images=images_decode, top_k=top_k, **kwargs)
+ final = {}
for resdict in resdicts:
for key, value in resdict.items():
resdict[key] = float(value)
@@ -144,18 +144,13 @@ class ImageClassifierModule(RunModule, ImageServing):
prog='hub run {}'.format(self.name),
usage='%(prog)s',
add_help=True)
- self.arg_input_group = self.parser.add_argument_group(
- title="Input options", description="Input data. Required")
+ self.arg_input_group = self.parser.add_argument_group(title="Input options", description="Input data. Required")
self.arg_config_group = self.parser.add_argument_group(
- title="Config options",
- description=
- "Run configuration for controlling module behavior, not required.")
+ title="Config options", description="Run configuration for controlling module behavior, not required.")
self.add_module_config_arg()
self.add_module_input_arg()
args = self.parser.parse_args(argvs)
- results = self.predict(
- images=[args.input_path],
- top_k=args.top_k)
+ results = self.predict(images=[args.input_path], top_k=args.top_k)
return results
@@ -164,20 +159,15 @@ class ImageClassifierModule(RunModule, ImageServing):
Add the command config options.
"""
- self.arg_config_group.add_argument(
- '--top_k',
- type=int,
- default=1,
- help="top_k classification result.")
+ self.arg_config_group.add_argument('--top_k', type=int, default=1, help="top_k classification result.")
def add_module_input_arg(self):
"""
Add the command input options.
"""
- self.arg_input_group.add_argument(
- '--input_path', type=str, help="path to image.")
+ self.arg_input_group.add_argument('--input_path', type=str, help="path to image.")
+
-
class ImageColorizeModule(RunModule, ImageServing):
def training_step(self, batch: int, batch_idx: int) -> dict:
'''
@@ -207,7 +197,7 @@ class ImageColorizeModule(RunModule, ImageServing):
img = self.preprocess(batch)
else:
img = self.preprocess(batch[0])
-
+
out_class, out_reg = self(img['A'], img['hint_B'], img['mask_B'])
# loss
@@ -288,11 +278,11 @@ class ImageColorizeModule(RunModule, ImageServing):
"""
images_decode = [base64_to_cv2(image) for image in images]
visual = self.predict(images=images_decode, **kwargs)
- final={}
+ final = {}
for i, visual_ret in enumerate(visual):
h, w, c = images_decode[i].shape
for key, value in visual_ret.items():
- value = cv2.resize(cv2.cvtColor(value,cv2.COLOR_RGB2BGR), (w, h), cv2.INTER_NEAREST)
+ value = cv2.resize(cv2.cvtColor(value, cv2.COLOR_RGB2BGR), (w, h), cv2.INTER_NEAREST)
visual_ret[key] = cv2_to_base64(value)
final['data'] = visual
return final
@@ -307,19 +297,13 @@ class ImageColorizeModule(RunModule, ImageServing):
prog='hub run {}'.format(self.name),
usage='%(prog)s',
add_help=True)
- self.arg_input_group = self.parser.add_argument_group(
- title="Input options", description="Input data. Required")
+ self.arg_input_group = self.parser.add_argument_group(title="Input options", description="Input data. Required")
self.arg_config_group = self.parser.add_argument_group(
- title="Config options",
- description=
- "Run configuration for controlling module behavior, not required.")
+ title="Config options", description="Run configuration for controlling module behavior, not required.")
self.add_module_config_arg()
self.add_module_input_arg()
args = self.parser.parse_args(argvs)
- results = self.predict(
- images=[args.input_path],
- visualization=args.visualization,
- save_path=args.output_dir)
+ results = self.predict(images=[args.input_path], visualization=args.visualization, save_path=args.output_dir)
return results
@@ -329,22 +313,15 @@ class ImageColorizeModule(RunModule, ImageServing):
"""
self.arg_config_group.add_argument(
- '--output_dir',
- type=str,
- default='colorization',
- help="save visualization result.")
+ '--output_dir', type=str, default='colorization', help="save visualization result.")
self.arg_config_group.add_argument(
- '--visualization',
- type=bool,
- default=True,
- help="whether to save output as images.")
+ '--visualization', type=bool, default=True, help="whether to save output as images.")
def add_module_input_arg(self):
"""
Add the command input options.
"""
- self.arg_input_group.add_argument(
- '--input_path', type=str, help="path to image.")
+ self.arg_input_group.add_argument('--input_path', type=str, help="path to image.")
class Yolov3Module(RunModule, ImageServing):
@@ -523,7 +500,12 @@ class StyleTransferModule(RunModule, ImageServing):
return {'loss': loss, 'metrics': {'content gap': content_loss, 'style gap': style_loss}}
- def predict(self, origin: list, style: Union[str, np.ndarray], batch_size: int = 1, visualization: bool = True, save_path: str = 'style_tranfer'):
+ def predict(self,
+ origin: list,
+ style: Union[str, np.ndarray],
+ batch_size: int = 1,
+ visualization: bool = True,
+ save_path: str = 'style_tranfer'):
'''
Colorize images
@@ -554,7 +536,7 @@ class StyleTransferModule(RunModule, ImageServing):
except:
pass
- batch_image = np.array(batch_data)
+ batch_image = np.array(batch_data)
content = paddle.to_tensor(batch_image)
self.setTarget(style)
@@ -578,7 +560,7 @@ class StyleTransferModule(RunModule, ImageServing):
images_decode = [base64_to_cv2(image) for image in images[0]]
style_decode = base64_to_cv2(images[1])
results = self.predict(origin=images_decode, style=style_decode, **kwargs)
- final={}
+ final = {}
final['data'] = [cv2_to_base64(result) for result in results]
return final
@@ -592,12 +574,9 @@ class StyleTransferModule(RunModule, ImageServing):
prog='hub run {}'.format(self.name),
usage='%(prog)s',
add_help=True)
- self.arg_input_group = self.parser.add_argument_group(
- title="Input options", description="Input data. Required")
+ self.arg_input_group = self.parser.add_argument_group(title="Input options", description="Input data. Required")
self.arg_config_group = self.parser.add_argument_group(
- title="Config options",
- description=
- "Run configuration for controlling module behavior, not required.")
+ title="Config options", description="Run configuration for controlling module behavior, not required.")
self.add_module_config_arg()
self.add_module_input_arg()
args = self.parser.parse_args(argvs)
@@ -608,33 +587,25 @@ class StyleTransferModule(RunModule, ImageServing):
visualization=args.visualization)
return results
-
+
def add_module_config_arg(self):
"""
Add the command config options.
"""
self.arg_config_group.add_argument(
- '--output_dir',
- type=str,
- default='style_tranfer',
- help="The directory to save output images.")
+ '--output_dir', type=str, default='style_tranfer', help="The directory to save output images.")
self.arg_config_group.add_argument(
- '--visualization',
- type=bool,
- default=True,
- help="whether to save output as images.")
+ '--visualization', type=bool, default=True, help="whether to save output as images.")
def add_module_input_arg(self):
"""
Add the command input options.
"""
- self.arg_input_group.add_argument(
- '--input_path', type=str, help="path to image.")
- self.arg_input_group.add_argument(
- '--style_path', type=str, help="path to style image.")
-
+ self.arg_input_group.add_argument('--input_path', type=str, help="path to image.")
+ self.arg_input_group.add_argument('--style_path', type=str, help="path to style image.")
+
class ImageSegmentationModule(ImageServing, RunModule):
def training_step(self, batch: List[paddle.Tensor], batch_idx: int) -> dict:
@@ -647,9 +618,9 @@ class ImageSegmentationModule(ImageServing, RunModule):
Returns:
results(dict): The model outputs, such as loss.
-
+
'''
-
+
label = batch[1].astype('int64')
criterionCE = nn.loss.CrossEntropyLoss()
logits = self(batch[0])
@@ -657,15 +628,19 @@ class ImageSegmentationModule(ImageServing, RunModule):
for i in range(len(logits)):
logit = logits[i]
if logit.shape[-2:] != label.shape[-2:]:
- logit = F.interpolate(logit, label.shape[-2:], mode='bilinear')
-
- logit = logit.transpose([0,2,3,1])
+ logit = F.interpolate(logit, label.shape[-2:], mode='bilinear')
+
+ logit = logit.transpose([0, 2, 3, 1])
loss_ce = criterionCE(logit, label)
loss += loss_ce / len(logits)
-
+
return {"loss": loss}
- def predict(self, images: Union[str, np.ndarray], batch_size: int = 1, visualization: bool = True, save_path: str = 'seg_result') -> List[np.ndarray]:
+ def predict(self,
+ images: Union[str, np.ndarray],
+ batch_size: int = 1,
+ visualization: bool = True,
+ save_path: str = 'seg_result') -> List[np.ndarray]:
'''
Obtain segmentation results.
@@ -679,8 +654,8 @@ class ImageSegmentationModule(ImageServing, RunModule):
output(list[np.ndarray]) : The segmentation mask.
'''
self.eval()
- result=[]
-
+ result = []
+
total_num = len(images)
loop_num = int(np.ceil(total_num / batch_size))
for iter_id in range(loop_num):
@@ -695,19 +670,19 @@ class ImageSegmentationModule(ImageServing, RunModule):
batch_image = np.array(batch_data).astype('float32')
pred = self(paddle.to_tensor(batch_image))
pred = paddle.argmax(pred[0], axis=1, keepdim=True, dtype='int32')
-
+
for num in range(pred.shape[0]):
- if isinstance(images[handle_id+num], str):
- image = cv2.imread(images[handle_id+num])
+ if isinstance(images[handle_id + num], str):
+ image = cv2.imread(images[handle_id + num])
else:
- image = images[handle_id+num]
+ image = images[handle_id + num]
h, w, c = image.shape
- pred_final = utils.reverse_transform(pred[num: num+1], (h,w), self.transforms.transforms)
+ pred_final = utils.reverse_transform(pred[num:num + 1], (h, w), self.transforms.transforms)
pred_final = paddle.squeeze(pred_final)
pred_final = pred_final.numpy().astype('uint8')
-
+
if visualization:
- added_image = utils.visualize(images[handle_id+num], pred_final, weight=0.6)
+ added_image = utils.visualize(images[handle_id + num], pred_final, weight=0.6)
pred_mask = utils.get_pseudo_color_map(pred_final)
pred_image_path = os.path.join(save_path, 'image', str(time.time()) + ".png")
pred_mask_path = os.path.join(save_path, 'mask', str(time.time()) + ".png")
@@ -717,10 +692,10 @@ class ImageSegmentationModule(ImageServing, RunModule):
os.makedirs(os.path.dirname(pred_mask_path))
cv2.imwrite(pred_image_path, added_image)
pred_mask.save(pred_mask_path)
-
+
result.append(pred_final)
return result
-
+
@serving
def serving_method(self, images: List[str], **kwargs):
"""
@@ -728,7 +703,7 @@ class ImageSegmentationModule(ImageServing, RunModule):
"""
images_decode = [base64_to_cv2(image) for image in images]
visual = self.predict(images=images_decode, **kwargs)
- final=[]
+ final = []
for mask in visual:
- final.append(cv2_to_base64(mask))
- return final
\ No newline at end of file
+ final.append(cv2_to_base64(mask))
+ return final
diff --git a/paddlehub/utils/download.py b/paddlehub/utils/download.py
index d0d83a2e..2d2cd297 100644
--- a/paddlehub/utils/download.py
+++ b/paddlehub/utils/download.py
@@ -23,7 +23,6 @@ from paddlehub.utils import log, utils, xarfile
def download_data(url):
-
def _wrapper(Dataset):
def _check_download():
save_name = os.path.basename(url).split('.')[0]
diff --git a/paddlehub/utils/utils.py b/paddlehub/utils/utils.py
index d649fc97..bbe14747 100644
--- a/paddlehub/utils/utils.py
+++ b/paddlehub/utils/utils.py
@@ -40,6 +40,7 @@ from paddlehub.utils.log import logger
class Version(packaging.version.Version):
'''Extended implementation of packaging.version.Version'''
+
def match(self, condition: str) -> bool:
'''
Determine whether the given condition are met
@@ -105,6 +106,7 @@ class Version(packaging.version.Version):
class Timer(object):
'''Calculate runing speed and estimated time of arrival(ETA)'''
+
def __init__(self, total_step: int):
self.total_step = total_step
self.last_start_step = 0
@@ -408,13 +410,14 @@ def extract_melspectrogram(y,
logger.error('Failed to import librosa. Please check that librosa and numba are correctly installed.')
raise
- s = librosa.stft(y,
- n_fft=window_size,
- hop_length=hop_size,
- win_length=window_size,
- window=window,
- center=center,
- pad_mode=pad_mode)
+ s = librosa.stft(
+ y,
+ n_fft=window_size,
+ hop_length=hop_size,
+ win_length=window_size,
+ window=window,
+ center=center,
+ pad_mode=pad_mode)
power = np.abs(s)**2
melW = librosa.filters.mel(sr=sample_rate, n_fft=window_size, n_mels=mel_bins, fmin=fmin, fmax=fmax)
diff --git a/paddlehub/vision/segmentation_transforms.py b/paddlehub/vision/segmentation_transforms.py
index a1d4ce2a..8e971bf6 100644
--- a/paddlehub/vision/segmentation_transforms.py
+++ b/paddlehub/vision/segmentation_transforms.py
@@ -46,7 +46,7 @@ class Compose:
self.transforms = transforms
self.to_rgb = to_rgb
- def __call__(self, im: Union[np.ndarray, str], label: Union[np.ndarray, str] = None) -> Tuple:
+ def __call__(self, im: Union[np.ndarray, str], label: Union[np.ndarray, str] = None) -> Tuple:
"""
Args:
im (str|np.ndarray): It is either image path or image object.
@@ -140,23 +140,20 @@ class Padding:
"""
def __init__(self,
- target_size: Union[List[int], Tuple[int], int],
- im_padding_value: Union[List[int], Tuple[int], int] = (128, 128, 128),
+ target_size: Union[List[int], Tuple[int], int],
+ im_padding_value: Union[List[int], Tuple[int], int] = (128, 128, 128),
label_padding_value: int = 255):
if isinstance(target_size, list) or isinstance(target_size, tuple):
if len(target_size) != 2:
- raise ValueError(
- '`target_size` should include 2 elements, but it is {}'.
- format(target_size))
+ raise ValueError('`target_size` should include 2 elements, but it is {}'.format(target_size))
else:
- raise TypeError(
- "Type of target_size is invalid. It should be list or tuple, now is {}"
- .format(type(target_size)))
+ raise TypeError("Type of target_size is invalid. It should be list or tuple, now is {}".format(
+ type(target_size)))
self.target_size = target_size
self.im_padding_value = im_padding_value
self.label_padding_value = label_padding_value
- def __call__(self, im: np.ndarray , label: np.ndarray = None) -> Tuple:
+ def __call__(self, im: np.ndarray, label: np.ndarray = None) -> Tuple:
"""
Args:
im (np.ndarray): The Image data.
@@ -177,15 +174,14 @@ class Padding:
if pad_height < 0 or pad_width < 0:
raise ValueError(
'The size of image should be less than `target_size`, but the size of image ({}, {}) is larger than `target_size` ({}, {})'
- .format(im_width, im_height, target_width, target_height))
+ .format(im_width, im_height, target_width, target_height))
else:
- im = cv2.copyMakeBorder(im, 0, pad_height, 0, pad_width, cv2.BORDER_CONSTANT,
- value=self.im_padding_value)
+ im = cv2.copyMakeBorder(im, 0, pad_height, 0, pad_width, cv2.BORDER_CONSTANT, value=self.im_padding_value)
if label is not None:
- label = cv2.copyMakeBorder(label, 0, pad_height, 0, pad_width, cv2.BORDER_CONSTANT,
- value=self.label_padding_value)
+ label = cv2.copyMakeBorder(
+ label, 0, pad_height, 0, pad_width, cv2.BORDER_CONSTANT, value=self.label_padding_value)
if label is None:
- return (im,)
+ return (im, )
else:
return (im, label)
@@ -200,15 +196,13 @@ class Normalize:
ValueError: When mean/std is not list or any value in std is 0.
"""
- def __init__(self, mean: Union[List[float], Tuple[float]] = (0.5, 0.5, 0.5),
- std: Union[List[float], Tuple[float]] = (0.5, 0.5, 0.5)):
+ def __init__(self,
+ mean: Union[List[float], Tuple[float]] = (0.5, 0.5, 0.5),
+ std: Union[List[float], Tuple[float]] = (0.5, 0.5, 0.5)):
self.mean = mean
self.std = std
- if not (isinstance(self.mean, (list, tuple))
- and isinstance(self.std, (list, tuple))):
- raise ValueError(
- "{}: input type is invalid. It should be list or tuple".format(
- self))
+ if not (isinstance(self.mean, (list, tuple)) and isinstance(self.std, (list, tuple))):
+ raise ValueError("{}: input type is invalid. It should be list or tuple".format(self))
from functools import reduce
if reduce(lambda x, y: x * y, self.std) == 0:
raise ValueError('{}: std is invalid!'.format(self))
@@ -227,7 +221,7 @@ class Normalize:
im = F.normalize(im, mean, std)
if label is None:
- return (im,)
+ return (im, )
else:
return (im, label)
@@ -260,17 +254,13 @@ class Resize:
def __init__(self, target_size: Union[List[int], Tuple[int]] = (512, 512), interp: str = 'LINEAR'):
self.interp = interp
if not (interp == "RANDOM" or interp in self.interp_dict):
- raise ValueError("`interp` should be one of {}".format(
- self.interp_dict.keys()))
+ raise ValueError("`interp` should be one of {}".format(self.interp_dict.keys()))
if isinstance(target_size, list) or isinstance(target_size, tuple):
if len(target_size) != 2:
- raise ValueError(
- '`target_size` should include 2 elements, but it is {}'.
- format(target_size))
+ raise ValueError('`target_size` should include 2 elements, but it is {}'.format(target_size))
else:
- raise TypeError(
- "Type of `target_size` is invalid. It should be list or tuple, but it is {}"
- .format(type(target_size)))
+ raise TypeError("Type of `target_size` is invalid. It should be list or tuple, but it is {}".format(
+ type(target_size)))
self.target_size = target_size
@@ -298,10 +288,9 @@ class Resize:
interp = self.interp
im = F.resize(im, self.target_size, self.interp_dict[interp])
if label is not None:
- label = F.resize(label, self.target_size,
- cv2.INTER_NEAREST)
+ label = F.resize(label, self.target_size, cv2.INTER_NEAREST)
if label is None:
- return (im,)
+ return (im, )
else:
- return (im, label)
\ No newline at end of file
+ return (im, label)
diff --git a/paddlehub/vision/transforms.py b/paddlehub/vision/transforms.py
index 4946bb56..4b72fc41 100644
--- a/paddlehub/vision/transforms.py
+++ b/paddlehub/vision/transforms.py
@@ -31,6 +31,7 @@ class Compose:
to_rgb(bool): Whether to transform the input from BGR mode to RGB mode, default is False.
channel_first(bool): whether to permute image from channel laste to channel first
"""
+
def __init__(self, transforms: Callable, to_rgb: bool = False, channel_first: bool = True):
if not isinstance(transforms, list):
raise TypeError('The transforms must be a list!')
@@ -41,7 +42,7 @@ class Compose:
self.to_rgb = to_rgb
self.channel_first = channel_first
- def __call__(self, im: Union[np.ndarray, str]):
+ def __call__(self, im: Union[np.ndarray, str]):
if isinstance(im, str):
im = cv2.imread(im).astype('float32')
@@ -57,16 +58,20 @@ class Compose:
im = F.permute(im)
return im
+
class Permute:
"""
Repermute the input image from [H, W, C] to [C, H, W].
"""
+
def __init__(self):
pass
+
def __call__(self, im):
im = F.permute(im)
return im
+
class RandomHorizontalFlip:
"""
Randomly flip the image horizontally according to given probability.
@@ -74,6 +79,7 @@ class RandomHorizontalFlip:
Args:
prob(float): The probability for flipping the image horizontally, default is 0.5.
"""
+
def __init__(self, prob: float = 0.5):
self.prob = prob
@@ -90,6 +96,7 @@ class RandomVerticalFlip:
Args:
prob(float): The probability for flipping the image vertically, default is 0.5.
"""
+
def __init__(self, prob: float = 0.5):
self.prob = prob
@@ -146,6 +153,7 @@ class ResizeByLong:
Args:
long_size(int|list[int]): The target size of long side.
"""
+
def __init__(self, long_size: Union[List[int], int]):
self.long_size = long_size
@@ -162,6 +170,7 @@ class ResizeRangeScaling:
min_value(int): The minimum value for targeted size.
max_value(int): The maximum value for targeted size.
"""
+
def __init__(self, min_value: int = 400, max_value: int = 600):
if min_value > max_value:
raise ValueError('min_value must be less than max_value, '
@@ -188,6 +197,7 @@ class ResizeStepScaling:
scale_step_size(float): Scale interval.
"""
+
def __init__(self, min_scale_factor: float = 0.75, max_scale_factor: float = 1.25, scale_step_size: float = 0.25):
if min_scale_factor > max_scale_factor:
raise ValueError('min_scale_factor must be less than max_scale_factor, '
@@ -224,6 +234,7 @@ class Normalize:
std(list): Standard deviation for normalization.
channel_first(bool): im channel firest or last
"""
+
def __init__(self, mean: list = [0.5, 0.5, 0.5], std: list = [0.5, 0.5, 0.5], channel_first: bool = False):
self.mean = mean
self.std = std
@@ -253,6 +264,7 @@ class Padding:
target_size(Union[List[int], Tuple[int], int]): Targeted image size.
im_padding_value(list): Border value for 3 channels, default is [127.5, 127.5, 127.5].
"""
+
def __init__(self, target_size: Union[List[int], Tuple[int], int], im_padding_value: list = [127.5, 127.5, 127.5]):
if isinstance(target_size, list) or isinstance(target_size, tuple):
if len(target_size) != 2:
@@ -292,6 +304,7 @@ class RandomPaddingCrop:
crop_size(Union[List[int], Tuple[int], int]): Targeted image size.
im_padding_value(list): Border value for 3 channels, default is [127.5, 127.5, 127.5].
"""
+
def __init__(self, crop_size, im_padding_value=[127.5, 127.5, 127.5]):
if isinstance(crop_size, list) or isinstance(crop_size, tuple):
if len(crop_size) != 2:
@@ -339,6 +352,7 @@ class RandomBlur:
Args:
prob(float): The probability to blur the image, default is 0.1.
"""
+
def __init__(self, prob: float = 0.1):
self.prob = prob
@@ -370,6 +384,7 @@ class RandomRotation:
max_rotation(float): Upper bound of rotation angle.
im_padding_value(list): Border value for 3 channels, default is [127.5, 127.5, 127.5].
"""
+
def __init__(self, max_rotation: float = 15, im_padding_value: list = [127.5, 127.5, 127.5]):
self.max_rotation = max_rotation
self.im_padding_value = im_padding_value
@@ -401,8 +416,6 @@ class RandomRotation:
return im
-
-
class RandomDistort:
"""
Random adjust brightness, contrast, saturation and hue according to the given random range and probability, respectively.
@@ -418,6 +431,7 @@ class RandomDistort:
hue_range(float): Boundary of hue.
hue_prob(float): Probability for disturb the hue of image.
"""
+
def __init__(self,
brightness_range: float = 0.5,
brightness_prob: float = 0.5,
diff --git a/tests/test_module.py b/tests/test_module.py
index c2aa65ae..9b7a0b22 100644
--- a/tests/test_module.py
+++ b/tests/test_module.py
@@ -14,10 +14,8 @@ class TestHubModule(unittest.TestCase):
self.assertEqual(results[0]['tag'], ['TIME', 'v', 'q', 'n'])
self.assertEqual(results[1]['word'], ['天气预报', '说', '今天', '要', '下雨'])
self.assertEqual(results[1]['tag'], ['n', 'v', 'TIME', 'v', 'v'])
- self.assertEqual(results[2]['word'],
- ['下', '一班', '地铁', '马上', '就要', '到', '了'])
- self.assertEqual(results[2]['tag'],
- ['f', 'm', 'n', 'd', 'v', 'v', 'xc'])
+ self.assertEqual(results[2]['word'], ['下', '一班', '地铁', '马上', '就要', '到', '了'])
+ self.assertEqual(results[2]['tag'], ['f', 'm', 'n', 'd', 'v', 'v', 'xc'])
def test_senta(self):
senta = hub.Module(name="senta_bilstm")
@@ -45,13 +43,11 @@ class TestHubModule(unittest.TestCase):
if result['similarity'] > max_score:
max_score = result['similarity']
result_text = result['text_2']
- print("The most matching with the %s is %s" % (test_text_1[0],
- result_text))
+ print("The most matching with the %s is %s" % (test_text_1[0], result_text))
def test_ssd(self):
ssd = hub.Module(name="ssd_mobilenet_v1_pascal")
- test_img_path = os.path.join(
- os.path.dirname(__file__), "resources", "test_img_cat.jpg")
+ test_img_path = os.path.join(os.path.dirname(__file__), "resources", "test_img_cat.jpg")
input_dict = {"image": [test_img_path]}
results = ssd.object_detection(data=input_dict)
for result in results:
--
GitLab