hello and welcome to our Channel Tech expert tutorials in today's video we will show you how to create your own application using the cloud AI Vision API in a python script we will create an anthropic account add credit so that we can start sending messages and use an API key to connect to anthropic Cloud AI online we will be using VSS code and python for this demo for more details see our video on this topic Link in the description below finally we will evaluate the accuracy of this model so please stick around until the end
to get started go to the anthropic dcom webpage you will see information about Claude and anthropic to create an account click on Claud and API then click on start building you can use a Gmail account or another email account we will use a personal email for this demo after filling out the email address click on continue open your email and copy the verification code after clicking the link in the email click on verify the signup will ask you a few questions after filling those out and accepting the terms and policy click on continue type in
your organization name the industry and website are optional click on create account before you can use the API you'll need to buy some credits you can start with5 or $10 for now click on complete setup and make your selections then click on continue add your billing information and click continue when you finish this step click on add funds and add a minimum of $5 here we suggest don't select autoload for now click on API keys on the left then click create key on the upper right give the key a name and click on ADD be
sure to copy the key to a secure location you will need it later now we will show you how to use this API in a python script first you will need to set up a python environment here are some details on how be sure to set up an environment variable named anthropic API key with a key value you copied earlier okay now we are ready to run our code the first example has a few import statements anthropic is the python SDK for connecting to the AI service then we set up an anthropic client which is
part of the anthropic SD that we imported above we need to pass in the API key so we can connect to the Cloud Server using that client we create a message to send to the server this message includes the model name we will be using there are several to choose from we set a token limit so we don't use up that $10 too quickly and include a role and content as shown finally we print the output from the Cloud Server okay that was simple this shows how easy it is to use this model and API
in an application next we will use this model to perform some OCR text extraction on an image this notebook has a few import statements including the same anthropic SDK as the first example we have a few functions the first one will encode our image to Bas 64 for sending to the API the next function takes in the API key value and the path to the image as input parameters we create an anthropic client then include our image next we create a message with the model token limit along with a more complicated message this time we
have to tell the model some information about the image and then give it a prompt that is appropriate for this use case finally we return the output with text format we include a simple error Handler for now in our main function we get the API key from the environment variable we set up earlier then select the image we want to process in our case we will be using a driver's license next We Run The extract text function from above and pass in the the key and path parameters we store the result in the extracted text
variable and print it to the screen in the last cell contains code that is common in most Python scripts it will handle the case where you run this code as a separate script or include this as a package in another script these are the results from the API the text looks reasonable now we're going to compare to the image as you can see the OCR missed a few items such as the text in the three red rectangles and some of the small gray numbers however what it did find it got all about One correct the
only mistake was the first do should be dln and the 44 should be 4D 17 of 19 items were correct given this an accuracy of 89% there are techniques we can use to improve the accuracy including some image manipulation and some prompt engineering stay tuned for videos on these Advanced topics as always comments and suggestions are welcome please like And subscribe to our Channel see you next time