Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

image-matchの紹介

451 views

Published on

大阪Pythonユーザの集まり 2016/04 のLT発表資料です
2016.04.15
image-matchの紹介

Published in: Technology
  • Be the first to comment

  • Be the first to like this

image-matchの紹介

  1. 1. image-match osakapy 2016.04 15 April 2016 Hideo Hattori Software Enginner, KLab Inc. (Osaka)
  2. 2. whoami Hideo Hattori (github(https://github.com/hhatto)) Python / Go / C / Rust / Zsh My Python Projects autopep8(https://github.com/hhatto/autopep8), pgmagick(https://github.com/hhatto/pgmagick/), poyonga(https://github.com/hhatto/poyonga), genzshcomp(https://bitbucket.org/hhatto/genzshcomp)...
  3. 3. image-match
  4. 4. image-match
  5. 5. image-match image-match(https://github.com/ascribe/image-match) Python2.x only libpuzzle(https://www.pureftpd.org/project/libpuzzle) Perceptual Hash
  6. 6. image-match image-match $ brew install py2cairo cairo elasticsearch $ pip install numpy scipy image_match
  7. 7. 2 from image_match.goldberg import ImageSignature gis = ImageSignature() a = gis.generate_signature('a.jpg') b = gis.generate_signature('b.jpg') c = gis.generate_signature('c.jpg') print("a-b: %f" % gis.normalized_distance(a, b)) print("a-c: %f" % gis.normalized_distance(a, c)) $ python distance.py a-b: 0.220952 a-c: 0.684463 =
  8. 8. with Elasticsearch Elasticsearch(https://www.elastic.co/products/elasticsearch) from elasticsearch import Elasticsearch from image_match.elasticsearch_driver import SignatureES es = Elasticsearch() ses = SignatureES(es)
  9. 9. es = Elasticsearch() ses = SignatureES(es, size=10, distance_cutoff=0.9) ses.add_image(filename) ses.search_image(filename) {'path': u'image/image_08179.jpg', 'score': 56.06757, 'dist': 0.0, 'id': u'AVQQyhUEJXUmYMIAjxKA'} {'path': u'image/image_01623.jpg', 'score': 0.2764881, 'dist': 0.55480701966252521, 'id': u'AVQQxa3_JX {'path': u'image/image_04659.jpg', 'score': 0.33701482, 'dist': 0.56801020853288964, 'id': u'AVQQx7GOJ
  10. 10. otama image-match otama(https://github.com/nagadomi/otama) otamapy(https://github.com/hhatto/otamapy)otama Python http:// owers.libotama.so/ (8189 )(http://www.robots.ox.ac.uk/~vgg/data/ owers/102/)
  11. 11. $ brew tap hhatto/otama $ brew install otama $ pip install --upgrade otamapy
  12. 12. image-match from elasticsearch import Elasticsearch from image_match.elasticsearch_driver import SignatureES es = Elasticsearch() ses = SignatureES(es) for filename in files: ses.add_image(filename)
  13. 13. image-match es = Elasticsearch() ses = SignatureES(es, size=10, distance_cutoff=0.9) #for o in ses.search_image(TARGET_FILE, all_orientations=True): for o in ses.search_image(TARGET_FILE): print(o)
  14. 14. otama from otama import Otama db = Otama.open(config) db.create_database() for filename in files: key = db.insert(filename) keystore[key] = filename db.pull() db.close()
  15. 15. otama db = Otama(config) for result in db.search(10, TARGET_FILE): key = result['id'] print("sim=%.3f, file=%s" % (result['similarity'], keystore[key])) print(db.exists(key))
  16. 16. otama otama ( time )
  17. 17. Thank you Hideo Hattori Software Enginner, KLab Inc. (Osaka) @hhatto(http://twitter.com/hhatto)

×