PaddleHub can easily access the pre-training model under PaddlePaddle ecological, complete management model and a key prediction. Used in conjunction with Fine-tune API, applications can pre-training model based on large-scale migration to learn quickly, so that the pre-training model to better serve the users of a particular scene.
Model Overview
CycleGAN is a generation against the network (Generative Adversarial Networks) with the traditional way of GAN can only generate a different picture, while two domain CycleGAN can complete the picture conversion. PaddleHub Module using the training data set Cityscapes completed, image conversion from real to support semantic FIG segmentation results, also supports conversion from real semantic segmentation result of FIG.
Code and Effect Example:
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"
# Predictions show
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]
cyclegan = hub.Module(name="cyclegan_cityscapes")
test_img_path = "./cbd1.jpg"
# Predictions show
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