-: Hey, I'm gonna show you how to use AI
to tell what's performing inside of your creative images.
So we're gonna use Google's vision API,
and to do that we just need to run
PIP store, Google Cloud Vision.
It's gonna install the library that we need.
And then we're gonna just import these libraries here.
So when you're running these cells,
it's literally just click into the cell and shift enter,
or command enter if you're on a Mac
or you can click play here.
So what we're gonna do is we're gonna pull
the campaign stats, the campaign results in first.
So this is the performance data
that you get from your campaign.
So here we have like a specific ID for each creative
that we ran, that each one of these is an image
and we've got the reach impressions,
clicks, spend, conversions, whatever else you need.
So before we can do that, we need to upload it
and you should be able to see that.
We can see the campaign results, CSV here.
So what we need to do,
if you're in the notebook,
it might just have something like this.
You just click on the folder and then click upload,
and then you can kind of choose the file to upload it there.
You also want to do that for the images.
So you're gonna get a link to all the images in this folder.
I've got all the images here,
look, they're on my computer.
So you can see these are just the different ads that we ran,
you know, for our campaign.
And we wanna know, okay,
is it pictures of women or men
or is it kind of like...
You know, what style of images
worked really well for our campaigns?
Or was it these kind of, you know,
clay emoji style images that worked?
And you know, obviously there's like 20 ads here.
Yeah, you could go through and kinda manually tag them,
but it might be interesting to see
what the AI comes up with.
So once you've uploaded,
you can just run this and get the campaign results.
And then what we're gonna do is we're gonna use Google
Vision to tag each image
and then join that to the campaign results.
So what this is doing is just running through
and once you've uploaded all the images,
so you know, in this case, you'd click upload
and then find all the images on your computer
and then upload 'em that way.
This is gonna make sure that you have all those images.
So it's just gonna run through,
look in this folder in the Google Colab notebook,
and then it's just gonna kind of find everything
that's a PNG in that folder.
So don't worry too much about how this works,
it's just gonna display them with the name here.
So just gonna let that run.
Here we go.
Okay, so you can see what all the
different images look like.
This is useful because sometimes you
need to remind yourself like
What ad did we run for that campaign?
Cool.
The other thing you need to do is
get a service account, JSON.
So this is basically like a password,
but it's a file that you can save.
So if you go to this page here,
there's a link,
it tells you how to get started.
So if you haven't set up a Google Cloud
console project before,
it's gonna walk you through how to do that.
You need to enable billing.
So it doesn't work
unless you don't have a credit card behind it.
It's not really gonna cost you very much
unless you do something hilariously wrong.
But you know, for me it's like,
I think a couple cents.
And you usually get some credit
that you can use like a few hundred dollars
when you set up the Google Cloud project.
You can also...
The next thing you need to do is enable the API.
So literally, if you click on this,
it will actually just kind of look at the project
and then it's gonna confirm, you know,
within your project if you are happy to enable it.
So that's the next thing you do.
And that's just kind of a fail safe
to make sure you don't use the wrong APIs.
And then the next thing you do is get a service account key.
So if you click go to create service accounts,
then that's gonna kind of give you the different projects
and you're gonna choose that.
And then you're gonna go through this flow
and just create and continue.
Once you've got a service account,
then you basically just need to click into it
and then you wanna go to Keys,
and then you can download a key here.
So you can go add a key, create a new key,
and I'm gonna delete mine after this.
So, you know, don't worry,
you won't be able to access.
Yeah, because I'll have it deleted
by the time I put the video live
and I recommend you don't share yours with anyone.
But once you have the key...
So like if I create a new key,
it'll say like, create,
and then it'll download some JSON to my folder.
And then you basically just then upload it here.
I've renamed it.
So you can click into a file and go rename
and I've renamed it "Service account JSON,"
just to make the code run.
But you can just set yours
to whatever your thing is named here.
So if you run that fine and then you go in here.
So this is the actual code that finds the labels.
So this is just a test run.
We'll try it with one of the images.
In this case it's gonna be,
let's say image 10.
So or the, I guess that's the 11th image
because it starts counting from zero.
So it's gonna open the image.
So it's gonna read the image,
then it's gonna turn that into a Google vision image.
And then when it's in that format,
then you can get the label detection running.
And there's actually a bunch of other things you can do
with this, but label detection
is the most immediately useful.
And then once you get the response,
so this calls the API for Google Vision
and it takes a few seconds,
you get the response and then you can get the labels
as well as other things as well.
But labels is all we need.
And then what we're gonna do
here is just to test, it's working.
We're just gonna display the image
with the labels underneath.
So let's run that and see if it's working.
Here we go.
Yeah, it worked.
So this was our image.
And then we got the labels of hair,
joint, head, shoulder, eye,
flash photography, neck,
sleeve, dress, thigh,
and we can check other images as well.
So lemme try another one.
This is the first image.
So zero.
So this is a lemon, picked up the blue
and the sphere and still life.
And then you can just basically, you know,
kind of try out all the different images if you like,
kinda see what it comes up with.
It's not always fully accurate.
I think it's a good kind of directional understanding.
Sometimes it doesn't get them right.
These images themselves are actually
generated by AI as well.
So sometimes it does get confused on these
more than it does with the real images that you know
that you would use from your account.
Cool.
So now that we know it's working,
we can just run this to process all the images.
So it's gonna go through every single image
and do the same thing again.
Except instead of just printing the labels,
although it will print them,
it will also then add them to a list.
And then we're gonna use that list afterwards
to join the data together.
So I'm not gonna run that again
because it's already run here,
takes a few minutes,
but it depends on how many images you have.
But you can see that, you know...
Here it can tell that that's a peach,
which is pretty cool.
It thinks that this is a toy or maybe some office supplies.
So you can see this isn't quite get it,
but you know, these, I think these fashion photography ones
seem to work a little bit better.
So, you know, it's picking up quite a few things here.
So it's quite interesting.
So you can see all the logos as it comes through.
And then if you scroll down to the end,
now this is where we start
to get the data into the right format.
So what this does is it just goes through every label
and then for every label it adds it with the creative.
So you know, if C 39 had, you know,
C 39 creative had the label of ball and solo photography
and circle and sphere and electric blue.
So this just showing the first five rows
and then we're basically gonna then join that together
with our other data, the metrics DF,
which was the impression,
click, spend, et cetera.
So that just does merge.
And there we go.
Now we can see, 'cause C 39 had the label of ball,
we've given that the metrics from C 39
and it's given that for each one of the labels.
And then what we're gonna do is kind of join it all together
so that, you know, if multiple creators had, you know,
the circle label,
then they're gonna add up all of their metrics.
So that's what this does here,
it's gonna run this.
And there we go.
So this is kind of the beginning of the table
and what this has done is it's kind of grouped
by the creative and then just counted how many creatives
it was in and kind of spat back
which creatives it was in as well.
So seeking the action figure was in C 44,
an arm was tagged in C3,
C 34, and C 25.
So we're gonna use that in a second.
The only thing left to do really is to
attach all the metrics.
So again, this is just going through each column
and then getting just the metrics data,
so from column to onwards and then grouping by
and summing it and then kind of adding it into that column.
So every creative, so you know,
this one action figure,
it was just in creative C 44.
The reach impressions clicks will be just from C 44,
but this one arm was in C 3, C 34, and C 25.
So it has the combination,
the sum of all those metrics.
The other thing I did was just
calculated the click-through rate.
That's what I'm gonna look at for this.
We don't have a lot of conversions,
but here it's just the clicks divided
by impressions times by a hundred.
And that's what I'm kind of using to tell
which creatives were good or not.
Cool.
So one thing you'll notice is that like,
if it's only in one creative,
it doesn't tell as much.
So it's saying action figures, you know,
ranked the same as art,
1.18% click through rate.
'Cause that was the click through rate for this one ad.
So what's more interesting if it's in multiple creators,
but it wouldn't be that interesting
if it was in all the creatives
'cause then that would just be the average, right?
So what we want is any, you know,
we don't want it in all creatives.
So this is saying basically filter for any time
where the creative count was equal
or you know, it's basically it needs to be
less than the length of creative names.
And then this three
or more filter basically, you know,
needs to have at least three in the creative count call.
Cool, so then the filter DF,
I've also sorted it by values.
So sorted by click through rate descending,
and then that shows the head here.
So you can run that and you can see,
there we go.
And now we can start to tell, you know,
what types of tags are showing up as performant.
And you could look at the head
and see that this one has like,
it's only in three creatives,
but it's actually like quite a high click-through rate.
When the circle thing,
I think this is showing up in the labels,
like in the specific, you know,
the kind of the Claymation emoji thing.
So that tends to show up there.
So that's an interesting thing to look at.
We also see neck, when we show the neck,
the click rate is pretty high.
Flash photography is good,
sleeve, forehead.
Okay, so that's kind of telling us roughly what's working.
We could also look at what's not working.
So is the pale and we can see the very end.
So these are the things with the lowest click rate.
So when it notices, there's a hairstyle that seems
to perform worse.
When there's a white color in there
that seems to perform worse,
then this electric blue color.
So that's in some of the Claymation ones,
it's performing worse.
So you start to get a sense of what sorts of things
are improving performance
and what sorts of things are decreasing in performance.
And these are just correlations.
So you do need to test these hypotheses,
but this is a great way to find new ideas
of what's a test.
All right, hopefully this was useful.