classifier = hub.Module(name="resnet50_vd_dishes") result = classifier.classification(images=[cv2.imread('imgs/test1.jpg')])
print('result:{}'.format(result))
[2022-06-28 17:21:55,454] [ WARNING] - The _initialize method in HubModule will soon be deprecated, you can use the __init__() to handle the initialization of the object
[2022-06-28 15:01:17,573] [ WARNING] - The _initialize method in HubModule will soon be deprecated, you can use the __init__() to handle the initialization of the object
[2022-06-28 18:06:45,298] [ WARNING] - The _initialize method in HubModule will soon be deprecated, you can use the __init__() to handle the initialization of the object
上面使用deeplabv3p识别实现了人像分割,除此之外,图像分割还包含如 图12 所示算法:
图12:图像分割算法
注:如果想了解更多图像分割模型细节,请参考图像分割开发套件PaddleSeg
3.4 OCR
OCR(Optical Character Recognition,光学字符识别)是计算机视觉重要方向之一。传统定义的OCR一般面向扫描文档类对象,即文档场景文字识别(Document Analysis & Recognition,DAR),现在我们常说的OCR一般指场景文字识别(Scene Text Recognition,STR),主要面向自然场景。OCR技术有着丰富的应用场景,如卡证票据信息抽取录入审核、工厂自动化、政府工作医院等文档电子化、在线教育等。
[2022-06-28 17:25:56,761] [ WARNING] - The _initialize method in HubModule will soon be deprecated, you can use the __init__() to handle the initialization of the object [2022-06-28 17:25:57,665] [ WARNING] - The _initialize method in HubModule will soon be deprecated, you can use the __init__() to handle the initialization of the object
videotag = hub.Module(name="videotag_tsn_lstm") result = videotag.classify(paths=["imgs/dance.mp4"]) print(result)
[2022-06-28 15:49:27,292] [ WARNING] - The _initialize method in HubModule will soon be deprecated, you can use the __init__() to handle the initialization of the object
GAN的全称是Generative Adversarial Networks,即生成对抗网络,由Ian J. Goodfellow等人提出。一般一个GAN网络包括了一个生成器(Generator)和一个判别器(Discriminator),生成器用于生成越来越接近实际标签的数据,判别器用来区分生成器的生成结果和实际标签。生成模型和判别模型构成了一个动态的“博弈过程”,最终的平衡点即纳什均衡点,即生成模型所生成数据(G(z))无限接近真实数据(x)。GAN模型应用也非常广泛,可应用于图像生成、风格迁移、超分辨率、影像上色、人脸属性编辑、人脸融合、动作迁移等。
图19:图像生成示意图
In [21]
import cv2 import paddlehub as hub
model = hub.Module(name='UGATIT_100w') # 结果保存在'output/'目录,可以观察可视化结果 result = model.style_transfer(images=[cv2.imread('imgs/test6.jpg')], visualization=True)
[2022-06-28 17:08:24,765] [ WARNING] - The _initialize method in HubModule will soon be deprecated, you can use the __init__() to handle the initialization of the object