clarifai / clarifai-php-grpc
Clarifai PHP gRPC 客户端
10.8.7
2024-09-23 15:12 UTC
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.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-09-23 15:13:02 UTC
README
Clarifai PHP gRPC 客户端
这是官方 Clarifai gRPC PHP 客户端,用于与我们的强大识别 API 交互。Clarifai 为数据科学家、开发者、研究人员和企业提供了一个平台,以掌握整个人工智能生命周期。使用计算机视觉和自然语言处理从图像、视频和文本中收集有价值的业务洞察。
- 在:https://clarifai.com/demo 尝试 Clarifai 示例
- 在:https://portal.clarifai.com/signup 注册免费账户
- 在:https://docs.clarifai.com/ 阅读文档
安装
composer require clarifai/clarifai-php-grpc
另请参阅 如何将 gRPC 添加到您的 PHP 安装中。
版本控制
此库不使用语义版本控制。前两个版本号(X.Y
从 X.Y.Z
)遵循 API(后端)版本控制,并且每当 API 更新时,此库都会跟随。
Z
(从 X.Y.Z
)是此库用于库特定改进和错误修复的独立发布版本号。
入门
构建客户端并在元数据变量中设置 API 密钥或个人访问令牌。
require ‘vendor/autoload.php’; use Clarifai\ClarifaiClient; $client = ClarifaiClient::grpc(); $metadata = ['Authorization' => ['Key {MY_CLARIFAI_API_KEY_OR_PAT}']];
预测图像中的概念
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"; }