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
    Playing with Google ML APIs
    and websockets
    Meili Triantafyllidi, 2017

    View full-size slide

  2. @meilitr
    What?
    Multilingual chat application with websockets

    View full-size slide

  3. @meilitr
    How?
    ● Google Machine Learning
    APIs
    ● Websockets
    ● Chat application code
    walkthrough
    ● Hands on session to add
    translation

    View full-size slide

  4. @meilitr
    Part I: Google ML APIs

    View full-size slide

  5. @meilitr
    Motivation Google Developers Day reminded
    me ...

    View full-size slide

  6. @meilitr
    21 century

    View full-size slide

  7. @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

    View full-size slide

  8. @meilitr
    Google machine learning APIs

    View full-size slide

  9. @meilitr
    Google machine learning APIs
    ● Vision API - https://cloud.google.com/vision/

    View full-size slide

  10. @meilitr
    Google machine learning APIs
    ● Vision API - https://cloud.google.com/vision/
    ● Speech API - https://cloud.google.com/speech/

    View full-size slide

  11. @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/

    View full-size slide

  12. @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

    View full-size slide

  13. @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

    View full-size slide

  14. @meilitr
    Is it free to use?

    View full-size slide

  15. @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 ...

    View full-size slide

  16. @meilitr
    What is under the
    hood? Continuously improving already
    trained deep neural networks
    that solve the specific problem.

    View full-size slide

  17. @meilitr
    Tensorflow
    ● Open source software library by Google behind most products
    ● Create and train your own models

    View full-size slide

  18. @meilitr
    Integration

    View full-size slide

  19. @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

    View full-size slide

  20. @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 :(

    View full-size slide

  21. @meilitr
    On hands on session Solve Tower of Babel problem

    View full-size slide

  22. @meilitr
    Part II: websockets

    View full-size slide

  23. @meilitr
    Motivation Last Pyladies talk by Thomas Iorns

    View full-size slide

  24. @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

    View full-size slide

  25. @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.

    View full-size slide

  26. @meilitr
    HTTP vs websockets
    ● Walkie talkie vs Phone

    View full-size slide

  27. @meilitr
    HTTP vs websockets
    ● Walkie talkie vs Phone
    ● Websocket can implement HTTP

    View full-size slide

  28. @meilitr
    HTTP vs websockets
    ● Walkie talkie vs Phone
    ● Websocket can implement HTTP
    ● Websocket less overhead

    View full-size slide

  29. @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)

    View full-size slide

  30. @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

    View full-size slide

  31. @meilitr
    Websocket usage status
    Browsers: 100%

    View full-size slide

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

    View full-size slide

  33. @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)

    View full-size slide

  34. @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

    View full-size slide

  35. @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

    View full-size slide

  36. @meilitr
    Demo time
    Our stripped out version
    ● https://github.com/mei-li/multiling-chat/
    Ask questions if it is not clear

    View full-size slide

  37. @meilitr
    Questions - Break - Coding time
    https://github.com/mei-li/multiling-chat/
    API KEY: AIzaSyC0LOHlJuqsHrYWoIxhbzNrUnrlFDv6TeI
    Pray to have network

    View full-size slide

  38. @meilitr
    Thank you

    View full-size slide