In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to use Python code batch matting", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "how to use Python code batch matting" bar!
1. Prepare for
In order to achieve this experiment, Python is essential. If you have not installed Python, you can follow the official Wechat account at the end of the article to download the installation guide.
Then, we need to install baidu's paddlepaddle, and the official website has detailed instructions:
Https://www.paddlepaddle.org.cn/install/quick
Choose these options according to your own situation, the last version of CUDA, because this experiment does not need training data, and does not need too much calculation, so you can directly choose the CPU version. After the selection, the installation instructions will appear below. I have to say that what Paddlepaddle has done in these aspects is relatively intimate (whisper bb: just the name is not good).
Note that if the program name in your Python3 environment variable is Python, remember to change the statement to Python xxx and install it as follows:
Python-m pip install paddlepaddle-I https://mirror.baidu.com/pypi/simple
You also need to install paddlehub:
Pip install-I https://mirror.baidu.com/pypi/simple paddlehub
two。 Write code
The whole step is divided into three steps:
Loading model
Specify the picture directory to be matted
Matting
Import os import sys import paddlehub as hub # 1. Load the model humanseg = hub.Module (name= "deeplabv3p_xception65_humanseg") # 2. Specify the directory path ='. / source/' files = [] dirs = os.listdir (path) for diretion in dirs: files.append (path + diretion) # 3. Matting results = humanseg.segmentation (data= {"image": files}) for result in results: print (result ['origin']) print (result [' processed'])
No more, no more than 20 lines of code. After matting, a folder called humanseg_output is created under the local folder. What is stored here are the pictures that have been successfully matted.
3. Result analysis
I have to admit, Google's algorithm is always good. As long as the background is better, the details are on a par with the manual details, or even better than manual means.
However, when the background is comparable to the color of the person, there will be some problems, such as the following result:
The uncle behind has been completely ignored (asking for the shadow area of his heart). Nevertheless, this model is one of the strongest matting models I have ever seen.
Thank you for your reading, the above is "how to use Python code batch matting" content, after the study of this article, I believe you on how to use Python code batch matting this problem has a deeper understanding, the specific use of the situation also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.