clarifai / clarifai-php-grpc
Clarifai PHP gRPC client
Installs: 22 154
Dependents: 0
Suggesters: 0
Security: 0
Stars: 11
Watchers: 13
Forks: 1
Open Issues: 3
Requires
- google/common-protos: ^1.2
- google/protobuf: >=3.12.2
- grpc/grpc: >=1.41.1
Requires (Dev)
- phpunit/phpunit: 9.2.6
- dev-master
- 10.10.1
- 10.10.0
- 10.9.8
- 10.9.7
- 10.9.6
- 10.9.5
- 10.9.4
- 10.9.3
- 10.9.2
- 10.9.1
- 10.9.0
- 10.8.7
- 10.8.6
- 10.8.5
- 10.8.4
- 10.8.3
- 10.8.2
- 10.8.1
- 10.8.0
- 10.7.2
- 10.7.1
- 10.7.0
- 10.6.5
- 10.6.4
- 10.6.3
- 10.6.2
- 10.6.1
- 10.6.0
- 10.5.3
- 10.5.2
- 10.5.1
- 10.5.0
- 10.4.1
- 10.4.0
- 10.3.3
- 10.3.2
- 10.3.1
- 10.3.0
- 10.2.1
- 10.1.6
- 10.1.5
- 10.1.4
- 10.1.3
- 10.1.2
- 10.1.1
- 10.1.0
- 10.0.10
- 10.0.9
- 10.0.8
- 10.0.7
- 10.0.6
- 10.0.5
- 10.0.4
- 10.0.3
- 10.0.2
- 10.0.1
- 10.0.0
- 9.11.5
- 9.11.4
- 9.11.3
- 9.11.2
- 9.11.1
- 9.11.0
- 9.10.8
- 9.10.7
- 9.10.6
- 9.10.5
- 9.10.4
- 9.10.3
- 9.10.2
- 9.10.1
- 9.10.0
- 9.9.6
- 9.9.5
- 9.9.4
- 9.9.3
- 9.9.2
- 9.9.1
- 9.9.0
- 9.8.5
- 9.8.4
- 9.8.3
- 9.8.2
- 9.8.1
- 9.8.0
- 9.7.3
- 9.7.2
- 9.7.1
- 9.7.0
- 9.6.0
- 9.5.0
- 9.4.0
- 9.3.0
- 9.2.0
- 9.1.1
- 9.1.0
- 9.0.0
- 8.11.0
- 8.10.0
- 8.9.0
- 8.8.0
- 8.7.0
- 8.6.0
- 7.9.0
- 7.8.0
- 7.7.0
- 7.6.0
- 7.5.0
- 7.4.0
- 7.3.0
- 7.2.0
- 7.1.0
- 7.0.0
- 6.11.1
- 6.11.0
- 6.10.0
- 6.9.0
- 6.8.1
- 6.8.0
- 0.0.2
- 0.0.1
- dev-Version_10.3.1
- dev-Version_10.2.0
- dev-grpc-test-3
This package is auto-updated.
Last update: 2024-11-21 13:18:07 UTC
README
Clarifai PHP gRPC Client
This is the official Clarifai gRPC PHP client for interacting with our powerful recognition API. Clarifai provides a platform for data scientists, developers, researchers and enterprises to master the entire artificial intelligence lifecycle. Gather valuable business insights from images, video and text using computer vision and natural language processing.
- Try the Clarifai demo at: https://clarifai.com/demo
- Sign up for a free account at: https://portal.clarifai.com/signup
- Read the documentation at: https://docs.clarifai.com/
Installation
composer require clarifai/clarifai-php-grpc
See also how add gRPC to your PHP installation.
Versioning
This library doesn't use semantic versioning. The first two version numbers (X.Y
out of X.Y.Z
) follow the API (backend) versioning, and
whenever the API gets updated, this library follows it.
The third version number (Z
out of X.Y.Z
) is used by this library for any independent releases of library-specific improvements and bug fixes.
Getting started
Construct the client and setup your API key or Personal Access Token in the metadata variable.
require ‘vendor/autoload.php’; use Clarifai\ClarifaiClient; $client = ClarifaiClient::grpc(); $metadata = ['Authorization' => ['Key {MY_CLARIFAI_API_KEY_OR_PAT}']];
Predict concepts in an image:
use Clarifai\Api\Data; use Clarifai\Api\Image; use Clarifai\Api\Input; use Clarifai\Api\PostModelOutputsRequest; use Clarifai\Api\Status\StatusCode; [$response, $status] = $client->PostModelOutputs( new PostModelOutputsRequest([ 'model_id' => 'aaa03c23b3724a16a56b629203edc62c', // This is the ID of the publicly available General model. 'inputs' => [ new Input([ 'data' => new Data([ 'image' => new Image([ 'url' => 'https://samples.clarifai.com/dog2.jpeg' ]) ]) ]) ] ]), $metadata )->wait(); if ($status->code !== 0) throw new Exception("Error: {$status->details}"); if ($response->getStatus()->getCode() != StatusCode::SUCCESS) { throw new Exception("Failure response: " . $response->getStatus()->getDescription() . " " . $response->getStatus()->getDetails()); } echo "Predicted concepts:\n"; foreach ($response->getOutputs()[0]->getData()->getConcepts() as $concept) { echo $concept->getName() . ": " . number_format($concept->getValue(), 2) . "\n"; }