百度AI攻略:Paddlehub实现图像生成
2020-02-04 06:41
561 查看
PaddleHub可以便捷地获取PaddlePaddle生态下的预训练模型,完成模型的管理和一键预测。配合使用Fine-tune API,可以基于大规模预训练模型快速完成迁移学习,让预训练模型能更好地服务于用户特定场景的应用。
模型概述
CycleGAN是生成对抗网络(Generative Adversarial Networks )的一种,与传统的GAN只能单向生成图片不同,CycleGAN可以同时完成两个domain的图片进行相互转换。该PaddleHub Module使用Cityscapes数据集训练完成,支持图片从实景图转换为语义分割结果,也支持从语义分割结果转换为实景图。
代码及效果示例:
[code]import paddlehub as hub import matplotlib.pyplot as plt import matplotlib.image as mpimg cyclegan = hub.Module(name="cyclegan_cityscapes") test_img_path = "./body2.jpg" # 预测结果展示 img = mpimg.imread(test_img_path) plt.imshow(img) plt.axis('off') plt.show() # set input dict input_dict = {"image": [test_img_path]} # execute predict and print the result results = cyclegan.generate(data=input_dict) for result in results: print(result) test_img_path = "./cyclegan_output/body2.jpg" img = mpimg.imread(test_img_path) plt.imshow(img) plt.axis('off') plt.show()
[2020-01-06 08:47:55,320] [ INFO] - Installing cyclegan_cityscapes module 2020-01-06 08:47:55,320-INFO: Installing cyclegan_cityscapes module [2020-01-06 08:47:55,353] [ INFO] - Module cyclegan_cityscapes already installed in /home/aistudio/.paddlehub/modules/cyclegan_cityscapes 2020-01-06 08:47:55,353-INFO: Module cyclegan_cityscapes already installed in /home/aistudio/.paddlehub/modules/cyclegan_cityscapes
[2020-01-06 08:47:55,728] [ INFO] - 234 pretrained paramaters loaded by PaddleHub
2020-01-06 08:47:55,728-INFO: 234 pretrained paramaters loaded by PaddleHub
File ./body2.jpg is processed successfully and the result is saved to the cyclegan_output/body2.jpg
In[8]
[code]cyclegan = hub.Module(name="cyclegan_cityscapes") test_img_path = "./cbd1.jpg" # 预测结果展示 img = mpimg.imread(test_img_path) plt.imshow(img) plt.axis('off') plt.show() # set input dict input_dict = {"image": [test_img_path]} # execute predict and print the result results = cyclegan.generate(data=input_dict) for result in results: print(result) test_img_path = "./cyclegan_output/cbd1.jpg" img = mpimg.imread(test_img_path) plt.imshow(img) plt.axis('off') plt.show()
[2020-01-06 08:49:16,726] [ INFO] - Installing cyclegan_cityscapes module 2020-01-06 08:49:16,726-INFO: Installing cyclegan_cityscapes module [2020-01-06 08:49:16,746] [ INFO] - Module cyclegan_cityscapes already installed in /home/aistudio/.paddlehub/modules/cyclegan_cityscapes 2020-01-06 08:49:16,746-INFO: Module cyclegan_cityscapes already installed in /home/aistudio/.paddlehub/modules/cyclegan_cityscapes
[2020-01-06 08:49:17,164] [ INFO] - 234 pretrained paramaters loaded by PaddleHub
2020-01-06 08:49:17,164-INFO: 234 pretrained paramaters loaded by PaddleHub
File ./cbd1.jpg is processed successfully and the result is saved to the cyclegan_output/cbd1.jpg
- 点赞
- 收藏
- 分享
- 文章举报
相关文章推荐
- 百度AI攻略:Paddlehub实现图像分割
- 百度AI攻略:Paddlehub实现人体解析
- 百度AI攻略:Paddlehub实现目标检测
- 百度AI实现图像分类-python
- python实现连连看辅助--图像识别延伸(百度AI)
- OpenAI发布「块稀疏」GPU内核:实现文本情感分析与图像生成建模当前最优水平
- AI 端侧落地+图像语义分割,百度 AI 快车道揭秘工业质检不再靠“人眼”的秘诀
- 初探机器学习之使用百度AI服务实现图片识别与相似图片
- 对抗神经网络学习(四)——WGAN+爬虫生成皮卡丘图像(tensorflow实现)
- SNAP的另类实现,采用js生成IFRAME内嵌框架的形式实现链接的网页'图像预览'
- Opencv3 Sift和Surf特征实现图像无缝拼接生成全景图像
- 百度AI步入3.0时代:无人车实现量产
- 用百度AI的OCR文字识别结合JAVA实现了图片的文字识别功能
- Opencv Sift和Surf特征实现图像无缝拼接生成全景图像
- 百度AI实现图片转文字-python
- ASP.NET程序中实现校验码图像生成
- C#图像处理类(使用此类可实现生成锐化效果、黑白效果和灰度效果)
- 【基于百度AI的人脸识别Python实现】
- 百度AI-文字识别(身份证识别)的实现,大部分识别都通用适合所有人找灵感
- PHP实现图像上传并生成缩略图