Trending February 2024 # Pyechart Data Visualization Library For Enhanced Visuals # Suggested March 2024 # Top 9 Popular

You are reading the article Pyechart Data Visualization Library For Enhanced Visuals updated in February 2024 on the website We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested March 2024 Pyechart Data Visualization Library For Enhanced Visuals

This article was published as a part of the Data Science Blogathon


If you want to make charts like the above one so let’s get to know about the amazing Pyecharts library. Generally, the bar chart which we use of matplotlib library is static and there are very few parameters to tweak to make it more appealing to the audience but if I say with less line of code we can create eye-pleasing charts. Yes!!!!!! so let’s see how it is done.

The Pyecharts library uses Echarts to generate charts. Pyecharts library provides the interface between Python and Echarts. The Pyecharts work usually like we use visualization library in Python or R in our Jupyter Notebook. Pyecharts have flexible configuration options, so you can easily match the desired chart you want to make. Detailed documentation and samples to help developers get started the faster project

This Pyecharts library supports the chained calls and we can easily integrate them into Flask, Django Web framework, and other mainstream. Let’s look at some examples, and many more can be found at Pyecharts Gallery!


Installing the Pyechart library, with the pip command

pip install pyecharts==1.7.1

Importing Library

from pyecharts import options as opts from pyecharts.charts import Liquid from pyecharts.globals import SymbolType from pyecharts.charts import Bar, Line Parameters for the chart

How to create a pyechart chart? Let’s see the parameters to make an interactive chart.

For showing data on the x-axis: add_xaxis()

For showing data on the y-axis: add_yaxis()

set_global_ops gives a lot of room where we can have the title and subtitle to the chart.

render() create a file named chúng tôi in the root directory defaultly, which supports path parameter and set the location the file save in, for instance, render(r”e:my_first_chart.html”), open file with your browser.

init_opts helps to set the various theme palate.

Benefits of PyeChart

The pyechart data is a dynamic chart and whenever the mouse is hovering on the chart, the number shows up with the transparent background. The charts are very eye-catching. Less code is needed to make pleasant charts.

The library does provide 3D visuals which are great

Support for javascript and python.

Creative theme palate

Color palate example. Let’s first see the dark mode palate for the bar chart.

from pyecharts.charts import Bar bar = ( Bar(init_opts=opts.InitOpts(theme=ThemeType.DARK)) .add_xaxis(['JAN','FEB','MAR','APR']) .add_yaxis('Temperature Max', [-7,-6,10,15]) .set_global_opts(title_opts=opts.TitleOpts(title="Temperrature throught out the year", subtitle="2024")) ) bar.render_notebook()

We saw the common dark mode theme let’s check some other interesting themes also. Well, I do prefer this purple palate! I have never seen such a good purple check box palate theme for the chart.

from pyecharts.charts import Bar from pyecharts import options as opts from pyecharts.globals import ThemeType bar = ( Bar(init_opts=opts.InitOpts(theme=ThemeType.PURPLE_PASSION)) .add_xaxis(['JAN','FEB','MAR','APR']) .add_yaxis('Temperature Max', [7,6,15,10]) .set_global_opts(title_opts=opts.TitleOpts(title="Temperature of India", subtitle="2024 Year")) ) bar.render_notebook()

There are some other palates to try them out I am listing them WHITE, LIGHT, DARK, CHALK, ESSOS, INFOGRAPHIC, MACARONS, ROMA, ROMANTIC, SHINE, VINTAGE, WALDEN

Bar chart

Let’s try out the pyechart library by starting with the bar chart. Here, I have taken demo data of the Temperature of India for 4 months Jan, Feb, Mar, Apr.

from pyecharts.charts import Bar

bar = (



.add_yaxis(‘Temperature Max’, [-7,-6,10,15])

.set_global_opts(title_opts=opts.TitleOpts(title=”Temperature of India”,

subtitle=”2024 Year”))



This bar chart shows the one parameter Temp Max but if you want another parameter too like temp min then it is simple just add another y-axis. Let’s see how it is done.

bar = (



.add_yaxis(‘Temperature Max’, [-7,-6,10,15])

.add_yaxis(‘Temperature Min’, [-1,0,5,12])

.set_global_opts(title_opts=opts.TitleOpts(title=”Temperature of India”,

subtitle=”2024 Year”))



We saw how to make a simple bar chart let’s add some specific details so when our audience sees the charts they don’t fail to miss out on the details.

from pyecharts.charts import Bar bar = ( Bar(init_opts=opts.InitOpts()) .add_xaxis(['JAN','FEB','MAR','APR']) .add_yaxis('Temperature Max', [-7,-6,10,15]) .add_yaxis('Temperature Min', [-1,0,5,12]) .set_series_opts( label_opts=opts.LabelOpts(is_show=False), markpoint_opts=opts.MarkPointOpts( data=[opts.MarkPointItem(type_="max", name="Highest Temp"), opts.MarkPointItem(type_="min", name="Lowest Temp")] ), ) ) bar.render_notebook()

If we want to download the charts we just need to add ToolboxOpts to the chart and it will show a download option on the chart.



.add_yaxis(‘Temperature Max’, [7,6,15,10])

.set_global_opts(title_opts=opts.TitleOpts(title=”Temperature of India”,

subtitle=”2024 Year”),




Want to see a unique way to represent the value in percentage pyecharts data that have liquid charts. In liquid charts, we need to give the value which we want to see on the chart in decimal format. This chart is a unique chart that will not only show the value but also the background has water which is running all the time. I haven’t seen this type of chart till now.

To make this type of chart just run the below line of code

c = ( Liquid() .add("Completion", [0.67]) .set_global_opts(title_opts=opts.TitleOpts(pos_left="center")) ) c.render_notebook()

We can modify the chart by color and outline parameter. like if we want to choose any other color than the default blue. We just need to give a color name in the color parameter and for the outline, if we want to hide it then just need to make is_outline_show=False

c = (


.add(‘Completion’, [0.6], is_outline_show=False)

.set_global_opts(title_opts=opts.TitleOpts(title=’% of sales target achieved’,




For changing the color of the circle just give a color name to the color parameter.

c = (


.add(‘Completion’, [0.6], is_outline_show=False,color=[‘#7733FF’])

.set_global_opts(title_opts=opts.TitleOpts(title=’% of sales target achieved’,




Scatter Chart

The scatter chart which we are going to see is not a normal bubble chart the scatter chart will have a ripple effect. The scatter chart with ripple effects of each dot and also have a slide bar from where we can slide to filter the data. Isn’t that amazing?

from pyecharts.charts import EffectScatter

from pyecharts.globals import SymbolType

from pyecharts import options as opts

v1 = [24,50,105,205,389,673,1073,1578]

x = [“2013″,”2014″,”2024″,”2024″,”2024″,”2024″,”2024″,”2024”]

c = (



.add_yaxis(“Temp”, v1,is_selected = True,symbol_size = 20,


.set_global_opts(title_opts=opts.TitleOpts(title=”Temperature of India”,

subtitle=”2013-2024 Year”))



We saw how to make a scatter plot with a ripple effect let’s add two y-axes and compare the data.

v1 = [24,50,105,205,389,673,1073,1578]

v2 = [3,5,8,12,16,23,40,56,72]

x = [“2013″,”2014″,”2024″,”2024″,”2024″,”2024″,”2024″,”2024”]

c = (



.add_yaxis(“Temp1”, v1, is_selected = True,symbol_size = 20,


.add_yaxis(“Temp2”, v2, is_selected = True,symbol_size = 20,


.set_global_opts(title_opts=opts.TitleOpts(title=”Temperature of India”,

subtitle=”2013-2024 Year”))



We saw how to have 2 data points for comparison let’s see how we can have a sidebar that will tell us where the data point lies compared to others.

c = ( EffectScatter(opts.InitOpts(width='900px', height='500px')) .add_xaxis(x) .add_yaxis("Temp1", v1,is_selected = True,symbol_size = 20, symbol=SymbolType.DIAMOND) .add_yaxis("Temp2", v2,is_selected = True,symbol_size = 20) .set_global_opts(title_opts=opts.TitleOpts(title="Temperature of India", subtitle="2013-2024 Year"), visualmap_opts=opts.VisualMapOpts(pos_left="right", type_="color", max_=2000, min_=0, pos_bottom=50) ) ) c.render_notebook() End Note

Here we saw what is Pyechart Data and what are the benefits of pyecharts. As there are dynamic which helps the audience to engage with them with additional functionality that it is in scatter chart we have a ripple effect.

Author’s Contact

You can contact me through the below-mentioned social media platforms.

The media shown in this article is not owned by Analytics Vidhya and are used at the Author’s discretion. 


You're reading Pyechart Data Visualization Library For Enhanced Visuals

Best Free Antivirus For Windows 11 For Enhanced Security

Want to have a secure browsing experience and keep your data safe? Use the best free antivirus for Windows 11.

Being the most popular operating system in the world, Windows has always been the target of viruses, spyware, malware, and other cybersecurity threats.

If you’re a Windows 11 user, you use a highly secure OS. But there is always a chance that your files will get corrupted or inaccessible due to a virus attack.

So, you must use antivirus applications on your Windows 11 PC to protect it against any external threats.

Listed below are the best free antivirus for Windows 11. Read on to learn the top features of these free antivirus solutions.

Best Free Antivirus for Windows 11

1. Windows Security

Windows Security is an all-in-one security service from Microsoft. It comes built-in with your Windows 11 PC, and Microsoft Defender is one of its components.

It offers comprehensive protection against viruses, malware, spyware, adware, and many more.

This application provides virus and threat protection, firewall and network protection, account protection, device security, and app and browser control.

You can visit the virus and threat protection section and navigate to the Scan options to choose from Quick scan, Full scan, Custom scan, and Microsoft Defender offline scan.

You also get the option to allow detected threats and check the protection history. Managing settings for ransomware, virus, and threat protection is possible here.

Microsoft Security also lets you choose who can access your network. You can enable or disable Windows Defender firewalls for private, domain, and public networks by visiting the firewall and network protection section.

You can also choose if an app can communicate through the public or private network firewall. This program also lets you have control over your apps and browser.

By utilizing the reputation-based protection feature, you can find out about potentially unwanted apps, websites, and files.

Isolated browsing, exploit protection, core isolation, and security process are other highlighted features of Windows Security.

2. Bitdefender Antivirus

Bitdefender Antivirus is one of the best free antiviruses for Windows 11 that safeguards you against all the latest online threats and keeps your PC clean and virus-free.

This software stops the constantly-evolving threats that run in your system background. This application is lightweight. Hence, it consumes fewer system resources.

Unlike many free Windows 11 antivirus applications, it offers live customer support to resolve your security threat-related issues.

Besides the regular antivirus and malware, Bitdefender Antivirus protects you against ransomware, cryptocurrency, zero-day exploits, spearphishing, trojans, and rootkits.

It keeps you informed of the threats through gentle reminders without annoying you. Moreover, the program doesn’t interfere with other apps on your PC.

It even upgrades automatically to protect you against the latest threats and viruses.

3. Avast Antivirus

As a Windows 11 user, you can join hundreds of millions of people who use Avast Antivirus for world-class protection against viruses and malware.

You can also use it to improve your privacy and secure your Wi-Fi network. The software is easy to install, and you can use it effortlessly right from the start.

It boasts the largest threat-detection network in the industry. Also, features like home network security and machine learning (ML) based virus protection ensure optimum speed for your PC.

Avast free antivirus offers multiple layers of antivirus security — Smart Scan, CyberCapture, Behavior Shield, File Shield, Rescue Disk, and Quarantine.

Additional features of this free antivirus software include safe browsing and emailing ransomware protection and data leak alerts.

4. AVG

AVG is a powerful free antivirus for Windows 11 that protects your computer while ensuring the safety of your online life as well.

Using its six robust protection layers, it saves your computer from viruses, malware, and spyware.

The antivirus also comes with an email shield that automatically blocks phishing links and harmful attachments that might contain viruses.

It has access to the largest virus database in the world and gets updated in real-time. Hence, it can also provide you with zero-day protection.

While browsing, AVG stops you from landing on web pages that contain malware and scams.

You can also use its firewall feature to protect your home network from threats.

What’s more, if anyone hacks your email password, it’ll notify you instantly.

Its improvised anti-ransomware technology offers extra protection to your most important files. Also, the webcam protection feature prevents unauthorized access to your webcam.

5. Avira Free Antivirus for Windows

Avira is one of the best free antivirus solutions for Windows 11 users. It also helps you block spyware, adware, and ransomware to ensure maximum protection.

This program is lightweight, so it doesn’t affect your PC performance or speed. Moreover, you get real-time updates and protections.

The antivirus scanner of Avira detects and blocks viruses, malware, ransomware, trojans, and others. Its automated system continuously learns about new and evolving threats to protect you.

The software can also detect unnecessary programs hiding inside a legitimate application. You can also trust it for safe browsing as it blocks harmful websites before the page loading is complete.

6. Immunet Antivirus

If you want basic antivirus protection for your Windows 11 computer, use Immunet Antivirus. For additional security, you can use it with any other paid or free antivirus software.

The application provides fast and real-time online protection against viruses, worms, keyloggers, bots, trojans, and spyware.

The antivirus software offers Quick Scan, On-Access Scan, and On-Demand Scan for your network security. It provides features like history and reports logging that help you with documentation.

Managing your files is also easy with this tool. You can scan individual and compressed files, exclude files from scanning, and put infected files into quarantine.

7. Malwarebytes

Malwarebytes is another free antivirus for Windows 11 that protects you against viruses.

Win 11 users can easily download the free version of this software and scan their computers for malware.

Once the viruses have been detected, the tool can remove them and bring your computer back to a clean state.

You can go through it and select the items you want to remove from your Windows 11 computer. It also shows you a summary report of the threat scan.

8. ZoneAlarm

Are you looking for a free antivirus with a robust firewall? In that case, ZoneAlarm should be your go-to option.

This fast and reliable software can seamlessly detect viruses, worms, spyware, trojans, bots, and other security threats and remove them successfully.

If you have this application installed on your Windows 11 PC, you don’t have to worry about hackers while browsing online.

Its firewall protects your data by making your computer invisible to hackers. The tool only takes seconds to disable malicious programs.

ZoneAlarm can detect when your Wi-Fi networks are in use and apply firewall protection for maximum security.

9. Panda Free Antivirus

If you’re willing to find the best free antivirus for Windows 11 for personal usage, Panda is an ideal option.

Whether browsing online for fun or using the internet for office or school work, this antivirus tool can offer you real-time protection.

Moreover, it has the maximum virus detection rate without having much impact on your Windows 11 device.

The software gets updated in real-time to protect you against zero-day vulnerabilities, so you don’t have to update the tool manually.

While it provides real-time protection against viruses, you can even schedule a scan at regular intervals or scan it any time you want.

Panda also scans your USB devices as you insert and stops them from automatic malware execution.

10. TotalAV

TotalAV isn’t just the best free antivirus for Windows 11; it’s a security suite that safeguards your digital life and activities.

Whether you’re running Windows 11 on a desktop, laptop, or tablet, TotalAV will function with equal efficiency.

You can install it quickly without any interruptions. This antivirus software doesn’t hamper your PC performance while gaming and video editing.


Antivirus application has become an essential component for Windows 11 PC security. These programs protect your files and computer from all kinds of security threats, including viruses and malware.

If you don’t want to use any paid antivirus, free antivirus for Windows 11 is available in the market.

You can choose any tool from our list of the best free antivirus for Windows 11. Since all antivirus applications are free, you can try many of these to select the right one.

Creating Linear Model, It’s Equation And Visualization For Analysis

This article was published as a part of the Data Science Blogathon.


Linear Regression:

Fig. 1.0: The Basic Linear Regression model Visualization

The Linear model (Linear Regression) was probably the first model you learned and created, using the model to predict the Target’s continuous values. You sure must have been happy that you’ve completed a model. You were probably also taught the theories behind its functionality– The Empirical Risks Minimization, The Mean Squared Loss, The Gradient descent, The Learning Rate among others.

Well, this is great and all of a sudden I was called to explain a model I created to the manager, all those terms were like jargons to him, and when he asked for the model visualization (as in fig 1.0) that is the model fit hyperplane(the red line) and the data points(the blue dots). I froze to my toes not knowing how to create that in python code.

Well, That’s what the first part of this article is about Creating the Basic Linear Model Visualization in your Jupyter notebook in Python.

Let’s begin using this random data:

X y

1 2

2 3

3 11

4 13

5 28

6 32

7 50

8 59

9 85

Method 1: Manual Formulation Importing our library and creating the Dataframe:

now at this stage, there are two ways to perform this visualization:

1.) Using  Mathematical knowledge

2.) Using the Linear_regression Attribute for scikit learns Linear_model.

Let’s get started with the Math😥😥.

just follow through it’s not that difficult, First we define the equation for a linear relationship between y(dependent variables/target) and X(independent variable/features) as :

         y = mX + c

where y = Target

            X = features

           a = slope

           b = y-intercept constant

To create the model’s equation we have to get the value of m and c , we can get this from the Y and X with the equations below:

The slope, a is interpreted as the product between the summation of the difference between each individual x value and its mean and the summation of the difference between each individual y point and its mean then divided by the summation of the square of each individual x and its mean.

The intercept is simply the mean of y  minus the product of the slope and mean of x

That is a lot to take in. probably read it over and over  till you get it, try reading with the picture

👆👆 that was the only challenge; if you’ve understood it congratulations let’s move on.

Now writing this in python code is ‘eazy-pizzy’  using the numpy library, check it out👇👇.

To blow your mind now, did you know that this is the model’s equation. and we just created a model without using scikit learn. we will confirm it now using the second method which is the scikit learn Linear Regression package

Method 2: Using scikit-learn’s Linear regression

 We’ll be importing Linear regression from scikit learn, fit the data on the model then confirming the slope and the intercept. The steps are in the image below.

so you can see that there is almost no difference, now let us visualize this as in fig 1.


The red line is our line of best fit that will be used for the prediction and the blue point are our initial data. With this, I had something to report back to the manager. I particularly did this for each feature with the target to add more insight.

Now we have achieved our goal of creating a model and showing its plotted graph

This technique may be time-consuming when it comes to data with larger sizes and should only be used when visualizing your line of best fit with a particular feature for analysis purposes. It is not really necessary during modeling unless requested, Errors and calculation may suck up your time and computation resources especially if you’re working with 3D and higher data. But the insight gotten is worth it.

I hope you enjoyed the article if yes that great, you can also tell me how to improve in any way. I still have a lot to share especially on regressions(Linear, Logistics, and Polynomial ).

Thank You for reading through.


4 Things Your Facebook Ad Visuals Must Have

The ultimate goal of any Facebook ad is to catch someone’s eye with the right combination of stunning visuals and compelling copy.

You want the ad to stand out against the background noise of news, politics and status updates.

And there is a lot of noise right now.

The ad copy could be great but the visual has to be even better.

Because that’s what will be seen first.

Now that almost every news site, company page or blogger uses compelling visuals, standing out has become more difficult.

But I have come up with a few tried and tested tips to help you create a winning Facebook Ad visual.

How to use Facebook Instant Experiences (Canvas Ads)

Learn the ins and outs of Facebook Instant Experiences with this Quick Win. From set-up to optimization, this guide will help get you up and running with Facebook Experiences in no time at all.

Access the How to use Facebook Instant Experiences (Canvas Ads) quick win

1. Include a product image

If you are using a Facebook Ad to show off your product you should probably include a shot of your product. Right? In most other marketing channels that would be a no-brainer. But when it comes to Facebook Ad visuals some people may have missed the memo.

Because some people think that they can use a stock image or a few lines of text to create a winning Facebook Ad visual. Wrong. For example, recently I have seen some brands either us a somewhat related stock image:

Or just the slightly better vague stock image with some random text overlaid. But in this case the internet’s favorite pet can not make up for a bad Facebook Ad visual:

Actually, they are both virtual products, which is why I picked them. In this day and age, many marketers are trying to sell products that you can not hold in your hands or see. I do not see that changing anytime soon, in fact, it will probably get worse. That makes it hard to include a product in your Facebook Ad visual when you technically do not have the traditional definition of a product. It is difficult for sure, but not impossible. Just take a look at the simple but effective way 99Designs showed off their logo design service.

Or you could be like Hubspot in the example below and include a screenshot of the product. This approach can be extremely useful for products that have a very beautiful or easy to understand interface as well.

Finally here is an example from one of my campaigns for an Ebook about creating social media images.

2. Use legible text and fonts

It is common knowledge that Facebook Ads visuals can only include text that takes up to 20% of the image. And that definitely causes some headaches for even the most seasoned social media marketer. Because it is hard to not only grab someone’s attention but also inform about your product them in few words.

That is why some marketers decide just to shrink the size of the text to fit more in. And if you are paying attention to the title of this section that makes it barely legible. Like this example that shrunk the most important part of their text, the savings, for some reason:

As you can see the font is very light, the text small and the background color too light, which when all are combined makes it even harder to read. Something like this is not going to stop someone from scrolling right over it in their Facebook feed.

Here is another example of using the wrong text in your Facebook Ad visual but in this case, it is all about using the wrong font colour:

In this case, the font blends into the background image pretty easily and does nothing to grab the reader’s attention. In contrast, the text on this Facebook Ad from Clearbit jumps off the page and is easy to read:

They used a dark background, a bold font and an acceptable text size, which makes this a great visual. I will show off why dark backgrounds are so important in the next section too.

To make it very easy to read they not only use large and in your face text, they also use two different font weights. This makes it even easier to read, and we have seen this work very well in our Facebook Ad visuals.

I would also recommend using a white font, it sticks out on about any dark background.

Like on this visual that comes from one of our past campaigns and performed very well.

As you can see it uses white font, two font weights and very large text to make it incredibly legible. And people are able to quickly read this and react while scrolling through their feed. Unlike some of the bad examples, we saw above. Unlike some of the bad examples, we saw above.

3. Dark and bold backgrounds are your friend

As you are probably well aware of by now, the background colour of the Facebook feed is white. Which helps it look clean and beautiful on almost any screen. That does not mean that your Facebook Ad visuals use a white or light colour scheme to fit in. Because that is exactly what will happen, your ad visuals will just blend into the background.

People will scroll over them without even noticing your product and you will have wasted a nice chunk of money. And as many props that I have given Hubspot in this article, sometimes they just have a bad Facebook Ad visual:

This is something that does not grab my attention at all and blends into not only the background of Facebook but the text of the ad.

Honestly, you are not sure where the ad text ends and the visual begins if you take a quick look. So I would recommend taking their hiccup and using it for your gain by never using a white background in a Facebook Ad visual. The same can be said about this ad from Blocks about using white backgrounds:

It may look incredibly clean and futuristic while you are designing it but a white background will rarely ever work on Facebook. Instead, I recommend very dark or bold backgrounds for your Facebook Ad visuals. Anker, the portable battery company, did just that in their ad below and it looks fantastic:

Plus the white text really pops off the screen and blends into the clean aesthetic that you see on your Facebook feed. Additionally, it does not have to be a static dark background, you can also use an image with darker tones for your Facebook Ad visual. Like the team at Blenders Eyewear did below:

And if you can not avoid using a white or lighter background, just throw a dark colored gradient over the image. It is one of the oldest tricks in the Facebook Ad or really any social network game and the team at Hoth used it perfectly.

4. Do not forget icons and graphics

Using icons to add something extra is one of my favorite design tricks I use while creating infographics, and they translate to Facebook Ads as well. They can be used to catch the eye of your reader and direct them to a part of your ad, like a call to action. Or icons can become the focal point of your Facebook Ad visual in which the text latches onto. And they even can be used to add a bit of context to the ad without using any extra text.

It really is up to you, and since there is not really a wrong way to use icons I will jump to the good examples! In this first Facebook Ad from Southwest airlines, they masterfully use a simple icon to draw your eye to the low price of the flight:

Using icons in this way really helps your visual look balanced and also sets the tone for what the ad is about. And finally we have one from the team at Hubspot, where they use just a simple Instagram icon to add quick context to the post:


There you have it, my personal guide to creating better Facebook Ad visuals. You should be set if you:

Include a product image

Use legible text

Feature a dark background color

Do not avoid using icons

I will be using these tips in all of my future Facebook Ads and I hope you will too.

And if you need some more guidance on creating your own Facebook Ad visuals I recommend checking out our e-book on the subject here!

Learn how to set up Facebook Ads and target your customers with effective messages to boost your sales.

Background Removal In The Image Using The Mediapipe Library

This article was published as a part of the Data Science Blogathon.

In this article, we will be making an application that will remove or replace the background of the image with another image. For that, we will be using two libraries. First, is the media pipe library for segmenting the person from the background. Second, cv2 for performing image processing techniques.

Now, we will be loading all the required libraries to build this application.

So, our very first step will be to initialize our model which will be like a pre-step for the selfie segmentation model.

In this model, we will have two types of model:

General Model: If we pass 0 as the parameter for the selfie segmentation model then the general model will be selected.

Landscape Model: If we will pass 1 as the parameter for the above model then the landscape model will be selected.

Note: If we will not specify any of the models then 0 will be selected by default i.e. General model.

But wait a minute! What is the difference between both models? Let’s discuss that:

When it comes to the general model, it specifically works on 256X256x1, i.e., 256-Height, 256-Width, 1 channel as the input, and 256x256x3 as the output. When we talk about the Landscape model, it specifically works on the 144X256X1 as the input and results in 144x256x3 output tensors other than that, both the general and landscape model is the same.

change_background_mp = change_bg_segment = change_background_mp.SelfieSegmentation()

Code breakdown:

As discussed here, we will initialize the segmentation model using 

mp. solutions.selfie_segmentation,

 if we break it down, then we can see that from the Mediapipe library, we are calling solutions class, and from that class, 

we are calling selfie_segmentation model


After model initialization, we will be setting our segmentation function, i.e., SelfieSegmentation().

Read an Image

So previously, we have initialized our segmentation model and created a selfie segmentation function as well. Now, let’s read our sample image and see what it looks like: To read the sample image from the local system.

plt.imshow: This is the matplotlib function that will help us to see/plot the image.

sample_img = cv2.imread('media/sample.jpg') plt.figure(figsize = [10, 10]) plt.title("Sample Image");plt.axis('off');plt.imshow(sample_img[:,:,::-1]);

Sample image source: Unsplash

Code breakdown:

So firstly, we are reading the image from the read() function

Then before plotting/displaying the image, we will set the size of the display using the figure function.

Finally, before displaying the image, it will be a good practice to convert the image format from RGB to BGR as cv2 will read the image in that format only when it comes to colored image, and then with the help of the show function, we will display the image.

Remove/Replace Background using Mediapipe Library

RGB_sample_img = cv2.cvtColor(sample_img, cv2.COLOR_BGR2RGB) result = change_bg_segment.process(RGB_sample_img) plt.figure(figsize=[22,22]) plt.subplot(121);plt.imshow(sample_img[:,:,::-1]);plt.title("Original Image");plt.axis('off'); plt.subplot(122);plt.imshow(result.segmentation_mask, cmap='gray');plt.title("Probability Map");plt.axis('off');


Code breakdown:

As discussed, we will first convert the BGR format image to an RGB format image.

Now with the help of process function, we will process our selfie segmentation model on the sample image.

Then as we did in the Read image section, here also we will set the figure size with the help of figure function.

Finally, we will be displaying the original image as well as segmented image side by side (by using subplot function of matplotlib) and imshow function.

Inference: So, if we will closely look at the output (segmented subplot, i.e., our main processed output) then there, we can see that some areas are neither purely black nor purely white they are a bit gray which indicates that those places our model was not able to predict that it was the background or the person so for that reason we will be using the threshold techniques to have the more accurate segmented area in the image.

So in our next step, we will be using thresholding of the mask so that we would only get two types of pixel values, i.e., Binary black and white mask, which has a pixel value of 1 for the person and 0 for the background.

plt.figure(figsize=[22,22]) plt.subplot(121);plt.imshow(sample_img[:,:,::-1]);plt.title(“Original Image”);plt.axis(‘off’); plt.subplot(122);plt.imshow(binary_mask, cmap=’gray’);plt.title(“Binary Mask”);plt.axis(‘off’);


Code breakdown:

Binary masking with thresholding: Here, we are using the concept of binary masking, which will have a pixel value of 1 for the person and a pixel value of 0 for the background. Also, we will be setting up the threshold value of 0.9, i.e., the confidence of 90% that pixel values when will be greater it will be 1 otherwise 0.

Now, again we will plot both the original and preprocessed image (one with the binary mask) using subplots and Matplotlib’s show function.

So by far, we have segmented our image accurately by performing some image preprocessing techniques. Now it’s time to visually see how the image’s background will be removed, so for that, we will be using the numpy.where() function. This function will use the binary mask values and returns white are for every 1-pixel value and then replace every area with 0 pixels, i.e., a black region with 255, which means the background will have white color only.

But, before having the required output, we have to first convert the one-channel image into the three-channel image using numpy.dstack function.

binary_mask_3 = np.dstack((binary_mask,binary_mask,binary_mask)) output_image = np.where(binary_mask_3, sample_img, 255) plt.figure(figsize=[22,22]) plt.subplot(121);plt.imshow(sample_img[:,:,::-1]);plt.title("Original Image");plt.axis('off'); plt.subplot(122);plt.imshow(output_image[:,:,::-1]);plt.title("Output Image");plt.axis('off');


Code breakdown:

As discussed, we will be using Numpy’s d-stack function to convert our image from one channel to three-channel.

Now, we will be using the Numpy’s function that will convert every black region to a white region. That is, it removes the black segmented area with the white so that it appears to be like the white background.

Finally, we will set the image size using the figure function. And then display both the original and output image using the show function.

Note: By far, for having the white background, we have used 255 as the value, but we can also have another background image as the output, for that, we just need to change the parameter in np.where function.

bg_img = cv2.imread('media/background.jpg') output_image = np.where(binary_mask_3, sample_img, bg_img) plt.figure(figsize=[22,22]) plt.subplot(131);plt.imshow(sample_img[:,:,::-1]);plt.title("Original Image");plt.axis('off'); plt.subplot(132);plt.imshow(binary_mask, cmap='gray');plt.title("Binary Mask");plt.axis('off'); plt.subplot(133);plt.imshow(output_image[:,:,::-1]);plt.title("Output Image");plt.axis('off');


Code breakdown:

So here comes the last part where we will replace the background of the image. For that, we will first read that background image using imread the function.

Now we will create one final output image. We’ll use the np. where function to replace the black region (binary asking) with the other background image.

Finally, we will display the original image, sample image, and the final segmentation result.

So, finally, we have developed our application which can remove the background of any particular image that has the person in it, though, we can also create functionality, where it can be done in real-time just like the zoom application. Still, the logic will be the same only, instead of image processing, there, we will be handling the video processing.

Key takeaways from the article

The very first takeaway from this article is that we have learned how image segmentation works and its real-world implementation.

There are ample techniques available for image segmentation. But this is one of the simplest to use as you can see it’s in the modular form.

We have also covered some image preprocessing techniques like thresholding, erosion, stack. These basic techniques are also involved in building a complete computer vision pipeline for an application.


Read on AV Blog about various predictions using Machine Learning.

About Me

Greeting to everyone, I’m currently working in TCS and previously, I worked as a Data Science Analyst in Zorba Consulting India. Along with full-time work, I’ve got an immense interest in the same field, i.e. Data Science, along with its other subsets of Artificial Intelligence such as Computer Vision, Machine Learning, and Deep learning; feel free to collaborate with me on any project on the domains mentioned above (LinkedIn).

The media shown in this article is not owned by Analytics Vidhya and are used at the Author’s discretion.

How To Reset Itunes Library On Windows 11/10?

In this post, we will learn how to clear or reset iTunes Library on Windows 11/10. iTunes is a multi-media application developed for Windows by Apple. Like how iTunes works on iPhone and Mac, it is used to store, download, and browse your entertainment content on Windows PC. However, as every other application has some bugs and issues, the same is the case with the iTunes app. Users have previously reported various problems with iTunes including issues with their iTunes library. Hence, to counter those issues, it is better to reset your library.

Now, there can be multiple reasons why you want to reset the iTunes library. As reported by most users, some common reasons are as follows:

In a lot of cases, users reportedly encountered issues when opening the iTunes application. The app either fails to load or keeps on crashing in the middle. So, if the scenario is applicable, resetting your iTunes library is a good solution to fix this issue.

A corrupted library can also cause the app to become less responsive or laggy on your Windows PC. Hence, you can reset your iTunes library in that case too, and fix all these performance issues with the app.

If you have replaced your hard drive, you might need to reset iTunes Library on the new hard disk or device.

In case you no longer need the existing one and wish to start with a new library, you can reset your iTunes library to have a fresh start with the iTunes library.

It is also useful when you want to clear unwanted content from your iTunes library.

You might have some other personal reason for resetting your iTunes library. In all cases, we got multiple methods using which you can reset the iTunes library on Windows 11/10 PC.

How to reset iTunes Library on Windows 11/10?

To clear or reset the iTunes library on a Windows 11/10 PC, you can use any of these three methods:

Manually clear your iTunes Library.

Rename the iTunes Library filename to reset your library.

Clear the media files from the iTunes Media folder.

1] Manually clear your iTunes Library

You can do a manual clearing of the unwanted items present in your iTunes library. This is quite suitable when you do not have a heavy content size in your iTunes library. Also, it is a more appropriate way to reset your library as you won’t lose all of your data from your library. So, if you want to clear specific media items from your library, go for this method.

Here are the steps to manually clear or reset the iTunes library:

Firstly, open your iTunes application on your PC.

Now, move to the Library Section from the right-side section.

After that, select the media type that you want to clear from the left-side drop-down button.

Next, manually choose the items that you want to remove or you can simply select all by pressing the CTRL + A hotkey on your keyboard.

You need to repeat the above steps for other media types as well.

This is the easiest option to reset the library. If you need more methods to reset your iTunes library, then move on to the other options listed below.

Read: How to change iTunes backup location in Windows?

2] Rename the iTunes Library filename to reset your library

If your library is huge and the application keeps on freezing or fails to open, you might not able to delete the items manually using fix (1). Hence, in that case, you can try this method to reset your library entirely. To do that, you can use the below steps:

Firstly, make sure iTunes is not running in the background.

Then, press Win+E to open your File Explorer.

Next, inside the iTunes folder, locate the “iTunes chúng tôi file.

Similarly, repeat the above steps to rename the “Itunes Music chúng tôi file to “Itunes Music Library.old.”

Finally, you can restart your computer, and iTunes will clear all the playlists and generate a fresh new library with ”Itunes Library.itl” and “Itunes Music Library.xml” once you open the app.

See: iTunes has detected a problem with your audio configuration in Windows.

3] Clear the media files from the iTunes Media folder

You can opt for the option of deleting the media files from the iTunes Media folder to reset the iTunes Library. Follow the below steps to do that:

Next, select the media files that you want to clear or you can simply select all the media files using Ctrl+A.

After that, press the Delete button to clear chosen or all media files from iTunes.

Once done, restart your PC and open the iTunes application.

On the next startup of the iTunes app, you can select the Create Library option if prompted and enter your library name. iTunes will create a new iTunes Media folder and iTunes library file, and completely reset your library. This option is the most effective way to reset your iTunes Library and you can also dump all your data.

Where is my Apple Music library stored? Is iTunes library stored in iCloud?

Itunes data is synchronized with iCloud. If you have purchased some items from the iTunes Store, they are stored in iCloud. You can download your content on any PC or phone that has iCloud installed and configured. So, you can synchronize and access your iTunes library in iCloud too.

Now read:

Update the detailed information about Pyechart Data Visualization Library For Enhanced Visuals on the website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!