How To Gather Data For Image Recognition

How To Gather Data For Image Recognition?

Let’s discuss image recognition on how to gather data? Therefore, by using the Bing Image Search that can generate your dataset.

Gather Data For Image Recognition

Furthermore, some of the explanation of a Bing Image Search API is a part of the cognitive service on azure. Therefore it gives us the possibility to search for an image just like how would do on an image.

Yet, let us discuss the 8 steps to gather data of image recognition.

Step 1: Install/ Import Necessary Packages

This Bing Image Search has his python SDK, it is very handy. Therefore if you want you can also make use of the classic HTTP request methods.

Step 2: Configure Subscription key + endpoint

After creating a cognitive service resource they can find the subscription key + endpoint from the Azure portal. Therefore you don’t need to look at fora specific bing search cognitive service. 

It because the bing search and many ore cognitive services have been implemented in one resource.

Step 3: Configure Client

We have created 2 new objects in this step. Such as the credentials which contain the subscription key that we just configured. So the other one is the client that we will use and make a call.

Step 4: Search And Gather The Results

So when searching for an item make sure that the client object and the search function is has a bunch of variables that can configure. Therefore in these cases, we have to configure out what we have searched for and how many results we want to get.

Step 5: Convert To Data Frame

This result have we receive from the API is a list of objects. Yet, in this case, that we want to work with had clear data.

Therefore the functionality we convert of data to a data frame. Also, you will notice that we get quite some information back.

Some of the information is stored in an object. However, in this case, we don’t need this data. 

Step 6: Generate New Filenames

Thus data that we get from many different websites has a chance that some filenames might be totally the same. Also, plus some files might not have an extension with the URI, it because of routing or image generation.

Therefore to fix it we need to add a function that guesses the mime-type and also based on that looks up the extension that belongs to it.

Step 7: Create Folder To Save The Image

This folder is for your local or cloud environment.

Step 8: Download Images

Therefore we need to create a function that tries to download the file to the new destination with the new filename. Also, the bing search might be outdated, so there are possibilities that certain downloads we fail.

Therefore the function returns to the true or false by depending if the download was a success.

Furthermore, by applying this function of every row, every result will be downloaded and will be added to the extra column that keeps the track if it was successful or not.

Click to rate this post!
[Total: 0 Average: 0]

Leave a Comment

Your email address will not be published. Required fields are marked *