LoginSignup
1
2

More than 5 years have passed since last update.

RecruitのimageInfluenceAPIを使ってみる

Last updated at Posted at 2017-04-28

概要

Recruitが肉の画像に点数をつけるAPIを無料公開したので使ってみる。
APIのアクセスキーはここで簡単に取れます。
imageInfluenceAPI

実践

imgフォルダに画像を入れておく
データはこんな感じ
29s.png

GetNikuRank.php
<?php
$url = "https://api.a3rt.recruit-tech.co.jp/image_influence/v1/meat_score";
$apikey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$predict = 1;

foreach (glob("img/*") as $imagefile) {
    exec("curl -X POST -F apikey=$apikey -F imagefile=@$imagefile 
                -F predict=$predict $url", $result);
}

var_dump($result);
 ?>

curlのとこ、phpのcurl_initとかcurl_setoptとかでカッコよくやりたかったけど
できなかったのでズルしましたm(_ _)m
誰かやり方教えてください。。。

結果

array(8) {
  [0]=>
  string(70) "{"status": 0, "message": "ok", "result": {"score": 4.119289398193359}}"
  [1]=>
  string(70) "{"status": 0, "message": "ok", "result": {"score": 4.322441101074219}}"
  [2]=>
  string(70) "{"status": 0, "message": "ok", "result": {"score": 4.786712169647217}}"
  [3]=>
  string(71) "{"status": 0, "message": "ok", "result": {"score": 4.7479472160339355}}"
  [4]=>
  string(70) "{"status": 0, "message": "ok", "result": {"score": 3.971776247024536}}"
  [5]=>
  string(71) "{"status": 0, "message": "ok", "result": {"score": 3.1198763847351074}}"
  [6]=>
  string(70) "{"status": 0, "message": "ok", "result": {"score": 4.162046432495117}}"
  [7]=>
  string(71) "{"status": 0, "message": "ok", "result": {"score": 4.1765265464782715}}"
}

結構美味しそうな写真を判定させたと思ったんだけどなぁ。

1
2
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2