Quick Start Guide - PHPfanatic/clarifai GitHub Wiki
Welcome to the quick start guide, you are here because you have no patients. I'm kidding, you are probably hyper intelligent and do not need a walk-through as you will learn what you need by looking at the code. So lets get to it.
First, the library client is included into your application via use
and is instantiated with your clarifai apikey which is obtained when your create your project at Clarifai
Predict
Predict analyzes your images and tells you what's inside of them.
use PhpFanatic\clarifAI\ImageClient;
$myclient = new ImageClient([apikey]);
$myclient->AddImage('http://phpfanatic.com/projects/clarifai/cat.png');
$result = $myclient->Predict();
$result
will contain a json response with the prediction results returned by clarifai' API.
What we did by line:
-
Included the ImageClient library.
-
Instantiated the ImageClient with our clarifai credentials.
-
Added an image to our ImageClient object to be worked with.
-
Requested that clarifai api analyze the image we added and return a result.
Read the Predict documentation to learn how to switch to different models, upload multiple image etc. etc.
Inputs
You start by adding images (inputs) to an app. These get automatically tagged with the 'general' model.
$myclient->ClearImages();
$myclient->AddImage('http://phpfanatic.com/projects/clarifai/cat.png');
$myclient->AddImage('http://phpfanatic.com/projects/clarifai/dog.png');
$result = $myclient->InputsAdd();
$result
will contain a json response with the result returned by clarifai' API.
What we did by line:
-
Removed any previous images we were working with in our ImageClient object.
-
Added an image to our ImageClient object to work with.
-
Added a second image to our ImageClient object to work with.
-
Requested that clarifai api add all images we added to our project.
Read the InputsAdd documentation to learn how to add id's, concepts, metadata and crop points to your images.
Search
You can use text or visual content to search across your collection of images that we just added.
$result = $myclient->Search('dog');
$result
will contain a json response with the results returned by clarifai' API.
Read the Search documentation to learn how to search in great detail or by image relation.