Slide 1

Slide 1 text

@meilitr Playing with Google ML APIs and websockets Meili Triantafyllidi, 2017

Slide 2

Slide 2 text

@meilitr What? Multilingual chat application with websockets

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

@meilitr Part I: Google ML APIs

Slide 5

Slide 5 text

@meilitr Motivation Google Developers Day reminded me ...

Slide 6

Slide 6 text

@meilitr 21 century

Slide 7

Slide 7 text

@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

Slide 8

Slide 8 text

@meilitr Google machine learning APIs

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

@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

Slide 13

Slide 13 text

@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

Slide 14

Slide 14 text

@meilitr Is it free to use?

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

@meilitr Integration

Slide 19

Slide 19 text

@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

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

@meilitr On hands on session Solve Tower of Babel problem

Slide 22

Slide 22 text

@meilitr Part II: websockets

Slide 23

Slide 23 text

@meilitr Motivation Last Pyladies talk by Thomas Iorns

Slide 24

Slide 24 text

@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

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

@meilitr HTTP vs websockets ● Walkie talkie vs Phone

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

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

Slide 30

Slide 30 text

@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

Slide 31

Slide 31 text

@meilitr Websocket usage status Browsers: 100%

Slide 32

Slide 32 text

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

Slide 33

Slide 33 text

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

Slide 34

Slide 34 text

@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

Slide 35

Slide 35 text

@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

Slide 36

Slide 36 text

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

Slide 37

Slide 37 text

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

Slide 38

Slide 38 text

@meilitr Thank you