Setting up API and Vision Intro - Google Cloud Python Tutorials p.2
Key Takeaways
The video demonstrates setting up the Google Cloud Vision API and using it to analyze images, covering initial setup for Google Cloud APIs, installing the Google Cloud SDK, and utilizing the Vision API to detect labels and extract attributes from images. Specific tools used include the google-cloud library, pip, and the Google Cloud API manager.
Full Transcript
welcome everybody to part two of our Google Cloud tutorial miniseries in this video what we're going to be doing is covering the first API but also just kind of how to set up any of the apis that you're going to use because the first time you go through this you've got to deal with some sort of API validation key and stuff like that so um also you have to install the actual Google Cloud stuff to work on the server so anyway uh the first one that we're going to work with is the actual Vision API so this is something you can feed an image to and it can and the API will basically give you information on this image what's in the image what is the image about uh can even give you some metadata on that image so if it sees something that it recognizes so if you FedEd an image of um like the Eiffel Tower or something like that the metadata might include the Wikipedia page for the Eiffel Tower anyway uh let's go ahead and get started so we you should on a fresh server we did install htop so we could Bop on in there and look at htop if we wanted contrl C to get out of that um and so we should be in our kind of typical home directory so and if not just CD to tility here and then that way we're basically back at um just well this puts us in the root directory so now what I want us to go ahead and do is um we're going to make dur uh we'll call this gcloud stuff and then let's change directory CD gcloud stuff and what I'm going to do here is first let's go ahead and make sure we've got pip so you should have it but just in case pseudo app get install actually I'm not sure if these servers will come with Pip or not anyway pseudo app get install python-pip no doesn't look like we had it already so cool let's grab it other thing we probably should have done is an update and upgrade but but you can do that on your own time I think we'll get away with not doing it even Pip's taking a while once we get PIP we're going to install uh google-cloud you can alternatively do google-cloud dvision if that's the only one you want since I'm going to be doing a series on Google Cloud I'm going to do pseudo pip install google-cloud but if you just wanted Vision you could type- Vision but I want the whole thing so I'm going to install the full everything so just as you can see everything's getting installed here um once we've done that there's one more thing that we really need to do and that is the API key for dealing with the apis so while this is running head back over to Google Cloud here and let's click on the little hamburger thing go to API manager and then come on down to credentials and once you're in the credentials what we're going to want to do is create credentials we'll do a service account key and let's choose a new service account and I'm going to call this um API tutorial something like that roll uh project and let's just give it owner um which just gives us full access to everything so I'm going to give it owner you can give it really specific access so if you had you know if this was your business and then you could give specific keys to certain of your employees or something like that but for now I'm the owner so I get full access we do want Json so we'll hit create and this will give us a file that's going to download that file downloaded go ahead and just kind of save it and put it somewhere so save to my computer I'm going to move this over here and what we're going to do now is um well I'm just going to leave it there but we can open it up and this is the file so it just has some information in here um I wouldn't show this to people normally but this server will be deleted soon enough anyway so by the time you see it um this won't matter anyway but anyways that's what's in it this is something we can copy and paste so we've got that let's go back to our server now and what I'm going to do is um that's weird we just installed it and it wants an update okay let's go we can upgrade it that's fine pip install D- upgrade pip and now what we want to do is add this API key so I'm going to go ahead and just uh Nano API key uh. Json and it's an empty file so I'm going to now take that file that we just downloaded from Google copy come over here paste contrl X to save yes enter whatever you can feel free to use a different editor if you like I know someone's going to be like why did you use Nano okay so I like to use silly editors now uh once we've done that the next thing that we can do is um so for example like if you if you go to Google basically what they tell you to do is okay export and then Google uncore application unor credentials equals and then you give the path to those credentials this is going to run off the screen so let me make sure this is all shown there we go equals and then the path to what we just made so that's slash uh gcloud stuff you can hit tab to a to complete API key. Json so we could do that and hit enter maybe not a valid identifier export what did I do wrong let's see export Google application credentials um maybe no space I'm not positive why that failed okay I guess this a space that's interesting okay um but the problem with this is if you restart your server or whatever it's not going to work so what we're we're going to go ahead and do is um let's do Nano till SL period profile and then just go to the very bottom of this profile and then actually what we want to do is copy that line so let's go ahead and copy this line here you can right click to copy there it is I don't really want that there and then now let's go ahead and Nano into the profile again and then right click to paste let's fix this little space here and then contrl X yes good and then to update that we'll do Source uh bash RC and now we'll be working off that either way it should have worked because we exported it initially but basically this is like adding something to your path so now when when we use the Google Cloud um python API it knows okay here's where we can find the API key all right so now that we've done that let's go ahead I'm going to makeer Vis Vision EX for example I'm going to CD into Vision ex great now I'm going to go ahead and Nano Vis vision ex. piy and this will be a new python file and what we're going to go ahead and do is first I'm going to import IO I'm going to go from google. cloud import vision and then we can specify Vision CL client so I'm going to say Vision client equals vision. client and now we need an image so what I'm going to go ahead and do is come over here and I'm just going to search for um quido and rossom great let's go to his Wikipedia page great picture let's copy that image address uh and then we'll come back over here and in fact we need to kind of let me just save this here so yes so we're back over here contr x save yes uh I'm going to do a w get that image awesome so that image name is is here LS to list out the directory I'm going to copy that image and then now back vano Vision X or Nano and now um we're going to specify the file name so we're going to say file name equals right click boom make sure it's not running over my face and now we've got the file so now we want to load this image into memory so we're going to say with io. openen file name RB as image file what do we want to do we're going to say content equals image file. read we're going to say image equals vision _ client. image and then content equals [Music] content and then we can get something simple like labels there's more things that we can do with vision we're going to continue but for now I just want to do something really simple and basic because this one's going to serve both as an intro to the vision API but also just how to use any of the apis because the process is pretty similar labels equals image. detector labels so this will just tell us what Google happens to see in this image so we're just going to print out um and in fact let's iterate through labels so let's say four label in labels we can print print label. description and let's just do that and then I'm going to give you some advice on using this API so yes enter and let's go ahead and I think we might have to use pseudo for this but let's just try to run it without pseudo oh we haven't enabled the API okay so duh okay that's the whole point of this tutorial so oh yeah so we got the permission denied so we got the API key but we haven't enabled the vision API in our actual um platform so the easiest thing to do there is some way to get there probably here maybe I don't know I don't know how to get there for real but you can just search like VIs Vision boom Google Cloud Vision API no problem you get here enable the API okay now we'll come back over it did say wait a few minutes after you you enable the API let's go ahead and try it hopefully I didn't just sacrifice a few minutes for [Music] everybody boom done so actually that was very quick okay so what does it see in the image it sees hair face person facial hair nose chin hairstyle beard head and senior citizen sorry guo okay so um so this is like a really quick example there's more stuff I'm definitely going to show you um but the one thing I do want to show you that I think is kind of um part of all the apis is I think the document usually Google's really good about documentation but there's a lot of the examples that don't have python examples yet and then the documentation is me and the code is kind of a challenge to crawl through so for example when you have like the labels and labels and actually even labels like so for example um I'm trying to think how I want to do this what I probably could do is I think we'll do this let me just copy this exit no let's run python um and I think I can do this let's see if this if we get away with this great so so I'm just writing this in regular python so if we do something like this like dur this will tell you all the kind of attributes of something right so for example we could say dur labels and this just tells us kind of what what are all the attributes and things and methods that we can do we've got a pend count count okay um so clearly this is something that's an iterable just by looking at this but then what what we can do is like for label Ender uh or rather let's let's see let me just do label real quick yeah so let's do dur label um as we can see each of the labels like cuz basically this is storing the last label that was iterated through kind of a thing with python so um what we have or all the attributes of a label that we could possibly access so these ones you anything with the underscores you probably want to leave alone unless you really know what you're doing but um you've got um interesting do they have score anywhere yes they do okay so bounds description from API repper I'm not sure what that even does I don't know what this one is either local locations mid I don't know and score but like we used description to get what is the actual thing right that gave us the hair the face beard person and all that kind of stuff but there's some other attributes too like locations unfortunately I don't think I've ever seen locations work so for example for label in labels um print label. locations let's do label. locations lab do local I don't think that one either has any information yeah so local I'm not really sure local what that would normally give you so clearly it looks like it's going to give you a you know text Data of some kind but anyway I was really hoping locations would work but I actually haven't found an image that locations works on at all so it' be nice if you could show The Vision API um a picture of a bunch of cars and it would see yes this has cars and then here are all the X and Y coordinates for those cars or or even better like a box that would be awesome to give you like the Box coordinates like the top left in the bottom right corner that'd be really neat but that doesn't seem to be the case and like I said I've never seen locations work clearly it looks like it's probably going to be some X and Y data or even box data but it's just not there so um and I've never like I said I've never seen it actually do anything but you do get at least an an an explanation of what's in the image you're looking at which is actually pretty impressive um and then like I said some of the stuff gets even more interesting because it especially if you if you show it things that should have metadata and it actually finds the metadata okay so that's a really quick example of the vision API and then also just using apis in general don't forget to enable the API I always forget but at least now you know what it's going to look like when you do forget it's going to be like this permission denied basically um go and enable the API also the key we won't ever have to do that again so now that it knows where the key is we don't have to generate a key every time we want to use a different API but you do have to enable that API all right so if you have questions comments concerns whatever feel free to leave them below otherwise I will see you in the next video where we're going to be doing a little bit more with the vision API because it's a cool API and you can do some neat things with it um but other than that see you next time
Original Description
Welcome everyone to part 2 of the Google Cloud tutorial series. In this tutorial, we're going to be covering the vision API, but also covering the initial set up for just about any of the APIs. Some of the setup that we do here will only need to be done once in this series.
Sample code: https://pythonprogramming.net/vision-api-intro-google-cloud-tutorial/
https://twitter.com/sentdex
https://www.facebook.com/pythonprogramming.net/
https://plus.google.com/+sentdex
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from sentdex · sentdex · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Matplotlib Python Tutorial Part 1: Basics and your first Graph!
sentdex
Python Encryption Tutorial with PyCrypto
sentdex
Python's Logging Function
sentdex
wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
sentdex
wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
sentdex
wxPython Programming Tutorial 3: Menu Bar and Menu Button
sentdex
wxPython Programming Tutorial 4: Panels
sentdex
wxPython Programming Tutorial 5: User Input Saved To Variables
sentdex
wxPython Programming Tutorial 6: Multiple Choice Input
sentdex
wxPython Programming Tutorial 7: Adding Static Text and Colors
sentdex
wxPython Programming Tutorial 8: Custom Button Images
sentdex
wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
sentdex
Basic PHP Tutorial 13: Multi-dimensional Array
sentdex
Basic PHP Tutorial 15: Functions and Global Variables
sentdex
Basic PHP Tutorial 12: Associative Array
sentdex
Basic PHP Tutorial 14: Foreach loop
sentdex
Basic PHP Tutorial 16: Include and Require
sentdex
Basic PHP Tutorial 7: Assignment, comparison and Logical operators
sentdex
Basic PHP Tutorial 4: Variables and Comments
sentdex
Basic PHP Tutorial 11: Arrays part 1, basic array
sentdex
Basic PHP Tutorial 6: If else and else if conditionals cont'd
sentdex
Basic PHP Tutorial 1: Intro to PHP
sentdex
Basic PHP Tutorial 3: HTML with PHP
sentdex
Basic PHP Tutorial 9: While Loop
sentdex
Basic PHP Tutorial 10: Switch Statement
sentdex
Basic PHP Tutorial 2: Print and Echo
sentdex
Basic PHP Tutorial 5: If else and else if conditional statements
sentdex
Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
sentdex
Basic PHP Tutorial 17: User Input Form Example / String Manipulation
sentdex
Basic PHP Tutorial 18: HTML Entities and forms cont'd
sentdex
Basic PHP Tutorial 19: Finding words in strings
sentdex
Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
sentdex
Basic PHP Programming Tutorial 22: Hashing part 2: salting
sentdex
Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
sentdex
Basic PHP Programming Tutorial 21: MD5 Hashing For Security
sentdex
Basic PHP Programming Tutorial 24: String similarity
sentdex
Basic PHP Programming Tutorial 25: Time and Time stamps
sentdex
Basic PHP Programming Tutorial 26: Die and Exit
sentdex
Basic PHP Programming Tutorial 27: MySQL Databases Part 1
sentdex
Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
sentdex
Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
sentdex
Basic PHP Programming Tutorial 30: MySQL database in Use
sentdex
Django Tutorial Web Development with Python Part 1: Installing Django
sentdex
Python Tutorial: File Deletion and Folder Deletion / directory deletion
sentdex
Python Tutorial: How to Rename Files and Move Files with Python
sentdex
3D Graphs in Matplotlib for Python: Basic 3D Line
sentdex
3D Plotting in Matplotlib for Python: 3D Scatter Plot
sentdex
3D Charts in Matplotlib for Python: Multiple datasets scatter plot
sentdex
Sikuli Tutorial 1: Visually programming in python!
sentdex
Sikuli Tutorial 2: Program visually in python!
sentdex
Sikuli Tutorial 3: Program visually in python!
sentdex
3D Bar Charts in Python and Matplotlib
sentdex
3D Plane wire frame Graph Chart in Python
sentdex
Raspberry Pi Part 1 Introduction
sentdex
Raspberry Pi Part 8: First Download and Update! (Firmware)
sentdex
Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
sentdex
Raspberry Pi Part 11: Remote Desktop
sentdex
Twitter Analysis: How to rank a user's influence
sentdex
GPIO Tutorial for Pi Part 2 - Programming the GPIO
sentdex
GPIO Tutorial for Raspberry Pi Part 1 - Setting up
sentdex
More on: Tool Use & Function Calling
View skill →Related AI Lessons
⚡
⚡
⚡
⚡
How to Create a Second Version of Yourself Inside Obsidian Using AI (Step-by-Step Guide)
Medium · ChatGPT
How to prepare for Spain civil service TIC exam using AI in 2026
Dev.to · David García
Going Viral! How I Created AI Kissing Videos Step by Step Easily Using AIAI.com
Medium · AI
How to prepare TIC teacher exams in Spain with AI (oposiciones 2026)
Dev.to AI
🎓
Tutor Explanation
DeepCamp AI