17
Getting started with indico APIs [Python] Tutorials: 1) Sorting images based on similarity 2) Creating a custom RSS feed

Getting started with indico APIs [Python]

Embed Size (px)

Citation preview

Page 1: Getting started with indico APIs [Python]

Getting started with indico APIs [Python]

Tutorials: 1)  Sorting images based on similarity

2) Creating a custom RSS feed

Page 2: Getting started with indico APIs [Python]

This tutorial

Page 3: Getting started with indico APIs [Python]

Getting Started

https://github.com/IndicoDataSolutions!

pip install indicoio npm install indico.io gem install indico

Page 4: Getting started with indico APIs [Python]

>>> from indicoio import image_features >>> image_features (<image_array>) [a1,!a2,!a3,!…]!

Image Features

Page 5: Getting started with indico APIs [Python]

Use case – Image Search

Page 6: Getting started with indico APIs [Python]

Steps to image search

1. Get images 2. Store image features 3. Distance Metrics 4. Querying

Page 7: Getting started with indico APIs [Python]

Example Code

https://github.com/IndicoDataSolutions/

ImageSimilarity

Page 8: Getting started with indico APIs [Python]

Get images

Page 9: Getting started with indico APIs [Python]

Store image features

{url: image_features}

Import redis Import indicoio redis_server = redis.StrictRedis()

redis_server .set(url, indicoio.image_features(<array>))

Page 10: Getting started with indico APIs [Python]

Distance metrics

Page 11: Getting started with indico APIs [Python]

Querying

from scipy.spatial.distance import cosine a = clicked_image

sorted([cosine(a, b) for b in all_images])

Page 12: Getting started with indico APIs [Python]

Steps to custom reddit

1. Access RSS feed 2. Categorization and thresholding 3. Basic frontend

Page 13: Getting started with indico APIs [Python]

Example Code

https://github.com/IndicoDataSolutions/

RSSCustomization

Page 14: Getting started with indico APIs [Python]

Accessing RSS feed

import feedparser from multiprocessing.pool import ThreadPool

feed = ‘http://www.reddit.com/.rss’ pool = ThreadPool(16) entries = feedparser.parse(feed)[‘entries’]

entries = pool.map(parse, entries)

Page 15: Getting started with indico APIs [Python]

Categorization and thresholding

from indicoio import text_tags def parse(entry):

return { ‘title’: entry[‘title’], ‘link’: entry[‘link’] ‘tag’: likely_tag(text_tags(entry[‘title’]))

}

Page 16: Getting started with indico APIs [Python]

Basic frontend

https://github.com/IndicoDataSolutions/

RSSCustomization

Page 17: Getting started with indico APIs [Python]

stay in the loop ! indico.io