---
title: "Image Categorization"
video_id: KpF-oavOL_0
url: https://www.youtube.com/watch?v=KpF-oavOL_0
workflow_page: https://workflows-of-ai.com/workflow/image-categorization
language: en
captions: generated
---

0:00 hey there uh Marcus here um I'm going to
0:03 show you a workflow today that is um
0:07 similar to something I did before so the
0:09 the idea is basically to categorize
0:12 content which is something we have done
0:14 before on text but what we're going to
0:16 do now is categorize it on these nice
0:19 images I just took some images as
0:22 example so say that we have a car
0:25 website um maybe we have a historical
0:28 car site that we already set up
0:32 and there was something where we wanted
0:35 to categorize the cars but it was just
0:39 too much work for the editors and now
0:41 it's just too much work because maybe
0:43 you're sitting on
0:45 10,000 20,000 images or something and
0:47 you you
0:48 know of course you could find a
0:50 Mechanical Turk or uh maybe a student
0:53 that's willing to help you but even that
0:56 would be a lot of work right so here
0:59 comes AI to save the day um and this is
1:03 basically what I'm going to show you how
1:05 to set this up in Drupal today uh as
1:09 usual this is just plain vanilla Drupal
1:12 uh I've only done two modifications to
1:14 it I've added the admin toolbar uh so I
1:17 can basically come to Pages a little bit
1:19 faster I will also show you I have added
1:23 uh minimum stability Dev in the composer
1:26 package that's because the AI
1:27 interpolator is still in beta there's no
1:30 stable release yet but hopefully that's
1:33 uh fixed
1:34 soon so this is the uh plugin we're
1:37 going to use today which is the AI
1:39 interpolator open
1:40 AI um together then with the AI
1:43 interpolator module which is a
1:45 requirement for all these plugins
1:48 um before I start as usual Drupal is
1:51 free AI interpolator is free everything
1:53 you see here you can do yourself after
1:56 you have uh seen this tutorial it's
1:59 going to be a little bit different uh so
2:01 I already show which kind of module to
2:03 use right I didn't do that before uh
2:07 which might have confused some people I
2:09 will also show you how you actually
2:10 install it I'm going to install it via
2:12 composer which is by
2:14 far uh the most reliable method uh for
2:18 doing it there are other ways you can do
2:21 it but yeah that's how I'm going to do
2:23 it so I just copied this composer
2:25 command I'm using something called doxal
2:28 for running this you could use DV or or
2:31 Lando or even map or something you know
2:35 set up Apache from scratch set up PHP
2:37 from scratch engine X whatever you're
2:40 however you like to set it up but in
2:42 this case I'm using dual which means I
2:43 write fin it's just a wrapper command
2:46 for for other commands to write uh run
2:49 them inside the docker container then I
2:52 just paste this so this will get the AI
2:55 interpolator open AI but also the AI
2:57 interpolator in the open AI module
2:59 because they are requirements basically
3:02 connected to to this
3:05 module uh then what I will do is
3:10 login I will go to
3:13 extend and I will just find that module
3:18 AI interpolator open Ai and I'm going to
3:20 enable that but at the same time I'm
3:22 also going to enable the media module
3:24 because in this case uh that makes sense
3:27 if you want to set categories on
3:30 images and make make it fieldable media
3:33 is the best module for it in
3:35 druple um if you're not from the Drupal
3:38 world there's so much documentation
3:41 videos that where you can learn about
3:42 the media modules or how Drupal Works in
3:46 general you will see now uh you get a
3:49 error message here that you have to set
3:51 up your open a account so I'm going to
3:53 show you how to do this you do it under
3:55 open AI
3:56 settings this is not at all best
3:59 practice this you should not be storing
4:01 it here because if you store it in a
4:03 repo that gets sent to the repo and so
4:05 on you should be using a n file and
4:09 settings.php or something like that
4:11 where it's basically maintained in a
4:13 deployment process but if you're just
4:16 testing it out you can basically just
4:18 paste it in here I'm I'm just going to
4:21 drag this out a little bit uh because I
4:25 don't want to show my key
4:27 basically uh save this this go to the
4:31 homepage and voila
4:35 we're back here we put it in here
4:40 again so that's the first step second
4:42 step is that I need to add a vocabulary
4:45 so that's basically my
4:48 uh
4:50 um my categories so I'm just going to
4:53 steal here because I'm not I don't
4:55 really know that much about cars to be
4:58 honest uh
5:01 convertible SUV so I'm just adding some
5:05 categories that it can choose from
5:08 now uh
5:11 crossover
5:14 pay
5:15 [Music]
5:17 San pick
5:20 up and hatchback I guess is enough that
5:23 was what the a this one is a hashack and
5:27 this one is a cabet I guess then I just
5:30 start adding some colors because I'm
5:32 going to make this into a uh multi field
5:35 basically so you can
5:39 um it can choose many different
5:42 categories as I as the idea right um and
5:47 so you can see also that it's truly
5:49 working um so I'm just adding some
5:52 colors and then I add two door or four
5:56 door as
5:57 well and if we just go here we can now
6:00 see all
6:02 the different choices it has just let me
6:06 see here this is blue and this is well
6:08 it's silver I guess I wrote gray but
6:10 yeah
6:12 um wait let me remove that I guess in
6:15 the car world you don't call it gray you
6:17 call it
6:18 silver
6:21 so it's just add gold see so it doesn't
6:25 confuse that and then we have the media
6:29 types where we need to add this field
6:31 basically so there's the image uh media
6:34 type that we want to use for this we go
6:35 to manage
6:37 Fields just create a new field that is a
6:40 tonomy that is this car tags we call
6:44 it uh we say that it can be
6:47 unlimited so because we wanted to check
6:50 many categories right and we choose the
6:53 uh vocabulary card tags and then we just
6:55 enable the AI
6:57 interpolator and there is this rule then
7:00 called the open AI taxonomy so that's
7:02 the rule uh that can basically choose
7:05 the categories for you
7:07 automatically uh so here's a little bit
7:11 funny in this case so you can install
7:13 the token module so you can run the
7:15 Advan mode but I'm not going to show you
7:16 that here so what you should do in this
7:19 case is that you should just uh as a
7:22 context field take a field that gets
7:23 filled out which name will be
7:26 automatically uh and the reasoning for
7:28 that is that's something has to be
7:30 filled out for it to start the process
7:32 but in this case the name doesn't really
7:35 matter so we're setting a context that
7:37 doesn't matter
7:38 right uh so what the context actually is
7:42 going to be in this case is the image
7:44 right and how to do this is that we go
7:45 to advanced settings under the model we
7:49 choose GPT Vision preview because that's
7:51 one of the modu models that actually has
7:54 the possibility to read uh uh read an
7:57 image and figure out something from it
8:00 and when we do that you see this drops
8:02 up open AI Vision image and then you
8:04 just choose the field that you actually
8:06 want the image to be the context of
8:10 right and this means uh in the prompt we
8:14 can actually copy here because it's
8:16 almost
8:19 correct So based on
8:22 the instead of context text here will
8:25 write image shoose up no shoose between
8:31 2 to four 2 to four categories from the
8:35 category context that fits the text and
8:37 then category options you get from the
8:40 context here so value options comma
8:42 means that basically takes the list that
8:44 we created before and gives it to uh to
8:48 open AI as a comma separated
8:51 list and then just asks it right based
8:54 on this list take two to four categories
8:58 that fits uh this image and then we just
9:01 remove this context because we don't
9:03 have a text
9:06 context uh the weight can be 100 we can
9:09 save it directly because we don't chain
9:11 any AI in this
9:15 case so we just save
9:20 that um and then I will just go ahead
9:24 here basically and take uh content add
9:27 media image
9:31 oh this looks a little bit funny let's
9:32 fix that
9:34 first so we go to form
9:38 display car tag should be here and we
9:40 say that it should be a checkbox
9:44 instead because that looks a little bit
9:47 nicer here so you can
9:49 see if this was without AI what would
9:53 happen is basically I would
9:55 upload an
9:57 image write the all text there is AI to
10:00 write all text as well by the
10:03 way
10:05 sorry
10:08 um uh let's no just write audio Audi and
10:12 then you would have to fill this
10:14 out which is yeah it's not much work but
10:18 of course if as I said if you have a
10:20 backlog of 20,000 images that you have
10:24 already then it's not so fun so what we
10:27 do instead we just leave it empty and
10:29 then the interpolator understands oh I
10:31 should kick in and try to do something
10:33 here so when we save this you're going
10:36 to notice that it takes some time
10:38 especially this is local so it doesn't
10:40 need time to upload anything right uh
10:44 and if you click edit now you see it has
10:46 filled in four door blue and a hatchback
10:49 so it worked we're just going to try one
10:51 more time add image and we try this uh
10:56 A5
10:58 C
11:00 same thing here we save
11:05 it take some time because it needs to C
11:08 uh contact open AI of course
11:12 and if we go to the cabola you see it's
11:15 a twodo convertible silver I we just
11:19 check here it is a twodo right and it
11:23 show
11:24 silver um and
11:27 that's it basically it's not more
11:31 complex than that that's how you can set
11:32 up automatic categorization on images uh
11:36 using the AI inator and the AI inator
11:39 open
11:40 AI um yeah so thanks for watching and uh
11:45 Happy
11:46 usage
