ã¿ã¤ãã«ã®ããã£ã¼ãã©ã¼ãã³ã°ãã¯ã¡ãã£ã¨é£ããããã§ãã;
Â
AlchemyVisionã¨ãããç»å解æãããã¹ã解æã«Deep Learningãå©ç¨ã§ããAPIã話é¡ã«ãªã£ã¦ãã¾ãã
æ©æ¢°å¦ç¿ç³»ãµã¼ãã¹ã®ç°¡åãªç´¹ä»è¨äºãæ¸ãã¾ãããæ·±ã話ã¯ããããã AlchemyAPIã®AlchemyVisionã使ã£ã¦ã¿ã http://t.co/nxbUY7b7h3 #techsketch
â Jun Saeki (@sobeit) June 23, 2014
AlchemyAPIã¯ç±³å½ã®ã³ãã©ãå·ãã³ãã¼çºã®äººå·¥ç¥è½ç³»ã®æè¡ãå¿ç¨ããèªç¶è¨èªå¦çãææ¸è§£æã®ãµã¼ãã¹ãã主ã«æ³äººåãã«å±éãã¦ããä¼æ¥ã§ããè¨ç«èªä½ã¯2005å¹´ã¨ãã§ã«9å¹´ã»ã©çµã£ã¦ãã¾ãããã·ãªã¼ãºAã®ãã¡ã³ããåããã®ã¯2013å¹´ã«ãªã£ã¦ããã§ãããååãç®ã«ããããã«ãªã£ãã®ã¯æè¿ã«ãªã£ã¦ããã§ãã
Â
å®éã«ãããããªåçããã¢ã«å ¥ãã¦è©¦ãã¦ã¿ã¾ãããç¹ã«åç©ã¯ç²¾åº¦ãè¯ããç¬ã®å ´åç¬ç¨®ï¼"shiba"ãªã©ï¼ã¾ã§ã¿ã°ä»ãã§ããã¿ããã§ããä¸æ¹ãå¦ç¿ãã¼ã¿ã«åçãå¤ãã®ããã¢ãã¡ã®ãã£ã©ãã¤ã©ã¹ãã¯æ®ã©ã¿ã°ä»ãã§ãã¾ããã§ããã
dog: 0.993 animal: 0.948 shiba: 0.937 inu: 0.769 pic.twitter.com/f6TBeeMMwe
â é»ãã ã (@takeshi0406) July 17, 2014
ç¬ã®ã¿ã°ä»ãã詳細ãªã®ã¯ãªãï¼ pic.twitter.com/DKOjl0bj2n
â é»ãã ã (@takeshi0406) July 17, 2014
Â
ããã¦ããã®ã¾ã¾AlchemyAPIãå©ç¨ããtwitterã®botãä½ã£ã¦ã¿ã¾ãããtwitterãåç©é¢é£ã®ã¯ã¼ãæ¤ç´¢ãã¦ãç»åã®ãããã¤ã¼ããæ½åºãã¿ã°ä»ããã¦ãã¤ã¼ããã¾ãã
AlchemyAnimals (AlcAnimals) on Twitter
dog: 0.956893 animal: 0.622459 pic.twitter.com/xWvsCfVvfp
â AlchemyAnimals (@AlcAnimals) July 18, 2014
ã¢ã«ãã«ã¯"cat"ã¨"dog"ã®ä¸¡æ¹ã§ã¿ã°ä»ãããã¾ããã"alpaca"ã£ã¦ã¿ã°ã¯ç¨æããã¦ããªãã¿ããã§ãã
dog: 0.832018 cat: 0.668188 animal: 0.622459 pic.twitter.com/DkXJnJBmLn
â AlchemyAnimals (@AlcAnimals) July 18, 2014
Â
ä¸å¿ã³ã¼ããè¼ãã¦ããã¾ããAlchemyAPIã®Pythonã¢ã¸ã¥ã¼ã«ãå ¬å¼ã§ç¨æããã¦ãã¾ããã使ãæ¹ãããããããªãã£ãã®ã§ãã®ã¾ã¾APIã®URLãå©ãã¾ãããpython-twitterã®ä½¿ãæ¹ã¯ä¸ã®è¨äºãåèã«ãã¾ããã
python-twitterã®ä½¿ãæ¹(1) - å¿ããªãããã«ã¡ã¢ã£ã¨ã
#!/usr/bin/python
#coding:utf-8
import urllib
import json
import twitter
import secret
import random
api = twitter.Api(
   consumer_key = secret.twDict['consumer_key'],
   consumer_secret = secret.twDict['consumer_secret'],
   access_token_key = secret.twDict['access_token_key'],
   access_token_secret = secret.twDict['access_token_secret']
)
alchemykey = "**************" #APIKEYã®åå¾ãå¿ è¦
keywords = [u"animal",u"dog",u"cat",u"animals",u"zoo",
            u"dogs",u"fish",u"bird",u"monkey",u"sheep",u"space+cats",
            u"wildlife",u"ç«",u"alpaca",u"pet",u"animal+crazy",
            u"animal+cute",u"rare+animal",u"mountain+animal",u"national+geographic+animal",
            u"aquarium+animal",u"animal+africa",u"species+asia",u"species africa",u"desert+animal"]
random.shuffle(keywords)
keyword = keywords[0]
search = api.GetSearch(keyword,count=100)
random.shuffle(search)
for tw in search:
   if len(tw.media) == 0:
      print "no picture"
   else:
      url = tw.media[0]["url"]
      media_url = tw.media[0]["media_url"]
      break
endpoint = "http://access.alchemyapi.com/calls/url/URLGetRankedImageKeywords?apikey="
access_url = endpoint + alchemykey + "&url=" + media_url + "&outputMode=" + "json"
endpoint = "http://access.alchemyapi.com/calls/url/URLGetImage"
f = urllib.urlopen(access_url)
api_open = f.read()
f.close()
print api_open
api_open = json.loads(api_open)
tags = api_open["imageKeywords"]
tweet = ""
for tag in tags:
   print tag["text"], tag["score"]
   tweet = tweet + tag["text"] + ": " + tag["score"] + """
   """ #ãªããÂ¥nã§æ¹è¡ããã¨ã¨ã©ã¼
api.PostUpdate(tweet + url)