使用pytorch将一个图像的样式传输到另一个图像
styletransfer的Python项目详细描述
样式转换
一个python库,使用pytorch将一个图片的样式传输到另一个图片。
安装
您可以使用以下命令从pypi安装styletransfer:
pip install styletransfer
这个包需要python 3.x
基本用法
开始的最简单方法是拍摄一张用于样式转换的在线图像,然后使用默认参数运行:
fromstyletransferimportStyleTransferstyleTransfer=StyleTransfer()#Set the content image from URLstyleTransfer.setContentFromUrl('https://upload.wikimedia.org/wikipedia/commons/thumb/4/4f/Felis_silvestris_catus_lying_on_rice_straw.jpg/640px-Felis_silvestris_catus_lying_on_rice_straw.jpg')#Set the style image from URLstyleTransfer.setStyleFromUrl('https://upload.wikimedia.org/wikipedia/commons/thumb/a/a5/Tsunami_by_hokusai_19th_century.jpg/640px-Tsunami_by_hokusai_19th_century.jpg')#Use default settings and train the model#If you do not have a GPU that can take 30-60 minutesstyleTransfer.apply()#Write the result image to a filestyleTransfer.writeFinalImage('stylized_image.jpg')
高级用法
tbd:遵循
的详细说明