PHP code example of j45un / ai

1. Go to this page and download the library: Download j45un/ai library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

j45un / ai example snippets


	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' => '***',
	    ],
	    'qcloud' => [//腾讯云
		'app_id' => '***',
		'secret_id' => '***',
		'secret_key' => '***',
	    ]
	];

	

$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();
//腾讯云
$result = Entry::Qcloud($config)->face->select('identify')->where(['image' => __DIR__ . '/../../file/face_01.jpg', 'appid' => $config['qcloud']['app_id'], 'group_ids' => ["tencent"]])->get();


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

$params = [
		['image'=> $url_1,
		'image_type' => 'URL'],
		['image'=> $url_2,
		'image_type' => 'URL']
	];

$result = Entry::Baidu(config('ai'))->face->select('matchv3')->where($params)->get();

$result = Entry::Baidu(config('ai'))->face->select('detectv3')->where(['image' => $source,'image_type' => 'URL'])->get();

match_v3,
detect_v3,
search_v3,
multi-search_v3,
useradd_v3,
userupdate_v3,
facedelete_v3,
userget_v3,
groupgetusers_v3,
usercopy_v3,
userdelete_v3,
groupadd_v3,
groupdelete_v3,
groupgetlist_v3,
personverify_v3

    '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();