代码拉取完成,页面将自动刷新
1.百度AI开放平台
2.腾讯AI开放平台
下载zip包 或者clone本项目
进入本项目根目录,执行composer install
,(包管理工具composer)
在项目目录tests->config
下面添加配置文件ai.php
(需要自己到各平台注册获取试用账号),内容如:
return [
'debug' => true,
'log' => [
'level' => 'debug',
'file' => './tests/logs/ai.log',//日志相对路径
'template' => "<<<<<<<<\n{response}\n--------\n{error}",//日志模版
],
'baidu' => [
'app_id' => '***',
'app_key' => '***',
'secret_key' => '***',
],
'youtu' => [
'app_id' => '***',
'secret_id' => '***',
'secret_key' => '***',
'user_id' => ****
]
'face_plus' => [
'api_key' => '***',
'api_secret' => '***',
],
];
在命令行下进入根目录,执行命令,比如测试腾讯优图人脸识别:
vendor/phpunit/phpunit/phpunit --testdox tests/Youtu/Face/FaceTest.php
composer require hahaxixi/ai
1.一般使用
$config = [
'log' => [...],//如,laravel:'file' => storage_path('logs/ai.log'),
'baidu' => [...],
'youtu' => [...],
'face_plus' => [...],
];
//百度
$result = Entry::Baidu($config)->face->select('detect')->where(['image' => file_get_contents(__DIR__ . '/file/face_detect.jpeg'), 'id_card_side' => 'front'])->get();
//腾讯优图
$result = Entry::Youtu($config)->face->select('detectface')->where(['url' => 'http://open.youtu.qq.com/app/img/experience/face_img/face_06.jpg', 'mode' => 1])->get();
//face++
$result = Entry::FacePlus($config)->face->select('detect')->where(['image_file' =>__DIR__ . '/../../file/face_01.jpg' , 'return_attributes' => 'skinstatus'])->get();
2.Laravel使用
config
下面添加配置文件ai.php
,配置内容和上文SimpleTest一致$result = Entry::Baidu(config('ai'))->face->select('detect')->where(['image' => file_get_contents(__DIR__ . '/file/face_detect.jpeg'), 'id_card_side' => 'front'])->get();
3.Yii2使用
params-local.php
添加 'ai'=>[
'log' => [...],
'face_plus' => [...],
'baidu' => [...],
'youtu' => [...],
],
$result = Entry::Baidu(Yii::$app->params['ai')->face->select('detect')->where(['image' => file_get_contents(__DIR__ . '/file/face_detect.jpeg'), 'id_card_side' => 'front'])->get();
Apache License Version 2.0 see Apache License
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
1. 开源生态
2. 协作、人、软件
3. 评估模型