In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article shows you how to achieve automatic matting Mini Program based on Python, the content is concise and easy to understand, absolutely can make your eyes bright, through the detailed introduction of this article hope you can get something.
What Python is mainly used to do? Python is mainly used in: 1, Web development; 2, data science research; 3, web crawler; 4, embedded application development; 5, game development; 6, desktop application development.
Text
PS short story
A man who just finished lunch and is wasting his life by browsing the web. The programmer is alive and well.
Piles of boring gossip page content slowly blurred my eyes, a yawn burst into tears, and then I saw a picture:
Who is it?! Who put out the picture of my girlfriend? Awsl! It's so beautiful.
Wait, why is that background so blurry?! The programmer brother said-- I just want the goddess and nothing else!
Finally, after three days and three nights of tea and dinner, the programmer succeeded in achieving this effect.
One click to download, one button to shake the picture:
1. Preparation 1.1 first of all
To introduce a free matting website: foreign version of matting artifact website, this matting website is called remove
1.2 introduction to the website
Automatically recognize people and background, goods and background, and the accuracy of recognition is very high, claimed to be 100% automatic, 5 seconds deduction.
You have to scratch a picture for at least 1 minute. It only takes 5 seconds ~ when it is opened, it looks like this:
It introduces a tool based on Python, Ruby and deep learning to remove background color. It supports calling its API interface with Python to achieve the effect of removing background and leaving foreground body.
Sign up for an account
To get API, you must first have an account. The application for the account is very simple, and the mailbox is fine.
If you use API, you can only process 50 pictures a day. If you use it directly on the website, it is unlimited and free!
Steps to get: log in, first click 'Tools & API', second click' API Docs':
Step 3 Click 'Get API Key':'
Step 4: click 'Show',' and you will have your own API!
two。 Official matting 2.1 environment installation
This article is based on the interface of Tkinter Mini Program! Module installation: removebg, Pillow.
Pip install-I https://pypi.douban.com/simple/ + module name 2.2 material (optional)
2.3 main program code def openfile (): # here change API key to get key rmbg = RemoveBg ('API key',' error.log') filename = filedialog.askopenfilename () rmbg.remove_background_from_img_file (filename) imagepath = filename+'_no_bg.png' img = Image.open (imagepath) img.show () showinfo ('complete generation', f' image processing is complete The path is: {imagepath}') # print (filename) root=Tk () root.title ("matted Mini Program") # window size root.geometry ("500x500") btn = Button (root, text=' Open Picture', command=openfile,width=15,height=2) # binding method 1: commandbtn.place (padx=5, pady=50) lbl=Label (root) Text='---- Gu Muzi acridine matting technology which is better -') lbl.pack () root.mainloop () 3. Effect figure 3.1 interface display
3.2 Picture display
Perfect matting effect! Ha ~
The above content is based on Python how to achieve automatic matting Mini Program, have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
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.