Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Playing with google ML APIs and websockets

Playing with google ML APIs and websockets

Meili Triantafyllidi

November 21, 2017
Tweet

More Decks by Meili Triantafyllidi

Other Decks in Programming

Transcript

  1. @meilitr How? • Google Machine Learning APIs • Websockets •

    Chat application code walkthrough • Hands on session to add translation
  2. @meilitr 21 century • Do I need an umbrella today

    • Auto tag my photos (beach, birthday) • Survive in a country 6 years without speaking the language (translate emails, docs by photo) • … 60% of airbnb customers use translate (listing, comments
  3. @meilitr Google machine learning APIs • Vision API - https://cloud.google.com/vision/

    • Speech API - https://cloud.google.com/speech/ • Natural language API - https://cloud.google.com/natural-language/
  4. @meilitr Google machine learning APIs • Vision API - https://cloud.google.com/vision/

    • Speech API - https://cloud.google.com/speech/ • Natural language API - https://cloud.google.com/natural-language/ • Translate API
  5. @meilitr Google machine learning APIs • Vision API - https://cloud.google.com/vision/

    • Speech API - https://cloud.google.com/speech/ • Natural language API - https://cloud.google.com/natural-language/ • Translate API • Video Intelligence API
  6. @meilitr Is it free to use? • Almost all APIs

    have free tier https://cloud.google.com/free - Translate API, 1 billion character per month - Vision API, 1000 feature detection per month - Speech API, 1 hour per month • 300$ credit for 1 year (requires credit card) No, but ...
  7. @meilitr What is under the hood? Continuously improving already trained

    deep neural networks that solve the specific problem.
  8. @meilitr Tensorflow • Open source software library by Google behind

    most products • Create and train your own models
  9. @meilitr Integration ➔ Create google cloud account (credit card needed)

    ➔ Enable API to use ➔ Create API key or Service account depending of API to use ➔ Call API via HTTP or use python client Demo Translate API - https://console.cloud.google.com/home
  10. @meilitr Documentation - examples - Mostly full integration in google

    cloud is assumed - Authentication can be tricky - API_KEY are the simplest but the docs hard to spot - Language code examples do not use API KEY :(
  11. @meilitr Demo • 130 lines Python 100 lines Javascript 20

    HTML 50 css • Minimal setup → Real time chat and shared drawing https://github.com/mesilliac/multitude
  12. @meilitr What is websocket? WebSocket is a computer communications protocol,

    providing full-duplex communication channels over a single TCP connection. The WebSocket protocol was standardized in 2011.
  13. @meilitr HTTP vs websockets • Walkie talkie vs Phone •

    Websocket can implement HTTP • Websocket less overhead
  14. @meilitr HTTP vs websockets • Walkie talkie vs Phone •

    Websocket can implement HTTP • Websocket less overhead • Websocket persistent, HTTP 1.1 stateless (HTTP 2 still early stage)
  15. @meilitr HTTP vs websockets • Walkie talkie vs Phone •

    Websocket can implement HTTP • Websocket less overhead • Websocket persistent, HTTP 1.1 stateless (HTTP 2 still early stage) • Server to client communication
  16. @meilitr Websocket usage status Browsers: 100% Mainly used for real

    time applications (online games, chats, financing, etc)
  17. @meilitr Websocket usage status Browsers: 100% Mainly used for real

    time applications (online games, chats, financing, etc) Why limited to real time? • HTTP has plenty of tooling already there (caching, load balancing, etc.) • It is not so easy (state handling, faulty connections, scaling) → Pubsub as a service (eg. Pusher/PubNub)
  18. @meilitr Python frameworks support • WSGI only compatible frameworks (Django,

    Flask, bottle, Pyramid, etc.) DO not support websockets • Event loop frameworks (tornado, twisted, frameworks based on asyncio) • django-channels with ASGI
  19. @meilitr Websockets takeaways • Server initiated communication → Real time

    • Not as simple as it looks • Not compatible with many existing tools → Use with caution for production
  20. @meilitr Questions - Break - Coding time https://github.com/mei-li/multiling-chat/ API KEY:

    AIzaSyC0LOHlJuqsHrYWoIxhbzNrUnrlFDv6TeI Pray to have network