Download the PHP package clarifai/clarifai-php without Composer

On this page you can find all versions of the php package clarifai/clarifai-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package clarifai-php

DEPRECATED

This API Client is no longer supported.

Please use Clarifai PHP gRPC instead, which is faster and more feature-rich.

Clarifai API PHP Client

Latest Stable Version License

Installation

composer require clarifai/clarifai-php

Note: If you're not using a framework (e.g Laravel), you may need to require the autoload.php file produced by composer: require_once('vendor/autoload.php');

Prerequisites

PHP >=7.0

Note: This library requires the curl PHP extension to be enabled. This is most likely already done on your PHP host service, unless you're hosting PHP yourself, in which case you may need to uncomment (delete ;) the line extension=php_curl.dll in your php.ini file.

Getting Started

We're going to show three common examples of using the Clarifai API. Below are all the imports needed to run these examples. In addition, the ClarifaiClient object is created which is used to access all the available methods in the Clarifai API.

Note: Rather than hard-coding your Clarifai API key, a better practice is to save the key in an environmental variable. If you skip the argument and do simply new ClarifaiClient(), the client will automatically try to read your API key from an environmental variable called CLARIFAI_API_KEY which you should set in your environment.

Example #1: Prediction

The following code will recognise concepts that are contained within each of the images in a list. It uses our general public model that recognizes a wide variety of concepts.

If your use-case requires more specific predictions, you can use one of the more specialized public models such as the weddingModel, foodModel, nfswModel etc. Here is a list of all the available models.

Note: You can also create your own models and train them on your own image dataset. We show how to do that in Example #2. Besides running the prediction on an URL image using new ClarifaiURLImage, you can also predict on a local file image by using new ClarifaiFileImage.

See below how to access the data from the $response variable. For each image, we print out all the concepts that were predicted by the model for that image.

Note: The value stored in $concept->value() is the precentage likelihood that the concept by the name of $concept->name() is contained within an image.

When something goes wrong, you can handle the error and inspect the details. In your program, this code below would go above the previous section of code.

See the Clarifai Developer Guide on how to do predict concepts in videos.

Example #2: Custom model Creating and training a custom model on some inputs and concepts

You can create your own model, add training data, and use the model to perform predictions on new images in the same way as in Example #1.

This is done by first creating concepts are the subject of our model. Sample inputs are then added which we associate or disassociate with certain concepts. After the model is created, we train the model, after which the model is available to performing predictions on new inputs.

Example #3: Visual search

An image can be used in a search to find other visually-similar images. After adding some images using addInputs (see Example #2), we use searchInputs to perform the search.

Please see the Clarifai Developer Guide to find out more of what the Clarifai API can give you.

Getting Help

If you need any help with using the library, please contact Support at [email protected] or our Developer Relations team at [email protected].

If you've found a bug or would like to make a feature request, please make an issue or a pull request here.

License

This project is licensed under the Apache 2.0 License - see the LICENSE file for details.


All versions of clarifai-php with dependencies

PHP Build Version
Package Version
Requires google/protobuf Version ^v3.6.0.1
php Version >=7.0.0
grpc/grpc Version ^1.12.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package clarifai/clarifai-php contains the following files

Loading the files please wait ....