<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ryan Paul on Medium]]></title>
        <description><![CDATA[Stories by Ryan Paul on Medium]]></description>
        <link>https://medium.com/@ryanpaul2024?source=rss-1ba2f4ab1eb7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*_EToHrGl1hXae35jEBaAQg.png</url>
            <title>Stories by Ryan Paul on Medium</title>
            <link>https://medium.com/@ryanpaul2024?source=rss-1ba2f4ab1eb7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 14:32:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ryanpaul2024/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Build an Image Classification IOS application]]></title>
            <link>https://medium.com/@ryanpaul2024/build-an-image-classification-ios-application-282d65c4c2b3?source=rss-1ba2f4ab1eb7------2</link>
            <guid isPermaLink="false">https://medium.com/p/282d65c4c2b3</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Ryan Paul]]></dc:creator>
            <pubDate>Thu, 24 Mar 2022 02:27:10 GMT</pubDate>
            <atom:updated>2022-03-24T02:36:21.904Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4JBBA_TcNYnnGde3UnIq-w.jpeg" /></figure><p>Hey there 👋</p><p>This article is directed towards the real-life application of machine learning, specifically app development. Since I have an IOS device, I will be running my models using Xcode.</p><p>This article will not be covering the development of a machine learning model, just the use cases of that model.</p><p>If you would like to tutorial on how to build a machine learning model, then click this link to get a step-by-step tutorial on that process.</p><p>For the purpose of this article, you will have to have your iPhone and MacBook updated to the latest versions, and Xcode currently downloaded onto your computer.</p><p>With that being said, let&#39;s get started!</p><h4><strong>Formatting the model</strong></h4><p>In ML development, there are different formats for each use case. For example, implementing a machine learning model on a website requires a .js format. For app development, .tflite is the acceptable version.</p><p>For my image classification model that detects a fire, I ran the following code segments in order to convert my model to tflite:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/60813c8099afd1ca9733ccc49f224683/href">https://medium.com/media/60813c8099afd1ca9733ccc49f224683/href</a></iframe><p>For more documentation on converting to tflite, check out the following <a href="https://www.tensorflow.org/lite/convert">link</a>.</p><p>I believe the following code segment is a universal way to convert your model to tflite. It’s always pretty tricky to determine whether this segment will work for you, so I would recommend using my notebook and just running everything along with this tutorial.</p><p>Once you have the tflite file, you will have to create a label.txt file in order to get the app to run.</p><p>This can be done by using the .class_indices Keras class in order to make the text file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9cea1fc6ad2d0cfb66c6071f59b79403/href">https://medium.com/media/9cea1fc6ad2d0cfb66c6071f59b79403/href</a></iframe><p>the variable train_generator is the location of my training data, and my dataset was configured for iOS development(ie. the dataset was very clearly formatted).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F6lanQqmttETv_7WKMA3pw.png" /></figure><p>Although it isn&#39;t necessary, it’s very helpful.</p><p>Once you have completed all of these steps, all you have to do is download the model and label files.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b0870a920e50a15e7168f15c82468298/href">https://medium.com/media/b0870a920e50a15e7168f15c82468298/href</a></iframe><p>Once the files are downloaded, the first step is complete</p><p><strong>Installing the Image Classification Packages.</strong></p><p>Navigate to this <a href="https://github.com/tensorflow/examples/tree/master/lite/examples/image_classification/ios"><em>link</em></a> and keep it in a separate tab because it’s very important</p><p>This next section is directly from that website since those are the official dependencies for app development. If you have Cocoapods already downloaded then all you have to do is clone the repo and open the xcode file.</p><p>Here are the terminal code segments.</p><p>xcode-select — install</p><p>sudo gem install cocoapods</p><p>git clone <a href="https://github.com/tensorflow/examples.git">https://github.com/tensorflow/examples.git</a></p><p>cd examples/lite/examples/image_classification/ios &amp;&amp; pod install</p><p>open ImageClassification.xcworkspace</p><p><strong>Editing the Xcode Template</strong></p><p>Once you have downloaded the dependencies and opened the xcode file, you should be directed towards the official tensorflow template for image classification.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fGD5gPHqUFxKrsXSM-xiiw.png" /></figure><p>Navigate to the Model tab, and you will see that there are label and model files already there. Right-click on each of them and move them to trash and empty the trash. Once you did that, drag your model and labels to that folder.</p><p>You will be prompted by a message like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*1jhuDkat8sY9zIWRWaq4uA.png" /></figure><p>Select ImageClassifcation and click finish. Repeat the process for the labels.</p><p>Add the model and labs exactly the way I did above and you are almost done with the application.</p><p>After that you have to put in your Apple Development Certificate and set the bundler to something different. <a href="https://www.youtube.com/watch?v=oK1b-H6rh08&amp;ab_channel=JumpStartWithiOS">Here is a video tutorial if you need help with that</a></p><p>All you have to do besides that is plug your iPhone in and run the application.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fy3trIf4gD9A%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dy3trIf4gD9A&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fy3trIf4gD9A%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/e94e8270fa05877750b4f82553e7881b/href">https://medium.com/media/e94e8270fa05877750b4f82553e7881b/href</a></iframe><p>There is a video of the end result of the models. It looks pretty solid.</p><p><strong>Congratulations</strong>! You have created an ios application that utilizes machine learning. If you have any questions, shoot me a message on <a href="https://www.linkedin.com/in/ryanpaul2024/">Linkedin</a> or email me at ryanpaul2024@gmail.com!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=282d65c4c2b3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learn & Create a Neural Network from Scratch using Tensorflow]]></title>
            <link>https://medium.com/@ryanpaul2024/learn-create-a-neural-network-from-scratch-using-tensorflow-6a98206ed733?source=rss-1ba2f4ab1eb7------2</link>
            <guid isPermaLink="false">https://medium.com/p/6a98206ed733</guid>
            <category><![CDATA[step-by-step-tutorials]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[step-by-step]]></category>
            <category><![CDATA[convolutional-network]]></category>
            <dc:creator><![CDATA[Ryan Paul]]></dc:creator>
            <pubDate>Wed, 23 Mar 2022 17:42:08 GMT</pubDate>
            <atom:updated>2022-03-23T17:42:08.079Z</atom:updated>
            <content:encoded><![CDATA[<p>Machine Learning isn&#39;t as hard as everyone makes it. Sure, at the heart of this field is a wide array of advanced mathematical concepts, but for beginners, you don&#39;t need to know a lot of the concepts to get started.</p><p>The artificial intelligence industry is <strong>booming,</strong> and you can create your model from scratch in <strong>record-breaking time</strong>. You&#39;ve seen everyone do amazing things in machine learning, building models, changing the world, and you want to know how you can get in this field. Well, you&#39;ve come to the right place.<strong> This article serves as a beginner-friendly guide for anyone interested in delving into neural networks, specifically image classifiers.</strong></p><p>First, to truly understand what we&#39;re going to do during this article, it might be best to understand what a neural network is.</p><p>A neural network is essentially a subset of machine learning and is at the heart of all deep learning algorithms. It takes data and finds a pattern interlinking from that set data and uses that in future cases.</p><p>For example, let&#39;s say I am creating a classifier that detects whether an image is a cat or a dog. The computer will look at thousands of different images of dogs and thousands of different images of cats to look for similarities in those subsets of cats and dogs. When the user makes the neural network look at an image of a dog or a cat, it will use those similarities that it found before, and it will classify the image depending on the similarities matching.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kth435k1b3XkyBmKYVIh2Q.jpeg" /></figure><p>That is what we&#39;re going to be doing in this article; we&#39;re going to be making a detector that can figure out whether there is a fire or no fire in a specific image. So let&#39;s get started.</p><p>For this article, we will be using <strong>google collaboratory</strong> in order to create and design our machine learning models. Google Colab is <strong>an excellent tool for deep learning tasks</strong>. It is a hosted Jupyter notebook that requires no setup and has an excellent free version, which gives free access to Google computing resources such as GPUs and TPUs[1]. The only thing you need for this article is a google account.</p><h3>A Step by Step Tutorial on how to build a Convolutional Neural Network that can detect fire</h3><p>Step 1- Download the <a href="https://www.kaggle.com/datasets/phylake1337/fire-dataset"><strong>dataset</strong></a>. We are going to be using this dataset to train our model.</p><p>Step 2- Go to <a href="http://drive.google.com/">Google Drive</a> and upload your folder to your drive. This is helpful because it makes the process of making the data directories easier and in less time.</p><p>Step 3- go to <a href="https://colab.research.google.com/">https://colab.research.google.com/</a>, and click &quot;Create New Notebook.&quot; This will be your workspace for the remainder of this tutorial.</p><p>On the left side, you should see a <strong>folder icon</strong>. When you press that, you will be prompted with the folders and data downloaded as well as 3 small buttons. Click the rightmost button, which mounts your drive to this notebook.</p><p>A Google authorization popup should come up, and you should sign in to the account where you had the dataset downloaded to the cloud.</p><p>As soon as that&#39;s done, you will see your files, and you have to navigate to the fire dataset. Once you have done that, right-click the folder and press show content path. You will want to copy that path to your clipboard.</p><p>Step 4: <strong>Importing the necessary dependencies</strong></p><p>Generally, the first code cell is typically used to load in packages necessary for the construction of the model.</p><p>Since we are using <a href="https://www.tensorflow.org/">TensorFlow</a> and <a href="https://keras.io/">Keras</a> to build this model, we will import those dependencies and <a href="https://numpy.org/">NumPy</a>, <a href="https://docs.python.org/3/library/glob.html">glob</a>, and <a href="https://docs.python.org/3/library/os.html">os</a>. A more thorough explanation of those dependencies can be found just by clicking the dependencies above since the explanation would take too long for the purpose of this tutorial.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d107322a8e74feee2252f14d61867e9d/href">https://medium.com/media/d107322a8e74feee2252f14d61867e9d/href</a></iframe><p>Step 5: <strong>Set up your test and training data</strong></p><p>This part is crucial, and there is a reason why this section needs some attention to detail. You don&#39;t want to be in a situation where you can&#39;t get your data to be run, so much emphasis is given to this specific section.</p><p>This is where we use the content base and set that to a variable called base_dir. After that, I resized everything to the format typically used in general and in ios development(Article coming soon). I utilized an 80/20 split between the training and test data, putting everything in different variable subsets.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6dac5c8ff521d96eb7165a67305347ba/href">https://medium.com/media/6dac5c8ff521d96eb7165a67305347ba/href</a></iframe><p>Step 6: <strong>Making sure everything is running correctly</strong></p><p>This is the part where we make sure everything was processed correctly. The following code segments are run to make sure the resizing worked correctly, and there are only two labels necessary for binary classification.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/780f5649e95a5eb69b5323bed4f89a71/href">https://medium.com/media/780f5649e95a5eb69b5323bed4f89a71/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1b390f48c073ab4dd50a0d562cac22dc/href">https://medium.com/media/1b390f48c073ab4dd50a0d562cac22dc/href</a></iframe><p>Step 7:<strong> Installing MobileNetV2 **Optional but very helpful**</strong></p><p>This step isn&#39;t important for the running of the model, but more so on the accuracy the model will produce. Often, we aren&#39;t able to get the results we desire, and we need a way to make our model better without having to run the model thousands of times. There is a method called<strong> transfer learning</strong> which solves this issue.</p><p><strong>Transfer learning</strong> is a research problem in machine learning that focuses on storing knowledge gained while solving one problem and applying it to a different but related problem. For example, knowledge gained while learning to recognize cars could apply when trying to recognize trucks[2].</p><p>MobileNet-v2 is <strong>a convolutional neural network that is 53 layers deep</strong>. You can load a pre-trained version of the network trained on more than a million images from the ImageNet database. The pretrained network can classify images into 1000 object categories, such as keyboard, mouse, pencil, and many animals[3].</p><p>We can piggyback on these models, which can help our model become so much stronger. If you are training your model on something that is very well known, like fire, transfer learning makes your model very strong. In just a few lines of code, you make your model 20 times stronger!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5659263c9953b6254950b3530bd471c7/href">https://medium.com/media/5659263c9953b6254950b3530bd471c7/href</a></iframe><p>Step 8: <strong>Building the Model Architecture and running the model.</strong></p><p>Since we are building a convolutional neural network, we will add a convolution layer and a dense layer. This is one of the simpler neural networks and only requires ten lines to build. We have four layers in total.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/23b07531c644599b0cfdd59820eb8eae/href">https://medium.com/media/23b07531c644599b0cfdd59820eb8eae/href</a></iframe><p>Once the architecture is built, the code is compiled, and the code is optimized through adam, which is one of the most reliable optimizers and is generally used for most of these types of models.</p><p>Since this network has only two labels, the loss metric is binary cross-entropy. For models with more than two labels, categorial cross-entropy is better. In terms of activation functions, the general notion is that sigmoid is better off for binary classes, and softmax is better off for three or more label classes(so the vast majority).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1ef579adfcfedd8c31ab193b362a08c1/href">https://medium.com/media/1ef579adfcfedd8c31ab193b362a08c1/href</a></iframe><p>Finally, we train the model. We pass the training and test generators, and the model starts running.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6d6d6f649cca5809210bedb8b025fd75/href">https://medium.com/media/6d6d6f649cca5809210bedb8b025fd75/href</a></iframe><p>This step typically takes longer than 25–30 minutes.</p><p>___________________________________________________________________</p><h3>Final Thoughts + Links</h3><p>After the model is run, you have made your very own Neural Network that is able to detect fire. <strong>Congratulations!</strong> If you did step 7, your model would be <strong>phenomenal</strong>. I really appreciate you taking the time to read my article. In the coming days, I will be releasing an article on the real-world application with machine learning and how it works. I really wish I was given a step-by-step tutorial when I started my machine learning journey, and my goal is to convey all of the possible methods in these articles to you. Thank you so much for your time, and have a wonderful rest of your day!</p><p><a href="https://colab.research.google.com/drive/1DfqcIpXC7T9qHFBH6MeyQ-yj48pZRh4g?usp=sharing">Finished notebook link</a></p><p>Above is the finished colab link. You can see all of the code and the desired result. If you have a question, shoot me a message on <a href="https://www.linkedin.com/in/ryanpaul2024/">Linkedin</a> or email me at ryanpaul2024@gmail.com!</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><p>[1] <a href="https://towardsdatascience.com/4-reasons-why-you-should-use-google-colab-for-your-next-project-b0c4aaad39ed">https://towardsdatascience.com/4-reasons-why-you-should-use-google-colab-for-your-next-project-b0c4aaad39ed</a></p><p>[2] <a href="https://towardsdatascience.com/what-is-transfer-learning-8b1a0fa42b4">https://towardsdatascience.com/what-is-transfer-learning-8b1a0fa42b4</a></p><p>[3] <a href="https://towardsdatascience.com/classify-any-object-using-pre-trained-cnn-model-77437d61e05f">https://towardsdatascience.com/classify-any-object-using-pre-trained-cnn-model-77437d61e05f</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a98206ed733" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>