In a previous lecture we haven't really created a brand new.
I sure couldn't give surveys that is going to allow us to provide some computer vision analysis into
our applications.
We're going to start in these lecture by analyzing images that will be able to find in the Internet.
So we're going to get yourself a certain image and we're going to send it to the custom Bishan API for
its analysis of course first things first I'm here on my Asherah notebooks and in my LPA dash washerwomen
library what I am going to do is create a brand new notebook.
We are going to be getting back into the azure notebooks in the previous sections we have been working
with local Jupiter because we required local functionalities such as access to the microphone in this
section we're not going to be using the microphone anymore.
So that is why I can be back here in your notebooks.
Now my new notebook is simply going to be called Computer vision.
And of course that type of fire is going to be applied in 3.6 notebook.
So I'm going to hit on new and I'm going to be opening this notebook and at it now because in this notebook
I'm going to be using that computer vision service that I have just created what I will do is get back
to my actual portal where I have these computer vision.
I sure service I'm going to get on one of the keys I'm going to create in the first cell of my new notebook
a subscription key variable that I will simply use whenever I have to access the service.
So have something like subscription King here which is going to be equal to that key that I just got
it and that will just wrong that cell.
So these variable is available now.
The first thing that I'm going to be defining here to be able to connect to that service is pretty much
every other time that we have worked the headers and the others are going to require only one value
the same value that we have been using which is OCB that's A.P.M. that's prescription Dashti optionally
of course we can always say the Content-Type and the accepte Heathers but I believe that by default
both are set to Jasen which is what we want.
If you ever see that that is not the case in any of these services you can simply sign it from the headers
to application form.
Plus Jason in this case I'm only going to be setting the OCP a subscription fee.
And of course its value is going to be the subscription King.
Next let me define the body and the body is going to require one single thing which is going to be in
the case of what we are going to be trying here.
So the body can be three different things.
It can be adjacent which is going to be the case in this example or we can be an OC to the stream or
our form data a multipart form data similar to what we used in the previous section when sending an
audio file.
Now the reason for these two other scenarios is because we can analyze in the mansion a local image
instead of analyzing remote image and image that we are going to be asked to think through your arrival.
So the creation of the body is going to be important.
It is going to define what exactly you are going to be using in here.
Either yourself for an image that you have already uploaded or for on the image that you found on the
Internet or multipart or not to the stream with the information about the image that you have locally
for this particular example then we're going to be working with our remote image using Jason in here
sitting simply the value of the rail.
For example in this case I said to the Eurail to be a certain image that I found on the web you can
do a quick Google search or just found an image that you want to analyze.
In this case I can give you.
And this is going to be and you can actually guess what this is about because this has a name pretty
giving name that says something about Paris.
So this is a photo of Paris.
Just make sure that when you said that you are rail and these ends on the extension of the Mishler wise
it is not really an image you are real.
Also make sure that your ear is ears and big ears BMG ears a gift or ease a BNP file.
The image cannot be more than four megabytes and it has to be bigger than 50 pixels by 50 pixels.
So use mixture of those two things and you will have your body ready.
In addition to the ball you of course we're going to meet the parameters and the parameters are going
to have three optional values.
So limit the fine here.
The parameters now to be able to define the Brehm's.
I am going to need to import a couple of things that let me just import the usual thing here.
I will start with your L-EB that Parr's.
We will also need HTP.
The client will need Jason and with this I shall be able to get the programs by calling from you r l
lived Parr's they your L and Cosmas and these methods ees going to receive the three optional values
that can be received by the service.
So these are optional bulled.
I'm going to mention them for you to keep in mind what you can setting here.
So the first one is going to be the visual features and the visual features are variable or volume and
here will be able to define what is it that you want the service to return to you.
And here you can set many different values.
This is going to be a string value.
You can set if you want to return a check or is if you want the service to get some tags for the image.
If you want a description if you want to identify faces which can be pretty useful in case you want
to determine gender and age and even where the face is so it's quickly and easy to maybe draw as well
around these days.
You want an image type color and whether or not DC tagged Suomi mesh that should not be seen by kids.
So we're going to do in here eat first and at least for this particular image.
That is of parries.
I am going to be asking for a description so I am going to say we show features to be description.
Additionally we could get the details and the details is just another string of journalists always that
is going to help us identify two things either celebrities or landmarks and it's simply going to be
returning US.
Whether or not it identifies any landmark or any celebrity in the picture for these particular one of
parries we're going to try landmarks.
And finally you could be saying the language the language in which you want the service to return to
information in by default is English at the moment of recording this video.
The only support languages are English DePrince is Portuguese and simplified Chinese.
I am going to be leaving this in English.
This is the default.
So I wouldn't have to establish it but I'm just going to be sending it in you so you know that this
is something that you can do and do everything that we need whether it's body parameters in the body
is important.
Think that you are a rail or if we have a local image the local image in the form of a multi-port were
enough to stream.
So now let's make the request.
I am going to be doing it in a try catch block as pretty much every single time and the first thing
is to create the connection which is going to be equal to each GTP the client got a GDP connection so
HTP disconnection and the connection is going to be established to every aimpoint or at least that Eurail
the weekend finding herefore Asher account more specifically inside of the overview for our computer
vision service each year as we can see it is deal Daut API that cognitive Dolemite quoted com.
But the important thing to notice in here ease the location of our service.
In my case south central US.
In your case and these may vary.
So it is very important that you do said this first time of the Eurail to the location where you created
the service.
So that is what I am going to be passing to the HTP s connection constructor and with the connection
I established I can make the request.
The request is going to be a post request.
The point I havent created in the year board.
If we never get back to usher you can see how by the way this is deal 1.0 as we noticed in the previews
lecture.
But it's definitely still going to be for less Rhaetian for flash and the version.
In our case we're already going to be setting that to 2.0.
So that is going to be for Flash vision for Flash VI 2.0.
In our case and to get this particular point we're going to be adding a Forth less and analyze.
So as I mentioned in a previous lecture the computer Bishan API is going to have many different endpoints
who will be able.
Among other things to make some analysis of the images to do some OCR to identify handwritten text etc..
For these particular servers that we're using right now the End Point is analyze.
And if we're going to be analyzing we're going to be requiring a couple of Purab since you're the ones
I already have in the parabens value.
So I am going to be passing the parameters so this gets added to the end of the endpoint.
Next I am going to be sending the body as a string.
This is going to be Jason.
And finally I am going to be sending the headers and that's it.
I shall be able to get the response by calling that good response.
Get some Jason data by calling from the responses.
The wreathe method.
And finally get the data itself by calling from Jason.
The load method and passing that Jason data has always do NOT forget to close the connection and finally
I shall catch any exception that may happen.
So there is everything that we need.
Let's test this out remember that the men in these games is a photo of Paris.
In fact before doing anything let me show you what this image is about.
I am going to here in that particular you are l.
You can see this is a simple photo.
There is a Boer's right here but you can see the Eiffel Tower so it's pretty easy to understand that
this is Parrys.
So now that you have seen that image let's run this el hand of course I forgot something very important
which is to print the data.
Let me try one more time and now we see these days in these digital string is going to contain some
information about the Amish.
Now taking a look at these two string you can see how it is identifying the boss as the main part of
the photo.
At least in some of the places inside here.
For example forget Greece.
We do see that one of the categories is a building.
And one of the categories ease our door to these two categories have been identified.
There is also a description which is going to have a first some tags it's correctly taking these hest
outdoors road OK Hassam callers.
It identifies a boss instead of the description it's also defining a caption which is going to be assigning
it to exit that as you can see is entirely focused on the box it says this a double decker boss parked
on the side of a road.
So it's not really identifying anything about parries or the Eiffel Tower.
It easier to find the height and the width and the formant correctly which is pretty easy.
Well you can see how we can make these requests to the service.
Now let me change this image to something now that contains people and what I'm going to do now is in
the visual features instead of description I'm going to be asking for places so we can take a look at
what this service is going to be returning.
I am going to be changing them.
There you are Ralph for the body.
I have the image right here making sure again that this is a jaybirds or at least has the extension
of any machine and changing the visual features two phrases normally show you the image and this is
probably going to be old to have on the service because it contains a lot of face to see here.
And they aren't precisely behind out of the picture.
They are they were far away.
Let's take a look at how the service behaves.
I am going to run this one more time.
And now in the Jason we see that their ears and faces are re being returned.
Unfortunately for these image it was a bit hard for the service to identify them to returns and M-theory
but you can definitely see that dignitaries have identified a crowd of people.
We see a people group as well.
You can see now the difference between passing faces.
Ampacity other scription we see definitely way less information special Hindis is in there.
We're phrases we're not identified.
Let me change these Eurail to an image dad has way less faces.
These may be easier for the service to work with.
So I am going to be sitting there Eurail to a brand new Umich again making sure that these has that
image extension.
Let me show you the image right here.
This is Mr. President Trump and the Queen of England.
So this is way easier.
Only three faces and pretty big inside of the image.
So let's take a look how the service behaves in this scenario.
I haven't changed any of the parameters.
These business deals setting their faces as we show features and we now see how the interfaces we have
in the rate of elements.
The first one is going to be defining gender its identifying the Queen as very young so any one pretty
close.
I think shes about 20 years older and we see the phase recked and will which is not only setting all
the coordinates.
A one eighty one and two hundred and five but its also turning all the weed and the height which would
be pretty easy for all to draw these squares out of image.
Then it is identifying another E-Machine here which is the second them final phase that its detecting
zero its not detecting the guard's face.
Probably because it is half covered but its correctly identifying the gender and its returning are phased
Rixton will very easily so you can see how in something easier for that or is it used correctly returning
an array of phrases.
So this is how you could be identifying this now in detail.
We are currently doing these two landmarks we could actually change this to be celebrities.
There are a couple of celebrities in this picture.
Maybe this is going to identify them.
Border want to know what is.
Here is how changing the visual features he's going to return you the information that you want.
You can see this two tags two categories two description one that I think is quite important is getting
these two adult.
If you said this to a told you will be able to identify a certain image has pornography in it and that
information may be banished from your side.
Maybe prevent this from being displayed to young kids.
So you can start to add certain functionality to your application so it is more suitable for children.
Let's for now does this with the same image but changing the details from Larrimer to celebrities.
Let me run this.
And now you can see that in the details that we have right here we're going to be having celebrities.
First there is going to be ashtrays rectangle.
It's still going to be the most.
Where is this person.
And you can see that now we see the name which is Elizabeth the Second correctly identified I'm pretty
confident at ninety nine point ninety eight percent.
Then there is another face rectangle.
It also tells us where the location of this face is the width and height and the name Donald Trump.
Again very confident at ninety nine point sixty two percent and eventually psaltery turning that faces
the same Gordon.
But remember that the faces a difference because it also tells us something about the age and gender
in this case not very accurately identifying the age.
Maybe they do look Giang but accurately identifying the gender.
And of course where the faces are with this information in the same image you could start to maybe draw
a rectangle around the faces maybe even grating the name of that people identify them.
Eventually you could also use the age and the gender to tell some information about the people there.
Now the purpose of these particular letters is not to draw all the squares in this picture we're going
to be doing that in the next section when we work with the Faces AAPI.
But it is something that you could do now before finishing this lecture.
I do want to mention that these days is it's little more difficult to understand that the ones we have
worked with before this has more information it is more cluttered.
And in fact we see elements being repeated here we see of the second.
And Donald Trump twice this year.
Why is this.
Well to be able to analyze it Jayson better instead of printing the data directly would get our form
of the data by calling from Jason Dunham's function.
This function is of course going to be requiring that Jason not it's going to format but it is also
going to allow us to do a couple of things one that is not quite important is sorting the keys so we
can set short keys to truth.
This is simply going to be sorting the name of the elements object keys alphabetically for example detail
is going to appear before name and name is going to appear before us Corps.
It's not that important but it's something that you can do.
The one that is going to be important is the indent value which is going to be sitting to do.
Well this is going to do is had some indentation so it's easier for us to understand what good is part
of what other key.
So let's run this as you can see now the agent is much much easier to understand.
We can see how the main object is going to have a Teguh risky.
It's also going to have our faces key and made data and request ITC's.
Now there are two important ones are the categories and the faces we can see how terrorist is an array
that is going to have a couple of objects in here.
One two.
And it's also going to contained in the underscore of the category which is the important thing for
that category.
And we see how one is called people whip and the other one is people.
And there is some score for each of them.
But notice that it is instead of each category where the details are being added and because there are
parameters we see the details to have celebrities we see celebrities and this is why we see it twice
because each category is going to contain those details.
As you can see here.
So that is why we see a little of the second and Donald Trump twice because they are and these details
are inside of each category.
And of course instead of celebrities there is that array with it two people being identified in there
the confidence the name and even the phrase race and all that we saw.
And then in the faces key instead of the main object we're also going to have on the rate in this case
with two elements these do not have information about who is in there but it does I did defy age and
gender at this early and finally you know the myth that it requires that I mention.
So this is how you can make the request of the computer vision API.
In this particular scenario to make some analysis in the next lecture we were of course going to continue
to work with the computer vision API but we're going to be working with another endpoint that is going
to allow us to get a description.
So it's easier for us to describe with our application what is happening is how the Amish many applications
since you're the one that I have seen being apply the most used to describe an image to a blind person
through audio.