Download the PHP package darrynten/clarifai-php without Composer

On this page you can find all versions of the php package darrynten/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

clarifai-php

Travis Build Status StyleCI Status codecov Packagist Version MIT License

Clarifai API client for PHP

This is a 100% fully unit tested and (mostly) fully featured unofficial PHP client for Clarifai

Clarifai is an artificial intelligence company that excels in visual recognition, solving real-world problems for businesses and developers alike.

PHP 7.0+

Basic use

The API is rather simple, and consists of Inputs, Concepts and Models.

Definitions

Inputs

You send inputs (images) to the service and it returns predictions. In addition to receiving predictions on inputs, you can also 'save' inputs and their predictions to later search against. You can also 'save' inputs with concepts to later train your own model.

Model

Clarifai provides many different models that 'see' the world differently. A model contains a group of concepts. A model will only see the concepts it contains.

There are times when you wish you had a model that sees the world the way you see it. The API allows you to do this. You can create your own model and train it with your own images and concepts. Once you train it to see how you would like it to see, you can then use that model to make predictions.

You do not need many images to get started. We recommend starting with 10 and adding more as needed.

Concepts

Concepts play an important role in creating your own models using your own concepts. Concepts also help you search for inputs.

When you add a concept to an input, you need to indicate whether the concept is present in the image or if it is not present.

Features

This is the basic outline of the project and is a work in progress.

Checkboxes have been placed at each section, please check them off in this readme when submitting a pull request for the features you have covered.

Application base

The client is not 100% complete and is a work in progress, details below.

The structure is heavily inspired by The official JS client

Authentication

Access is handled via oauth2.

You would need to initialise the client with your Client ID and Secret.

Predict

This is a basic library usage example that uses a predict call. The model name is aaa03c23b3724a16a56b629203edc62c

The response (abridged) would be:

This can happen either with an image URL:

or b64 encoded data:

Documentation

This will eventually fully mimic the documentation available on the site. https://developer.clarifai.com/guide

Each section must have a short explaination and some example code like on the API docs page.

Checked off bits are complete.

Inputs

The API is built around a simple idea. You send inputs (images) to the service and it returns predictions. In addition to receiving predictions on inputs, you can also 'save' inputs and their predictions to later search against. You can also 'save' inputs with concepts to later train your own model.

Add Inputs

You can add inputs one by one or in bulk. If you do send bulk, you are limited to sending 128 inputs at a time.

Images can either be publicly accessible URLs or file bytes. If you are sending file bytes, you must use base64 encoding.

You are encouraged to send inputs with your own id. This will help you later match the input to your own database. If you do not send an id, one will be created for you.

Add an input using a publicly accessible URL

Add an input using local path to image

Add an input using bytes

The data must be base64 encoded. When you add a base64 image to our servers, a copy will be stored and hosted on our servers. If you already have an image hosting service we recommend using it and adding images via the url parameter.

Add multiple inputs with ids

Add inputs with concepts

Add input with metadata

In addition to adding an input with concepts, you can also add an input with custom metadata. This metadata will then be searchable. Metadata can be any arbitrary JSON.

Add input with a crop

When adding an input, you can specify crop points. The API will crop the image and use the resulting image. Crop points are given as percentages from the top left point in the order of top, left, bottom and right.

As an example, if you provide a crop as 0.2, 0.4, 0.3, 0.6 that means the cropped image will have a top edge that starts 20% down from the original top edge, a left edge that starts 40% from the original left edge, a bottom edge that starts 30% from the original top edge and a right edge that starts 60% from the original left edge.

Get Inputs

You can list all the inputs (images) you have previously added either for search or train.

If you added inputs with concepts, they will be returned in the response as well.

Get Input by Id

If you'd like to get a specific input by id, you can do that as well.

Get Inputs Status

If you add inputs in bulk, they will process in the background. You can get the status of all your inputs (processed, to_process and errors) like this:

Update input with concepts

To update an input with a new concept, or to change a concept value from true/false, you can do that:

Delete concepts from input

To remove concepts that were already added to an input, you can do this:

Bulk update inputs with concepts

You can update an existing input using its Id. This is useful if you'd like to add concepts to an input after its already been added.

Bulk delete concepts from list of inputs

You can bulk delete multiple concepts from a list of inputs:

Delete Input By Id

You can delete a single input by id

Delete A List Of Inputs

You can also delete multiple inputs in one API call. This will happen asynchronously.

Delete All Inputs

If you would like to delete all inputs from an application, you can do that as well. This will happen asynchronously.

Models

There are many methods to work with models.

Create Model

You can create your own model and train it with your own images and concepts. Once you train it to see how you would like it to see, you can then use that model to make predictions.

When you create a model you give it a name and an id. If you don't supply an id, one will be created for you. All models must have unique ids.

Create Model with Concepts

You can also create a model and initialize it with the concepts it will contain. You can always add and remove concepts later.

Add Concepts To A Model

You can add concepts to a model at any point. As you add concepts to inputs, you may want to add them to your model.

Remove Concepts From A Model

Conversely, if you'd like to remove concepts from a model, you can also do that.

Update Model Name and Configuration

Here we will change the model name to 'newname' and the model's configuration to have concepts_mutually_exclusive=true and closed_environment=true.

Get Models

To get a list of all models including models you've created as well as public models

Get Model By Id

All models have unique Ids. You can get a specific model by its id:

Get Model Output Info By Id

The output info of a model lists what concepts it contains.

List Model Versions

Every time you train a model, it creates a new version. You can list all the versions created.

Get Model Version By Id

To get a specific model version, you must provide the modelId as well as the versionId. You can inspect the model version status to determine if your model is trained or still training.

Get Model Training Inputs

You can list all the inputs that were used to train the model.

Get Model Training Inputs By Version

You can also list all the inputs that were used to train a specific model version.

Delete A Model

You can delete a model using the modelId.

Delete A Model Version

You can also delete a specific version of a model with the modelId and versionId.

Delete All Models

If you would like to delete all models associated with an application, you can also do that. Please proceed with caution as these cannot be recovered.

Train A Model

When you train a model, you are telling the system to look at all the images with concepts you've provided and learn from them. This train operation is asynchronous. It may take a few seconds for your model to be fully trained and ready.

Note: you can repeat this operation as often as you like. By adding more images with concepts and training, you can get the model to predict exactly how you want it to.

Search Models By Name And Type

You can search all your models by name and type of model.

Searches

Search By Predicted Concepts

When you add an input, it automatically gets predictions from the general model. You can search for those predictions.

Search By User Supplied Concept

After you have added inputs with concepts, you can search by those concepts.

Search By Custom Metadata

After you have added inputs with custom metadata, you can search by that metadata.

Search By Reverse Image

You can use images to do reverse image search on your collection. The API will return ranked results based on how similar the results are to the image you provided in your query.

Search Match Url

You can also search for an input by URL.

Search By Concept And Predictions

You can combine a search to find inputs that have concepts you have supplied as well as predictions from your model.

Search ANDing

You can also combine searches using AND.

Pagination

Many API calls are paginated. You can provide page and per_page params to the API. In the example below we are getting all inputs and specifying to start at page 2 and get back 20 results per page.

Patching(Only for Concepts)

We designed PATCH to work over multiple resources at the same time (bulk) and be flexible enough for all your needs to minimize round trips to the server. Therefore it might seem a little different to any PATCH you've seen before, but it's not complicated. All three actions that are supported do overwrite by default, but have special behaviour for lists of objects (for example lists of concepts).

Merge

Merge action will overwrite a key:value with key:new_value or append to an existing list of values, merging dictionaries that match by a corresponding id field.

In the following examples A is being patched into B to create the Result:

Remove

Remove action will overwrite a key:value with key:new_value or delete anything in a list that matches the provided values' ids.

In the following examples A is being patched into B to create the Result:

Overwrite

Overwrite action will overwrite a key:value with key:new_value or overwrite a list of values with the new list of values. In most cases this is similar to merge action.

In the following examples A is being patched into B to create the Result:

Roadmap

Public Model IDs

Supported Images

Caching

Because these are expensive calls (time and money) some of them can benefit from being cached. All caching should be off by default and only used if explicity set.

These run through the darrynten/any-cache package, and no extra config is needed. Please ensure that any features that include caching have it be optional and initially set to false to avoid unexpected behaviour.

Contributing and Testing

There is currently 100% test coverage in the project, please ensure that when contributing you update the tests. For more info see CONTRIBUTING.md

We would love help getting decent documentation going, please get in touch if you have any ideas.

Acknowledgements


All versions of clarifai-php with dependencies

PHP Build Version
Package Version
Requires php Version ^7.0
guzzlehttp/guzzle Version ^6.2.1
darrynten/any-cache Version ^1.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 darrynten/clarifai-php contains the following files

Loading the files please wait ....