 Okay, so hi guys and girls. Today let's talk about AI for non-PhDs and I'm going to show you how to add AI superpowers into your app in less than 30 minutes. Firstly, a little bit about myself. My name is Akshita. I'm a full-stack engineer at Rakuten Viki and I come from a non-traditional background because I learned how to code by binging on Coursera, Udacity and Free Code Camp. In a previous life I was an architect for buildings and then I spent a few years in research at NUS and about six months back I joined Viki where I work on Rakuten Sports and Sumpi and that's what helps me pay for my food and alcohol these days. So why should you care about AI? Well, apart from the fact that it makes you look super cool, it's the possibilities and if you just look around us, this over here is a Koala version of me built with AI on an iPhone. That's colon cancer detection also powered by AI and that's what playlist you have. That's also AI and tech shift. AI now is accessible to everyone. Previously it was a domain that was majorly controlled by machine learning PhDs but now with companies pushing their tools, the open source work coming out, it's become very easy for developers like you and me to actually integrate AI into our apps very seamlessly and easily. So my journey with AI started a few months back when I did this AI nanodegree and I built all these cool algorithms to those sign language recognition, dog breed predictions, dog price prediction, text generation, speech translation etc and I was super happy with myself but all of these algorithms were just on my laptop, they were on my computer and I wanted to send them out into the real world and I was stuck because I didn't know how to. So I started looking around and one way was that I take my algorithms, put it on a server and every time I want an answer, I connect to my server and get it. It was a good option but I had issues. So this super cute baby that you see here, she's my niece, she's three, she's super smart and my goal was to convince her that I'm super smart too. It's my whatever and my niece loves dogs. So I thought okay why not use my dog breed classifier to make an app and impress her. So the way it worked in my head was that I would take my app, point it at a dog and my app would immediately tell me what the dog was. Turns out these dogs, they have a restless dog syndrome and it would never stand still enough for me to actually take a picture, send it to the server and then wait for the answer to come back. So my issue was latency. Next issue, privacy and even though dogs aren't really worried about their privacy yet, I thought people might be, if I ever tried this on people, they might have an objection to me sending pictures of them onto a server without, as I've learned that explicit consent. Issue number three, so suppose I go with my niece to Pulao Oban, which is one of the few places in Singapore that you actually find stray dogs and also one of the few places where there are points of zero internet connectivity and I take my app, I point it at a dog, no answer because no internet, hence no server and Caitlin is not impressed. So my issue was accessibility and issue number four, cost by far my main reason because I'm a poor developer. So I found this, that it's actually possible for you to take your entire AI ML algorithm and put it on your device itself without the need for a server. And I'm just going to show you how. So the process for this across web and mobile remains pretty much the same. You take your algorithm, you freeze it, then you put it through a converter that converts it into a file format that your device understands. Then you add that converted file format as an asset into the source code for your app, you add a library that understands that asset. And yeah, you have a prediction. How do I do this on the web? Okay, I forgot to scroll through these slides. So how do I do this on the web? I used a library, which is a JavaScript library that allows you to deploy these AI algorithms on the browser. And step one was converting my algorithm. I had this algorithm that took a dog image in gave me or gave me the name of the dog. I put it through a tensorflow JS converter, which is a command line utility. And then I got a file format that my browser would understand, which some of you might be familiar with is a JSON file. Step two, load the algorithm. So I linked my tensorflow JS library to my app. And then using the functions that it gave me, I loaded the model or JSON that that generated. Step number three, pre processing. So the dog image needed to be tweaked in certain ways before I could put it into my algorithm. So I had to define a few JavaScript functions to do that. And step four, predict. So I used functions again that the tensorflow JS library provided me and I had my prediction. And yay, this worked. That's that's my dog reclassifier hosted as a web app. And as you can see, it's critically predicting that this cute puppy is a pomegranate. Of course, this was not as straightforward as it as I made it sound. And some of the roadblocks that I faced was that this conversion tool, any tool that you're using in the space might not be as robust because it's being developed very actively. These are new. So while I was converting to my model of JSON, I actually found a bug in the converter which caused my JSON to be ill formed. So I had to go in and manually corrected to get my thing working. And my advice for this would be stay in touch with the community, go to Stack Overflow, track their GitHub repos. And it's good to go through the issues they might have if you find any new ones report them. Yeah. And then the second problem was huge file sizes. So because I was using a custom algorithm that I made, when I converted this into a model of JSON file, it was almost 100 MBs in size, which was probably way off the optimum limit for loading something on the web. But then they were happy takeaways that it was super quick to prototype with this. And here's a link to a playground with TensorFlow.js. It's a great place to get started and get a feel of the ecosystem if you want to. Coming on to mobile. Now I did this only for Android, because I'm not rich enough to own an iPhone yet. And I did this using TensorFlow Lite. So the steps were pretty much the same. I took my algorithm put it through another converter called TF Lite converter used the Python API to do that. And I came out with a file format called TF Lite. I took this file, put it in my source code, linked the TensorFlow Lite library in my Android cradle file. And step three was to steal from TensorFlow examples. Turns out that on the GitHub repo, they have fully formed Android examples to do these. And all I had to do was go there, pick up their Android example, replace their model with mine. And this worked too. So as you can see over here, my phone, this is a recording of my phone pointing at another phone. And it's looking for a portal. And my app knows it's a portal. And now another portal. And now it's going to a Pomeranian and my knows it's a Pomeranian. So what did I learn from this? I learned that Android debugging for this can be slightly hard. Because suppose you know how your model is built to a certain extent because in case it's not able to load the model, it might not give you very clear answers about why. Then the second problem I faced was linking the correct Android SDK and NDK version of course, that was more my fault because I did not read the docs properly. And the third one is an important point. Because there are two kinds of TF Lite files that you can generate, which is a quantized file and an unquantized file. Now the quantized file would be lighter, lesser in size and faster, but it comes at an accuracy cost. So if you're going to do this, you probably want to take out their accuracy tool which is hosted on the TensorFlow website to make sure that your accuracy hasn't been compromised above a certain threshold. Happy takeaways was by far the Android examples that was hosted on the GitHub repo. And here's a link to my GitHub repo, which has all these templates and the code for the dog breed classifier and a few other resources. I still don't have an iOS or react native templates. So if any of you are interested, happy to receive a PR. If you want to get in touch, questions, collaborations, I'm available here. And this is Divya. She's a recruiter. And and this is how happy she gets every time she receives an application. So if you want to see this expression on her face, please read out. Thank you.