Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does python paint?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "how to paint in python". In the operation of actual cases, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Pip install python-opencv

However, it also has limitations, we can only use models trained by others for style transfer, if we want to customize the style, we must configure tools such as cudn and use the methods of projects such as deep-photo-styletransfer for training. In today's tutorial, we use the model trained by fast-neural-style to do a style transfer to the following picture.

1. Selection model

There are 9 model styles released by fast-neural-style. We will try them one by one. Some of them are as follows:

Candy

Mosaic

Starry_night

two。 Clone OpenCV source code

Code:

Note that the source code is based on Python2, so line 46 is missing parentheses, if you are Python3, please pay attention to the parentheses. This code can be used directly, parser defines five parameters,-input input to migrate the image width and height, median_filter is the median filter, the basic idea is to use the pixel neighborhood gray value of the median value to replace the pixel gray value, so the larger the theoretical value, the smoother the image, the better the details of the output results (uncertain). I personally tried the impact of median_filter on the image and found that the change was minimal, so it was fine with the default value.

3. Start the migration

Save the code in step 2 to a file named 1.py, and run the script with parameters in CMD/Terminal, where input is the source image path and model is the migrated style model file, such as running:

$python 1.py-input 1.jpg-model udnie.t7

Effect:

Migration effects of all 9 styles:

This is the end of the content of "how to draw python". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report