说明

  1. 开发了一个像Laraval,Yii查询数据库一样,调用主流平台人工智能API的扩展,希望能帮助大家。
  2. 项目地址:https://github.com/huanghe/ai
  3. 提供百度API测试账号一枚:
   'baidu' => [
        'app_id' => '10542071',
        'app_key' => '8s6SsRRSqSEBGbHET5yQWWgT',
        'secret_key' => 'AYBUKYByCBDdaSWijinZl24WZnbCpAtt',
    ],

特性

  1. 统一AI平台SDK调用方法;
  2. 像查询数据库一样优雅调用API;
  3. 所传参数和原平台开发文档保持一致,节约开发者学习成本

Laravel使用方法

  1. 根目录下执行:

    composer require hahaxixi/ai
  2. 项目目录config下面添加配置文件ai.php,内容如下

    return [
            'face_plus' => [...],
            'baidu' => [...],
            'youtu' => [...],
    ];
  3. 一行代码调用人脸检测示例

    $result = Entry::Baidu(config('ai'))
        ->face
        ->select('detect')
        ->where(['image' => file_get_contents(__DIR__ . '/file/face_detect.jpeg'), 'id_card_side' => 'front'])
        ->get();

Yii2使用方法

  1. 根目录下执行:

    composer require hahaxixi/ai
  2. 在配置文件params-local.php添加

    'ai'=>[
       'face_plus' => [...],
       'baidu' => [...],
       'youtu' => [...],
    ],
  3. 一行代码调用人脸检测示例

    $result = Entry::Baidu(config('ai'))
    ->face
    ->select('detect')
    ->where(['image' => file_get_contents(__DIR__ . '/file/face_detect.jpeg'), 'id_card_side' => 'front'])
    ->get();

huanghe2016
10 声望0 粉丝

Two roads diverged in a wood, and I took the one less traveled by