Alchemy API 2

Similar documents
Bluemix いつでもWebinarシリーズ 第15回 「Bluemix概説(改訂版)」

ii II Web Web HTML CSS PHP MySQL Web Web CSS JavaScript Web SQL Web


経営論集2011_07_小松先生.indd

■サイトを定義する

SmartBrowser_document_build30_update.pptx


untitled

年刊EDP 2003

6 2 1

_IMv2.key

CSS

transform: translatex(x 方向の移動距離 ) transform: translatey(y 方向の移動距離 ) transform: translate(x 方向の移動距離, Y 方向の移動距離 ) transform: translate 関数は 移動する位置ではなく 移動

07_経営論集2010 小松先生.indd

[1] Excel Excel... [3]. CSV RDF. [4] LinkedData. [5] LinkedData 1 RDF. OLAP. OLAP. [6] RDBMS. Excel CSV. CSV JSON RDF. Excel RDF. RDF RDF..

hands_on_4.PDF

m_sotsuron


54 5 PHP Web hellow.php 1:<?php 2: echo "Hellow, PHP!Y=n"; 3:?> echo PHP C 2: printf("hellow, PHP!Y=n"); PHP (php) $ php hellow.php Hellow, PHP! 5.1.2

サンプル CSS web ページを開くと同時にピエロの玉乗りが動き出すアニメーションを作ってみましょう AnimeAuto の説明 HTML の記述 (AnimeAuto.html) ピエロの画像に pierrot という id を 玉の画像に ball という id を付けておきます <!DOCT

Homepage HTML+CSS Flash JavaScript Homepage Homepage Homepage Homepage Web HTML Hyper Text Markup Language XHTML XHTML HTML5 CSS Cascading Style Sheet

.....

画像 images/ SpaceShuttle.png を指定します <!DOCTYPE html> <html> <head> <title>circleanime1</title> <meta charset="utf-8"> <link rel="stylesheet" type="text/


SVG資料第10回目(その2) Ajaxによる同期通信と非同期通信の違い

_勉強会_丸山さつき_v3

平和教育の目標と主題(案)

ohp.mgp

help gem gem gem my help

Lotus Domino XML活用の基礎!

Web±ÜÍ÷¤Î³Ú¤·¤µ¤ò¹â¤á¤ëWeb¥Ú¡¼¥¸²Äݲ½¥·¥¹¥Æ¥à

Wiki

Microsoft PowerPoint - Tutorial_2_upd.ppt

橡点検記録(集約).PDF

Web 設計入門

2009 Web B012-1

MQTTとアンドロイドで 本格的IoTを体験しよう

~/WWW-local/compIID (WWW IID ) $ mkdir WWW-local $ cd WWW-local $ mkdir compiid 3. Emacs index.html n (a) $ cd ~/WWW/compIID

ホームページ制作 基礎編 (HTML5 CSS3 コーディング )

pdf

untitled


1.`16

WebOS aplat WebOS WebOS 3 XML Yahoo!Pipes Popfry UNIX grep awk XML GUI WebOS GUI GUI 4 CUI

SHOBI_Portal_Manual

Microsoft Word - Documento2

FileList Convert a pdf file!

Transcription:

IBM Bluemix AlchemyAPI 1

Alchemy API 2

Free API Key h"p://www.alchemyapi.com/ 3

目的 チェック ( 例 )To retrieve meta informa7on in images. 名 姓 メールアドレス確認メールアドレス 挑戦すること 4

Free API Key!! 1000! API API! API =! API API 5

API Key 6

7

ちなみに IBM では 人 工知能 (AI) とは 言いません コグニティブ (Cogni.ve 認識識型 人 工知能 ) と 言います ( ) AI 8 AlchemyAPI Watson

Alchemy Vision Alchemy Face Detec7on 結果のフォーマット 各配列要素の中身 9

URL Alchemy Vision Alchemy Face Detect API 10

AlchemyVision h"p://www.alchemyapi.com/products/demo/alchemyvision Top Page >> Products >> Demo >> AlchemyVision Demo 11

Alchemy Vision API URL URL Get http://access.alchemyapi.com/calls/url/urlgetrankedimagekeywords?apikey= API &url= URL &outputmode=json &knowledgegraph=1 12

URLGetRankedImageKeywords API { "status": "OK", "usage": "By accessing AlchemyAPI or ", "url": "h<p://xxx.com/wp- content/uploads/2015/05/aaaa.jpg", "totaltransacjons": 4", この API コールで消費したトランザクションは 4 "imagekeywords": [ 結果は imagekeywords の中 ( 配列 ) { text": sport", "score": "0.989013 sport の確率が 98.9013% と認識 }, { text": football", football の確率が 98.5226% と認識 "score": "0.985226 } ] } API http://www.alchemyapi.com/api/image-tagging/urls.html 13

API 14 h"p://www.alchemyapi.com/api/image- tagging/urls.html Top Page >> Developers >> Documenta7ons >> Image Tagging >> API Calls >> Web API

URL http://access.alchemyapi.com/calls/url/urlgetrankedimagekeywords?apikey= API Key &outputmode=json &url= URL 15

Alchemy Face Detection 16 h"p://www.alchemyapi.com/products/demo/face- detec7on Top Page >> Products >> Demo >> AlchemyVision Face API Demo

Alchemy Face Detection API URL URL Get http://access.alchemyapi.com/calls/url/urlgetrankedimagefacetags?apikey= API &url= URL &outputmode=json &knowledgegraph=1 17

URLGetRankedImageFaceTags API { "status": "OK", "usage": "By accessing AlchemyAPI or ", "url": "h"p://xxx.com/wp- content/uploads/2015/05/aaaa.jpg", "totaltransac7ons": "5", "imagefaces": [ { age : { "agerange": "18-24", "score": "0.702753 }, "gender": { "gender": "FEMALE", "score": "0.991837 }, "iden7ty": { "knowledgegraph": { "typehierarchy": "/people/ariana grande }, ] } "name": "Ariana Grande", "score": "0.622459" }, "posi7onx": "116", "posi7ony": "19", height : 48, "width": "48 } この API コールで消費したトランザクションは 5 結果は imagefaces の中 ( 配列 ) age: 推定年齢層と その確度 gender: 推定性別と その確度 個人が特定できた場合は iden7ty 内に情報が入り 名前とその確度 posi7onx, posi7ony: 顔の位置 width, height: 顔のサイズ API http://www.alchemyapi.com/api/face-detection/urls.html 18

API 19 h"p://www.alchemyapi.com/api/face- detec7on/urls.html Top Page >> Developers >> Documenta7ons >> Face Detec7on >> API Calls >> Web API

URL http://access.alchemyapi.com/calls/url/urlgetrankedimagefacetags?apikey= API Key &outputmode=json &url= URL 20

URL 21

URL Alchemy Vision Alchemy Face Detect API 22

Bluemix 23

WEB WEB 24

PHP PHP PHP 25

PHP 26

PHP kkimura -php-yyyymmdd 27

30 秒 ~ 1 分 PHP PHP 28

29

PHP 30

PHP PHP 31

(1) PHP URL ***.php?url=http://xxxxxxxx/xxx.jpg (2) URL Alchemy Vision API Alchemy Face Detection API (3) JSON (4) 32

Bluemix 1. Eclipse Eclipse 2. cf 3. IDS(IBM DevOps Services) Git 今回は cf ツールを使った方法を紹介します 33

cf https://github.com/cloudfoundry/cli#downloads Stable Installers Google Github cf 34

cf OS X cf v Mac >> 35

PHP c:\tmp\docroot 36

> cd \tmp\docroot 37

cf cf Bluemix > cf login a https://api.ng.bluemix.net/ cf Bluemix Login Bluemix PHP Space Login Error 38

PHP PHP > notepad image.php 39

image.php (1) <html> <head> <title>alchemyapi </title> </head> <body> <?php $trans1 = 0; $trans2 = 0; $trans1 = $json1->totaltransactions; $imagekeywords = $json1->imagekeywords; if( count( $imagekeywords ) ){?> <h2>keywords</h2> <table border='1'> <tr><th>text</th><th>score</th></tr> <?php 配列の結果をループで 1 つずつ取り出す if( isset( $_GET['url'] ) ){ $apikey = Alchemy API Key '; API key の値 for( $i = 0; $i < count( $imagekeywords ); $i ++ ){ $imagekeyword = $imagekeywords[$i]; $url = $_GET['url']; 画像 URL を取得 $alchemyurl = 'http://access.alchemyapi.com/calls/url/';?> $text = $imagekeyword->text; $score = $imagekeyword->score;?> <img src='<?php echo $url;?>'/> <p/> <tr><td><?php echo $text;?></td><td><?php echo $score;?></td></tr> <?php } 40 <?php $apiurl1 = $alchemyurl. 'URLGetRankedImageKeywords? apikey='. $apikey. '&outputmode=json&url='. urlencode( $url ); $text1 = file_get_contents( $apiurl1 ); $json1 = json_decode( $text1 ); モノ認識 API の URL?> </table> <p/> <?php API を実行して 結果の JSON を取り出す }

41 image.php (2) $apiurl2 = $alchemyurl. 'URLGetRankedImageFaceTags? apikey='. $apikey. '&outputmode=json&knowledgegraph=1&url='. urlencode( $url ); $text2 = file_get_contents( $apiurl2 ); $json2 = json_decode( $text2 ); $trans2 = $json2->totaltransactions; $imagefaces = $json2->imagefaces; if( count( $imagefaces ) ){?> <h2>facetags</h2> <table border='1'> <tr><th>attr</th><th>value</th><th>score</th></tr> <?php for( $i = 0; $i < count( $imagefaces ); $i ++ ){ $imageface = $imagefaces[$i]; $positionx = $imageface->positionx; $positiony = $imageface->positiony; $width = $imageface->width; $height = $imageface->height; $ageo = $imageface->age; $agerange = $ageo->agerange; $agescore = $ageo->score; 顔認識 API の URL API を実行して 結果の JSON を取り出す 配列の結果をループで 1 つずつ取り出す $gendero = $imageface->gender; $gender = $gendero->gender; $genderscore = $gendero->score;?> <tr><th colspan='3'><?php echo $i;?></th></tr> <tr><td>positionx</td><td><?php echo $positionx;?></td><td> </td></tr> <tr><td>positiony</td><td><?php echo $positiony;?></td><td> </td></tr> <tr><td>width</td><td><?php echo $width;?></td><td> </td></tr> <tr><td>height</td><td><?php echo $height;?></td><td> </td></tr> <tr><td>age</td><td><?php echo $agerange;?></td><td><?php echo $agescore;?></td></tr> <tr><td>gender</td><td><?php echo $gender;?></td><td><?php echo $genderscore;?></td></tr> <?php $identityo = $imageface->identity; if( $identityo ){ $name = $identityo->name; $namescore = $identityo->score;?> <tr><td>name</td><td><?php echo $name;?></td><td><?php echo $namescore;?></td></tr>

image.php (3) <?php }?> <?php }?> </table> <p/> <?php }?> <div align='right'> <?php echo $trans1;?> + <?php echo $trans2;?> = <?php echo ($trans1 + $trans2);?> </div> <?php }?> </body> </html> 42

! https://github.com/dotnsf/alchemyapi_php_sample! jqcloud https://github.com/lucaong/jqcloud *.php, *.js, *.css image.php, index.php jqcloud.css, jqcloud-1.0.4.js image.php, index.php apikey API Key 43

PHP 30 秒 ~ 1 分 Bluemix PHP > cf push Blumix PHP 44

PHP 45

image.php URL http://.mybluemix.net/image.php?url= URL 46

index.php URL http://.mybluemix.net/?url= URL 47

!! URL ImageGetRankedImageKeywords API ImageGetRankedImageFaceTags API 48