PaddlePaddle / PaddleHub

Awesome pre-trained models toolkit based on PaddlePaddle. (400+ models including Image, Text, Audio, Video and Cross-Modal with Easy Inference & Serving)【安全加固,暂停交互,请耐心等待】
https://www.paddlepaddle.org.cn/hub
Apache License 2.0
12.72k stars 2.08k forks source link

stylepro_artistic API内存不足 #503

Open 60999 opened 4 years ago

60999 commented 4 years ago

欢迎您反馈PaddleHub使用问题,非常感谢您对PaddleHub的贡献! 在留下您的问题时,辛苦您同步提供如下信息:

aistudio平台GPU环境

stylepro_artistic 使用GPU出错,在转换多张照片之后.

代码: `def stylepro_artistic(fore_image_path,paddlehub_out_path):

1.指定待预测图片路径,遍历循环抠图 保存到 paddlehub_out_path

g = os.walk(fore_image_path)
for path,dir_list,file_list in g: 
    file_list = natsorted(file_list)
    for file_name in file_list:
        #取出一个前景文件
        front_pic = os.path.join(path, file_name)
        # print (front_pic)
        # 2.加载预训练模型
        module = paddlehub.Module(name="stylepro_artistic")
        input_dict = {"content": front_pic,"styles":["/home/aistudio/work/Picasso_pic.jpg"]}
        #print (input_dict)
        #GPU开启下面一行,如果用下面一行,必须安装paddlepaddle-gpu
        results = module.style_transfer(paths=[input_dict],use_gpu = True,visualization=True,output_dir=paddlehub_out_path)
        #以下还可以优化吗
        #for result in results: 
        #print(result)

stylepro_artistic(front_path,HUMANSEG_SPACE) ` TIM截图20200405232521

nepeplwu commented 4 years ago

请问下你所用GPU的显存是多大?是否有其他进程也占用了显存?

60999 commented 4 years ago

aistudio平台 16/32 G

nepeplwu commented 4 years ago

@60999 是否可以提供下aistudio的链接?我们fork复现看。此外,下面的代码建议放在for循环外,没有必要每次都加载一次module

module = paddlehub.Module(name="stylepro_artistic")
60999 commented 4 years ago

怀疑就是多次载入模型导致的。调用其他模型时候也遇到过这种情况,在升级其他模型的更新版本后没出现过问题,stylepro_artistic 模型后来没有再测试过。 建议其他模型都载入几百次测试下,没准其他模型也有这种问题。

InternetMaster1 commented 4 years ago

@nepeplwu

This can be used on Android?

Steffy-zxf commented 4 years ago

@InternetMaster1 As for mobile-end usage, please refer to PaddleLite: https://github.com/PaddlePaddle/Paddle-Lite

InternetMaster1 commented 4 years ago

@Steffy-zxf @nepeplwu

  1. Any guide on how to convert "stylepro_artistic" to Android using PaddleLite. I don't see any demo present like other projects such as segmentation, etc have. https://github.com/PaddlePaddle/Paddle-Lite-Demo/tree/master/PaddleLite-android-demo

  2. What is the model size and the processing time for style transfer? If you check Tensorflow document, they have mentioned the model file size and time taken. https://blog.tensorflow.org/2020/04/optimizing-style-transfer-to-run-on-mobile-with-tflite.html image

What are the similar size and latency values for Paddle StyleTransfer module?

  1. What are the difference in the below two? https://github.com/PaddlePaddle/hapi/tree/b337063c7ecf44c60944801dbd32453f1481d987/examples/style-transfer https://github.com/PaddlePaddle/PaddleHub/tree/dbca09ae78b5387ebe3b49f37ce88de45d41d26a/hub_module/modules/image/style_transfer/stylepro_artistic
InternetMaster1 commented 4 years ago

@Steffy-zxf @nepeplwu

Is it possible to run "stylepro_artistic" on our own server, or on the mobile phone as offline code?

On PaddleHub, I only see the API.

We wish to provide stylepro_artistic for offline purpose on mobile phone similar to other libraries like PaddleSeg. Is this possible?