<?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 Lucas Meneghesso Faria on Medium]]></title>
        <description><![CDATA[Stories by Lucas Meneghesso Faria on Medium]]></description>
        <link>https://medium.com/@lucas.meneghesso.faria?source=rss-1e3ed99e443a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ha6Y8IsiQwZNjco9l76-HA.jpeg</url>
            <title>Stories by Lucas Meneghesso Faria on Medium</title>
            <link>https://medium.com/@lucas.meneghesso.faria?source=rss-1e3ed99e443a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 17:17:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lucas.meneghesso.faria/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[Image Classification made easy]]></title>
            <link>https://medium.com/@lucas.meneghesso.faria/image-classification-made-easy-856fb6c422e9?source=rss-1e3ed99e443a------2</link>
            <guid isPermaLink="false">https://medium.com/p/856fb6c422e9</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[convolutional-neural-net]]></category>
            <dc:creator><![CDATA[Lucas Meneghesso Faria]]></dc:creator>
            <pubDate>Sat, 25 Dec 2021 23:23:20 GMT</pubDate>
            <atom:updated>2021-12-25T23:23:20.650Z</atom:updated>
            <content:encoded><![CDATA[<p>Image classification with <strong><em>Transfer learning</em></strong> + <strong><em>ConvNets + Python</em></strong>. The code is published in the <a href="https://github.com/lucasmfaria/image_classifier"><strong><em>Github repo</em></strong></a><strong><em> </em></strong><a href="https://github.com/lucasmfaria/image_classifier">https://github.com/lucasmfaria/image_classifier</a></p><p>Hi everyone. We are going to train custom image classification models using <strong><em>transfer learning </em></strong>technique and <strong><em>ConvNets </em></strong>(Convolutional Neural Nets).</p><p>First of all you should clone the repo from Github. After that we can start working:</p><ul><li>Prepare your python environment (tested with <strong>python 3.9 so far</strong>). Run:</li></ul><pre>pip install -r requirements.txt</pre><ul><li>Move your image dataset to the “<strong><em>data/dataset</em></strong>” directory. Follow the example:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/573/1*5CkEzVNFhP5qNoN6PB-OHA.png" /><figcaption>As you can see, the directories names are the class names (labels). This is a binary classification example, but you can add as many number of classes you want (as long as you have enough data, of course)</figcaption></figure><ul><li>Use “<strong>create_splits.py</strong>” to create the train, test and validation splits. Example with default parameters:</li></ul><pre>python ./scripts/create_splits.py</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qh2IDEm0r1DRgUoeE8M9ng.png" /><figcaption>You can play with the parameters if needed. You can check the default values in Github.</figcaption></figure><p>Note that there is a parameter for undersampling. So you don’t need to under sample manually before running the script. It is passed to the RandomUnderSampler class within imblearn library. Check it’s documentation for more information: <a href="https://imbalanced-learn.org/stable/references/generated/imblearn.under_sampling.RandomUnderSampler.html">https://imbalanced-learn.org/stable/references/generated/imblearn.under_sampling.RandomUnderSampler.html</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hzMFSkTyJz3ko4mBHiFSug.png" /><figcaption>You should see an output like this.</figcaption></figure><ul><li>Use “<strong>train.py</strong>” to train your neural network.</li></ul><pre>python ./scripts/train.py</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ws2sL_K730UVid0sxDOj8w.png" /><figcaption>You can check the default values in Github.</figcaption></figure><p>You’ll probably need to change some parameters here, depending on the complexity of your dataset and its labels. Some important ones are “<strong>batch_size</strong>” (depends on available memory), “<strong>base_epochs</strong>” (number of epochs during the first stage — frozen <strong>VGG16</strong> model), “<strong>fine_tuning_epochs</strong>” (number of epochs during the second stage — unfronzen <strong>VGG16 </strong>model).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GejAl-xedfsp3UP9iPGnyQ.png" /><figcaption>Training output</figcaption></figure><ul><li>Use “<strong>test.py</strong>” to evaluate your final model.</li></ul><pre>python ./scripts/test.py</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mq9HIp7OPTB4Gnpn2LSzdg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*emRFw0SjwihatgHGOZgXkg.png" /><figcaption>Test statistics output</figcaption></figure><ul><li>Use “<strong>save_last_train.py</strong>” if you liked the tested model and want to save it on “saved_models” directory.</li></ul><pre>python ./scripts/save_last_train.py</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*LI1vQ_ooOYLbpxSJbS6rbw.png" /><figcaption>Directory structure after saving</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*jLElds8eItoTxLHBUmXmkw.png" /><figcaption>Saved model weights with statistics results (results.txt)</figcaption></figure><ul><li>Use “<strong>delete_last_train.py</strong>” to delete the trained model from the “checkpoints” and “logs” directories.</li></ul><pre>python ./scripts/delete_last_train.py</pre><p>You can also use the provided <strong>jupyter notebook</strong> for visual interface with each code cell.</p><h3><strong>Future work</strong></h3><p>TODOs:</p><ul><li>User interface</li><li>Create <strong>API </strong>for model serving/deploy</li><li>Centralize application configuration using <strong>dynaconf </strong>library</li><li>Save “<strong>class_names</strong>” after training</li></ul><p>Please feel free to contribute to the project if you are interested. Thanks!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=856fb6c422e9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>