<?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 Luka Chkhetiani on Medium]]></title>
        <description><![CDATA[Stories by Luka Chkhetiani on Medium]]></description>
        <link>https://medium.com/@lukachkhetiani?source=rss-ff274931ab45------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*OYWPg5M73Jz595H2</url>
            <title>Stories by Luka Chkhetiani on Medium</title>
            <link>https://medium.com/@lukachkhetiani?source=rss-ff274931ab45------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 13:12:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lukachkhetiani/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[Number Plate Detection & Recognition — DETECTRON v2 ; ქართულად]]></title>
            <link>https://medium.com/@lukachkhetiani/number-plate-detection-recognition-detectron-v2-%E1%83%A5%E1%83%90%E1%83%A0%E1%83%97%E1%83%A3%E1%83%9A%E1%83%90%E1%83%93-39f10a9d8235?source=rss-ff274931ab45------2</link>
            <guid isPermaLink="false">https://medium.com/p/39f10a9d8235</guid>
            <category><![CDATA[pytorch]]></category>
            <category><![CDATA[object-detection]]></category>
            <category><![CDATA[detectron]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Luka Chkhetiani]]></dc:creator>
            <pubDate>Mon, 02 Dec 2019 11:20:58 GMT</pubDate>
            <atom:updated>2019-12-02T11:30:11.114Z</atom:updated>
            <content:encoded><![CDATA[<h3>Number Plate Detection — DETECTRON v2 ; ქართულად</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dtOSuCQuaJ62SsCtRH7Q3A.png" /></figure><p>ჭკვიანი კამერების ნაწილი არ მიჰყვება სანომრე პლატის აღმოჩენის ორ ნაბიჯიან სისტემას: 1. შემოსულ სურათზე პლატის რეგიონის აღმოჩენა &amp; ამოჭრა 2. სკალირება (i.e. upsampling) და ტექსტის ექსტრაქცია. არამედ ისინი ყურადღებას აქცევენ ე.წ. ‘დამალულ ნიშანს’, რომელზეც გამჭვირვალე ნაჭრის გადაკვრის, ან უბრალოდ დამახინჯების შემთხვევაში მანქანის მფლობელის ამოცნობა შეუძლებელი ხდება.</p><p>რა თქმა უნდა ზემოთ აღნიშნული ქმედებები არალეგალურია, თუმცა კანონდარღვევას ყოველ ნაბიჯზე ვხვდებით, ამიტომ არც ისე გასაკვირია.</p><p>მძლავრი, რეალურ დროში მომუშავე დეტექტორის ამუშავება არც ისე რთული საქმეა კარგი გამოცდილების მქონე მანქანური ინტელექტის ინჟინრისათვის, განსაკუთრებით იმ ქვეყნებში, სადაც შესაბამისი სანომრე პლატების მონაცემთა ბაზა გამოქვეყნებულია.</p><p>განვითარებისათვის ყოველთვის ვცდილობ რაიმე კონკრეტული დავალების აღებას საკუთარ თავზე, და სრული პროდუქტის დონემდე მიყვანას სასაცილოდ მცირე დროში. <br>შესაბამისად, ქართული სანომრე პლატების დატასეტების არარსებობის მიზეზით, მომიწევს არა ე.წ. ‘დალეიბლება’, არამედ თითოეული ფოტოს ანოტაცია COCO ფორმატში, რათა შემდეგ დეტექტორის საწრთვნელად გამოვიყენო.</p><h4>გეგმა ჟღერს შემდეგნაირად:</h4><ol><li><strong>ვიპოვო 2–3 ვიდეო იუთუბზე შემდეგი ქივორდებით “driving, tbilisi”, “driving georgia”, სადაც ყველაზე მაღალი სიმკვრივით შევხვდები სანომრე პლატებს ფოტოებზე.</strong></li><li><strong>დავჭრა ffmpeg-ის საშუალებით 1 FPS-ზე (1 ფრეიმი 1 წამში)</strong></li><li><strong>გამოვიყენო Labelme open-source პროექტი ფოტოების ანოტაციისათვის.</strong></li><li><strong>გავწრთვნა დეტექტორი Detectron 2 ფრეიმვორქით, RetinaNet წინა ნაწილით, და ResNe50 კლასიფიკატორით (backbone).</strong></li><li><strong>და, რა თქმა უნდა — გამოვაქვეყნო დატასეტი (მონაცემთა ბაზა) ანოტაციებით COCO ფორმატში, გაწრთვნილი მოდელი, საწრთვნელი და ინფერენსისათვის საჭირო სკრიპტები.</strong></li></ol><p>Detectron 2 არის Detectron-ის 0-იდან გადაწერილი ვერსია PyTorch ფრეიმვორქში. ბევრად უფრო მოდულარული, სწრაფი, მარტივი, და რაც მთავარია: დეტექტორ და კლასიფიკატორ მოდელების წინასწარ გაწრთვნილი ჩექფოინთებით და არქიტექტურებით.</p><p><em>ნახეთ რეპოზიტორია: </em><a href="https://github.com/facebookresearch/detectron2"><em>https://github.com/facebookresearch/detectron2</em></a></p><p>საბოლოოდ Google Colab Notebook-საც მოვაყოლებ ბლოგს, დასაწყისისათვის კი მოდი ვნახოთ რამდენად მარტივია დეტექტრონ ფრეიმვორქის ინსტალაცია.</p><p>დავ-’ბილდ’-ოთ torch, torchvision და cython.<br>ასევე: FVCore და COCO API პითონისათვის.</p><pre>!pip install -U torch torchvision cython</pre><pre>!pip install -U &#39;git+https://github.com/facebookresearch/fvcore.git&#39; &#39;git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI&#39;</pre><p>დავკლონოთ დეტექტრონ 2-ის რეპოზიტორია და დავ-’ბილდ’-ოთ.</p><pre>!git clone https://github.com/facebookresearch/detectron2 detectron2_repo<br>!pip install -e detectron2_repo</pre><p>დაბილდვის შემდეგ აუცილებლად მოგვიწევს Runtime Restart.</p><h4>დატასეტი</h4><p>შეგიძლიათ ისარგებლოთ დატასეტით შემდეგ <a href="https://drive.google.com/file/d/1u1VNPrDPP6AePoiYESldTBepFaamrMbY/view"><strong><em>ლინკზე</em></strong></a>.<br>მონაცემთა ბაზა ატვირთულია Google Drive-ზე. შესაბამისად შეგიძლიათ გამოიყენოთ “დაამატე ჩემს დრაივზე” ფუნქცია, ანაც გამოიყენოთ ძალიან კარგი სკრიპტი .zip ფაილის გადმოწერისათვის — <a href="https://github.com/circulosmeos/gdown.pl"><strong><em>gdown</em></strong></a></p><p>გავუკეთოთ unzip დატასეტს. ამოარქივების შემდეგ მისი სტრუქტურა იქნება შემდეგნაირი:</p><pre><strong><em>-plates_coco<br>|--annotations.json<br>|--JPEGImages<br>|--|---*.jpg</em></strong></pre><h4>Gdown.pl</h4><p>gdown-ის გამოყენება ძალიან მარტივია. საკმარისია დავკლონოთ რეპოზიტორია, და მივცეთ სკრიპტს შესაბამისი პრივილეგიები [<strong><em>sudo chmod 777 gdown.pl</em></strong>] და გამოვიყენოთ შემდეგნაირად:</p><pre>./gdown.pl filelink name</pre><p>ჩვენს შემთხვევაში:</p><pre>./gdown.pl <a href="https://drive.google.com/file/d/1u1VNPrDPP6AePoiYESldTBepFaamrMbY/view?usp=sharing">https://drive.google.com/file/d/1u1VNPrDPP6AePoiYESldTBepFaamrMbY/view?usp=sharing</a> plates_coco.zip</pre><h3>Labelme</h3><p>``ჩემს მიერ გამოქვეყნებული დატასეტი უკვე არის COCO ფორმატში.</p><p>ერთ ერთი ძალიან მაგარი open-source პროექტი ჩემს ფავორიტებში არის Labelme, რომელიც იდეურად არის დეტექტორ მოდელებისათვის ფოტოების ანოტაციებისათვის შექმნილი პატარა პაითონის სოფტი. <br>labelme უფასოა, და შეგიძლიათ იხილოთ შემდეგ <a href="https://github.com/wkentaro/labelme"><strong><em>რეპოზიტორიაზე</em></strong></a>.</p><p>მუშაობს <strong>pip3 install labelme</strong>-ს საშუალებითაც, ინსტალაციის შემდეგ სასურველ დირექტორიაში შესვლის და ‘<strong>labelme</strong>’ ფუნქციის გაშვებით ტერმინალში.</p><p>სოფტის გახსნის შემდეგ ვაჭერთ ‘Open Directory’ ღილაკს, და ვირჩევთ სასურველ დირექტორიას. შემდეგ — ‘Create Polygons’ და ვიწყებთ ანოტაციას. შეგიძლიათ დაამატოთ იმდენი კლასი, რამდენს სურვილიც გაქვთ.</p><p>პატარა UX რჩევა კომფორტისათვს: თითო ფოტოს ანოტაციის შემდეგ, შეგიძლიათ დააჭიროთ ‘d’ ღილაკს კლავიატურაზე, და ‘Enter’-ით შეინახოთ *.json ფაილი, რის შემდეგაც ავტომატურად გადაგიყვანთ შემდეგ ფოტოზე.</p><p>ანოტაციის დასრულების შემდეგ გვაქვს *.png/jpg/jpeg ფაილები შესაბამისი დასახელების *.json ფაილებთან ერთად, რომელთა კონვერტაცია COCO ფორმატში შეგვიძლია შემდეგნაირად:</p><p>აიღეთ სკრიპტი ჩემი ჯისტიდან: <a href="https://gist.github.com/deepconsc/7c08cfbba757627b1c1816b30363913d"><strong><em>Labelme2COCO.py</em></strong></a><br>და დაარქვით ‘labelme2coco.py’.</p><p>შექმენით ‘labels.txt’ ფაილი შემდეგი სტრუქტურით:</p><pre>__ignore__<br>კლასი1<br>კლასი2<br>კლასი3</pre><p>ჩვენს შემთხვევაში:</p><pre>__ignore__<br>plates</pre><p>და გაუშვით ბრძანება:</p><pre>!python3 labelme2coco.py input_dir output_dir --labels labels.txt</pre><p><strong>input_dir </strong>არის დირექტორია სადაც ფოტოსურათები და გენერურებული *.json ფაილებია. <strong>output_dir </strong>კი სასურველი დირექტორიის სახელი COCO ფორმატში კონვერტაციის შემდეგ.<br>labels.txt კი ‘ლეიბლების’ ანუ კლასების სახელები (__ignore__ აუცილებელია)</p><h3>წრთვნა</h3><p>შესაბამისი პრერეკვიზიტების ინსტალაციის შემდეგ წრთვნა მარტივია.</p><p>შეგიძლიათ გამოიყენოთ ჩემი <a href="https://gist.github.com/deepconsc/c29e0957a0f44172622050468415cd6d"><strong><em>სკრიპტი</em></strong></a>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9c6098b979b3289a37a2d5a1db68bd43/href">https://medium.com/media/9c6098b979b3289a37a2d5a1db68bd43/href</a></iframe><p>წრთვნას დაჭირდება დაახლოებით 45 წუთამდე. <br>პროცესის დეტალურად ხილვას შეძლებთ მოდელის ‘output’ -ებით.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FxtBaWyHBK-RKo_bmQurNg.png" /></figure><p>რეალურად cfg.SOLVER.IMS_PER_BATCH = 2 (რაც ნიშნავს batch_size = 2) იკავებს გრაფიკული პროცესორის 6414M-ს, ანუ თითქმის ნახევარს, შესაბამისად მისი გაზრდა შეგვიძლია.</p><p>დეტექტრონი იყენებს იტერაციებზე ოპტიმიზირებულ სისტემას. სხვა სიტყვებით, ჩვენ არ გვაქვს ეპოქები, გვაქვს იტერაციები. ანუ, IMS_PER_BATCH = 2 ნიშნავს, რომ თითო იტერაციაზე მოდელი ხედავს 2 სურათს. ჯამური იტერაციების რაოდენობა უნდა იყოს <strong>(N/B) * E, </strong>სადაც N აღნიშნავს ფოტოების რაოდენობას, B აღნიშნავს ბეჩ საიზს (ანუ რამდენი სემპლი ვაჩვენოთ მოდელს თითო იტერაციაზე) და E არის ჯამში რამდენჯერ გვინდა დატასეტი ნახოს დეტექტორმა. <br>ჩვენს წრთვნის პროცედურაში გამოვიყენე 10000 იტერაცია, რაც ნიშნავს რომ მოდელმა მთლიანი დატასეტი ნახა (ბეჩ საიზი * 10000)/ფოტოს რაოდენობაზე, რაც უხეშად 48 ეპოქაა.</p><h4>ჩექფოინთები</h4><p>წრთვნის პროცედურის დროს დეტექტრონი ქმნის დირექტორია ‘output’-ს, სადაც ვნახავთ ჩექფოინთებსა და ე.წ. ლოგებს Tensorboard-ისათვის (ვიზუალიზაცია). ჩვენი მოდელის შემთხვევაში გამოვიყენე 500 იტერაცია როგორც პერიოდი თითო ჩექფოინთის გენერირებისათვის — რაც უხეშად ნიშნავს, რომ თითო ჩექფოინთის გენერირებისას მოდელი დამატებით 2-ჯერ ნახულობს მთლიან მონაცემთა ბაზას.</p><p>გაწრთვნილი მოდელი შეგიძლიათ ნახოთ <a href="https://drive.google.com/file/d/1hMCczENeCLd-jq7KGW9ak8B-QkWVUoXg/view"><strong><em>ლინკზე</em></strong></a>.</p><h4>ინფერენსი (ანუ ტესტირება/deployment)</h4><p>ინფერენსის სკრიპტი ნახეთ ჩემს <a href="https://gist.github.com/deepconsc/251445f3ea9f135d43b7c76b090cb1c0"><strong><em>ჯისტზე</em></strong></a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ff592668b1fcaed3aa3113244583fb68/href">https://medium.com/media/ff592668b1fcaed3aa3113244583fb68/href</a></iframe><h3>Google Colab Notebook</h3><p>გუგლ კოლაბის Notebook შეგიძლიათ იხილოთ შემდეგ <a href="https://colab.research.google.com/drive/19fMPI3WpwSnsirQEwA4UarV8qYPZ6jbK"><strong><em>ლინკზე</em></strong></a>.</p><p><a href="https://colab.research.google.com/drive/19fMPI3WpwSnsirQEwA4UarV8qYPZ6jbK">Google Colaboratory</a></p><h3>შედეგები</h3><p>მოდელმა კარგად იმუშავა. ობიექტურები რომ ვიყოთ, 414 სემპლზე გაწრთვნის, და მისი კარგად წვალების — ინფუთ ფოტოების რეზოლუციის 2–3 ჯერ შემცირებით, შედეგები ძალიან კარგი გამოვიდა.</p><p>ნახეთ რამდენიმე შედეგი:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fxKYXwlqtCO_QLBSAj0_6w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*2V1Mld90nYr_hmMAMCVvbQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ckEDYiv6wljmFTgePC5pPg.png" /></figure><p>ნებისმიერი კითხვის შემთხვევაში აუცილებლად დამიკავშირდით.</p><p>და, მადლობა ყურადღებისათვის!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39f10a9d8235" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Number Plate Detection & Recognition — DETECTRON v2]]></title>
            <link>https://pub.towardsai.net/number-plate-detection-recognition-detectron-v2-5ddad2a532d0?source=rss-ff274931ab45------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ddad2a532d0</guid>
            <category><![CDATA[image-detection]]></category>
            <category><![CDATA[pytorch]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[detectron]]></category>
            <category><![CDATA[computer-vision]]></category>
            <dc:creator><![CDATA[Luka Chkhetiani]]></dc:creator>
            <pubDate>Mon, 02 Dec 2019 10:25:09 GMT</pubDate>
            <atom:updated>2019-12-02T13:58:51.016Z</atom:updated>
            <content:encoded><![CDATA[<h3>Number Plate Detection — DETECTRON v2</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dtOSuCQuaJ62SsCtRH7Q3A.png" /></figure><p>Most (well, at least some) of the ‘Smart Cameras’ don’t use number plate detection &amp; recognition systems, but they pay attention to specific hidden codes on the number plates, and by sticking some transparent material on them, tricking the intelligent systems are not just possible, but pretty easy.</p><p>Well, it’s not legal, but …</p><p>Robust, real-time detection of number plates is not an unresolved challenge for the specific countries, that have dataset published. <br>While looking around the web, I couldn’t find any collection, or at least a ready-to-be-scrapped place, where I could get a dataset of Georgian number plates.</p><p>I’m pretty interested in challenging myself to do some work only by myself, even if it includes some menial work to do. For instance: labeling dataset (not a fan, right?). Or, worse — annotating the dataset for the detector model in COCO format.</p><p>After a couple of minutes of thinking, I came up with an approach, that would take the minimum time possible to get some results.</p><h4>The plan looks like the following:</h4><ol><li><strong><em>Get 2–3 videos from youtube that contain keywords “driving, tbilisi”, “driving georgia”.</em></strong></li><li><strong><em>Cut them to 1 FPS using ffmpeg.</em></strong></li><li><strong><em>Annotate the images using Labelme open-source annotator.</em></strong></li><li>Train the detector model with Detectron 2 framework. RetinaNet with ResNet50 backbone to be specific.</li></ol><p>5.<strong> And — publish the dataset, trained model, and inference after finishing the work.</strong></p><p>Detectron2 is a new write-up by FAIR (Facebook AI Research), that comes with a number of detector and backbone (classifier) pre-trained models for:<br>object detection, instance segmentation, panoptic segmentation, keypoint detection.</p><p><em>See the repository: </em><a href="https://github.com/facebookresearch/detectron2"><em>https://github.com/facebookresearch/detectron2</em></a></p><p>I’ll write Colab Notebook as a follow-up later on, but firstly, let me introduce how easy and quick it is building Detectron2 framework on Google Colab.</p><p>Installing torch, torchvision and cython.<br>Building FVCore, COCO API for Python.</p><pre>!pip install -U torch torchvision cython</pre><pre>!pip install -U &#39;git+https://github.com/facebookresearch/fvcore.git&#39; &#39;git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI&#39;</pre><p>Cloning into Detectron2 Repository and building it</p><pre>!git clone https://github.com/facebookresearch/detectron2 detectron2_repo</pre><pre>!pip install -e detectron2_repo</pre><p>And, restarting Runtime after the building is mandatory.</p><h3>Dataset</h3><p>You can access the dataset with the <a href="https://drive.google.com/file/d/1u1VNPrDPP6AePoiYESldTBepFaamrMbY/view?usp=sharing"><strong><em>link</em></strong></a><strong><em>.<br></em></strong>It’s uploaded on Google Drive. You can either use the “Add to my drive” function or use my beloved Google Drive Downloader script — <a href="https://github.com/circulosmeos/gdown.pl"><strong><em>gdown</em></strong></a><strong><em>.</em></strong></p><p>Unzip the dataset. The instances will be as followed:</p><pre><strong><em>-plates_coco<br>|--annotations.json<br>|--JPEGImages<br>|--|---*.jpg</em></strong></pre><h4>Gdown.pl</h4><p>Using gdown script is pretty easy. Just clone the repository, give the script admin privileges [<strong><em>sudo chmod 777 gdown.pl</em></strong>], and use it as follows:</p><pre>./gdown.pl filelink name</pre><p>In our case</p><pre>./gdown.pl <a href="https://drive.google.com/file/d/1u1VNPrDPP6AePoiYESldTBepFaamrMbY/view">https://drive.google.com/file/d/1u1VNPrDPP6AePoiYESldTBepFaamrMbY/view?usp=sharing</a> plates_coco.zip</pre><h3>Labelme</h3><p>`` The dataset I’ve provided you with is already converted to COCO format.</p><p>One of the coolest totally open-source project. Labelme is image polygonal annotator in python. Absolutely free, easy to use. <br>Check out the <a href="https://github.com/wkentaro/labelme"><strong><em>repository</em></strong></a>.</p><p>Works with <strong><em>pip3 install labelme</em></strong>, and you can execute it afterward by entering the desired dataset directory with terminal and executing command<strong><em> labelme. <br></em></strong>Then click the ‘Open Directory’ button, and open the directory you’re in. <br>Click ‘Create Polygons’, and start annotating. You can add as many classes as you want. <br>A little UX would be: after finishing annotating each image, you can press the ‘d’ button on keyboard and ‘Enter’ twice to save the *.json file, and it’ll proceed to the next image straightforward.</p><p>After finishing the annotation, you’re required to convert it to the COCO format.<br>It’s easy as followed:</p><p>Get the script from the gist: <a href="https://gist.github.com/deepconsc/7c08cfbba757627b1c1816b30363913d"><strong><em>Labelme2COCO.py</em></strong></a><strong><em><br></em></strong>Name it ‘labelme2coco.py’.</p><p>Create ‘labels.txt’ file with the following structure:</p><pre>__ignore__<br>class1<br>class2<br>class3</pre><p>In our case, it is:</p><pre>__ignore__<br>plates</pre><p>Execute the command:</p><pre>!python3 labelm2coco.py input_dir output_dir --labels labels.txt</pre><p>The <strong>input_dir </strong>is the directory your dataset and JSON files are. In case you’re in the same directory, you can use ‘.’ instead of ‘input_dir’.<strong> Output_dir </strong>is the directory we want our COCO-format converted dataset to be named as. And, the labels.txt is the name of.. well, you understand.</p><h3>Training</h3><p>After installing required libraries, and building the detectron2 framework, training is easy to do.</p><p>You can use the following <a href="https://gist.github.com/deepconsc/c29e0957a0f44172622050468415cd6d.js"><strong><em>script:</em></strong></a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9c6098b979b3289a37a2d5a1db68bd43/href">https://medium.com/media/9c6098b979b3289a37a2d5a1db68bd43/href</a></iframe><p>It’ll take a couple of minutes (around 45) to finish the training procedure. And you’ll be able to see the process in detail.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FxtBaWyHBK-RKo_bmQurNg.png" /></figure><p>Basically cfg.SOLVER.IMS_PER_BATCH = 2 (or, batch_size = 2) takes 6414M, almost half of the GPU, so we can increase it for sure. <br>Detectron uses an iteration-based training system. In other words, we don’t have epochs, we have iterations. To be clearer, IMS_PER_BATCH = 2 means that in 1 iteration the model sees 2 images. The total size of the iterations should be (<strong>N / B) * E</strong>, where <strong>N </strong>stands for Number of Images, <strong>B </strong>stands for Batch Size, and <strong>E </strong>means epochs, or how many times we want our model to see each image. <br>In my training procedure, I’ve used a total of 10000 steps, which means the model has seen each image (Batch Size *10000)/Num Images times, which roughly is 48 (epochs).</p><h4>Model Outputs</h4><p>The training procedure creates the ‘outputs’ directory with checkpoints and the log files for tensorboard. In our trainer we’ve used 500 as a period for each checkpoint, in other words — it’ll generate a model in every 500 steps. This means every time the model sees the dataset twice, we’re generating the checkpoint.</p><p>You can access my pretrained model with the <a href="https://drive.google.com/file/d/1hMCczENeCLd-jq7KGW9ak8B-QkWVUoXg/view"><strong><em>link</em></strong></a></p><h3>Inference</h3><p>For the inference, use the following <a href="https://gist.github.com/deepconsc/251445f3ea9f135d43b7c76b090cb1c0.js"><strong><em>gist</em></strong></a><strong><em>.</em></strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ff592668b1fcaed3aa3113244583fb68/href">https://medium.com/media/ff592668b1fcaed3aa3113244583fb68/href</a></iframe><h3>Colab Notebook</h3><p>Access the Notebook with the following <a href="https://colab.research.google.com/drive/19fMPI3WpwSnsirQEwA4UarV8qYPZ6jbK"><strong><em>link.</em></strong></a></p><p><a href="https://colab.research.google.com/drive/19fMPI3WpwSnsirQEwA4UarV8qYPZ6jbK">Google Colaboratory</a></p><h3>Results</h3><p>The model works fine. To be fair, with a total of 414 images annotated, and by making it struggle by downsampling the input images 2–3 times, its outputs turns out to be pretty good. <br>See some of the results here:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fxKYXwlqtCO_QLBSAj0_6w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*2V1Mld90nYr_hmMAMCVvbQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ckEDYiv6wljmFTgePC5pPg.png" /></figure><p>In case of any questions, feel free to comment &amp; reach out.</p><p>And, thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ddad2a532d0" width="1" height="1" alt=""><hr><p><a href="https://pub.towardsai.net/number-plate-detection-recognition-detectron-v2-5ddad2a532d0">Number Plate Detection &amp; Recognition — DETECTRON v2</a> was originally published in <a href="https://pub.towardsai.net/">Towards AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Progressive Growing GAN for Romanticism]]></title>
            <link>https://medium.com/@lukachkhetiani/progressive-growing-gan-for-romanticism-77ed951752f2?source=rss-ff274931ab45------2</link>
            <guid isPermaLink="false">https://medium.com/p/77ed951752f2</guid>
            <dc:creator><![CDATA[Luka Chkhetiani]]></dc:creator>
            <pubDate>Fri, 08 Nov 2019 20:54:56 GMT</pubDate>
            <atom:updated>2019-11-08T20:54:56.413Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cx8eBUyaOC0yP7ZvadvJZQ.gif" /></figure><p><strong>Paper</strong>:<strong><em> [</em></strong><a href="https://arxiv.org/pdf/1710.10196.pdf"><strong><em>https://arxiv.org/pdf/1710.10196.pdf</em></strong></a><strong><em>]</em></strong></p><p>We trained Progressive Growing GAN for Romanticism genre paintings scraped from <a href="https://wikiart.com/">https://wikiart.com</a>. Dataset consisted total of 3506 images.</p><p>Procedure started from 8x8 and finished at 512x512 resolution (for memory and timing issues).</p><h3>Samples</h3><h4>1.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*1T0tbC_WWHfl0MqZNnozGA.png" /></figure><h4>2.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*2cHTCAIPKjtxYFSHHlVjHQ.png" /></figure><h4>3.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*JHp5ybB6EUxvPOFxM1tMUA.png" /></figure><h4>4.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*q9GULhdUW2E48o192NTj7w.png" /></figure><h4>5.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*d07vaG-RF_x4eAaYkTLDbw.png" /></figure><h4>6.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*ooJOCGIs7Bxu4ORNYpnR2Q.png" /></figure><h4>7.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*U710RUhlqPQT18V_9AErvA.png" /></figure><h4>8.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*cZ6aU740oOd2Y1-nR9fyww.png" /></figure><h4>9.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*v4BBUOfB35cxodNlsj21oA.png" /></figure><h4>10.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*RTApC0HdE8Q1Qfj4UOQpbQ.png" /></figure><h4>11.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*WF-7K9UzHvx4-ermju84Ng.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=77ed951752f2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[StyleGAN Generated Face Classification with ResNexts]]></title>
            <link>https://pub.towardsai.net/stylegan-generated-face-classification-with-resnexts-19535ed1d91d?source=rss-ff274931ab45------2</link>
            <guid isPermaLink="false">https://medium.com/p/19535ed1d91d</guid>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[generative-adversarial]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Luka Chkhetiani]]></dc:creator>
            <pubDate>Sat, 28 Sep 2019 01:43:15 GMT</pubDate>
            <atom:updated>2019-10-02T17:55:46.839Z</atom:updated>
            <content:encoded><![CDATA[<h4>Using ResNexts with StyleGAN | <a href="https://towardsai.net/">Towards AI</a></h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F3VPb05GlWT4%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D3VPb05GlWT4&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F3VPb05GlWT4%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/1e946e4217e55ea390cd46c4becbb994/href">https://medium.com/media/1e946e4217e55ea390cd46c4becbb994/href</a></iframe><p>A week or two back a team released a dataset of 100K images of generated faces, based on StyleGAN [<em>Karras et al. and NVIDIA]</em> <a href="https://arxiv.org/pdf/1812.04948.pdf"><em>(see paper)</em></a><em>.</em></p><p>We’ve seen similar tech open for public interaction a while ago on <a href="https://www.thispersondoesnotexist.com/">https://www.thispersondoesnotexist.com</a>, which basically generates an entirely new face for every visit on the website.</p><p>The network is robust, and the work impressive, that’s for sure. And, to be completely honest, us, people in the field of ML/DL, especially if you’ve played with GANs, are familiar with Computer Vision, can somehow detect the fakeness.</p><p>Anyway, let me share a couple of red flags that generated images have in most cases:</p><h4>1. Pixel Perturbation</h4><p>Many of almost-perfect generated images have mutilated pixels, that look like <br>‘holes’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2-0i1Q-FKVduymcWoA_hnA.png" /><figcaption>retrieved from https://generated.photos</figcaption></figure><h4>2. Asymmetry</h4><p>Objects are asymmetrical. In this case, both sides of the glasses are different.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*256-q4iPEYZDm2hdBlKDPg.png" /><figcaption>retrieved from https://generated.photos</figcaption></figure><h4>3. Weird side-object, asymmetrical teeth.</h4><p>In case there’s another object present on image, we’ve destructed the idea of it. In this image, we see the idea of a person, but it seems to be weird.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V_SBCkD4Vbb9NON7VOdJ5g.png" /><figcaption>retrieved from <a href="https://generated.photos/">https://generated.photos</a></figcaption></figure><h4>4. Asymmetrical teeth, weird side-object</h4><p>Again asymmetry and weird objects, but in this case asymmetry of teeth are much clearly illustrated, and the object gives us feeling like we know what it is, but can’t describe it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KZxLbMU9PC6WpBeP9JmAXA.png" /><figcaption>retrieved from <a href="https://generated.photos/">https://generated.photos</a></figcaption></figure><h4>5. Synthetic Skin</h4><p>Skin in generated images is not well structured. Transitions, highlights, and sharpness are easy to spot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nTymJlaLqrS6dqOTQwHcwQ.jpeg" /><figcaption>retrieved from <a href="https://generated.photos/">https://generated.photos</a></figcaption></figure><h4>6. Hair</h4><p>Hair is messy in most of the cases, and are mixed with different objects, skin or background.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*80h8nzqAMlTDO--Acw1Iqw.jpeg" /><figcaption>retrieved from <a href="https://generated.photos/">https://generated.photos</a></figcaption></figure><h3><em>An obligation of data-usage</em></h3><p>Well, when you see a royalty-free data, available publicly, it’s hard to not try it out. The generated images are free to use for commercial and research purposes <em>‘’just for a link back to them’’</em>, as described in terms of use.</p><p>Speaking of <a href="https://colab.research.google.com/"><strong>Google Colab</strong></a><strong> </strong>dependent person, it was really challenging to get the data altogether for a couple of reasons, such as a. having not total access while adding to my drive. b. well, there are 100K images, and <strong>Colab </strong>is really slow in case of reading/writing (moving, copying) media files.</p><p>And, I chose to use CelebA images for the <strong>“True” </strong>class.<br>So: <em>Real Images</em>: <strong>True</strong>, <em>Generated Images</em>: <strong>False</strong></p><p>While analyzing the dataset, I’ve noticed a couple of differences, and similarities:</p><ol><li>Well, — quality. CelebA aligned images are pixelated, and have low quality, whereas StyleGAN generated images have <strong>Super Resolution (1024x1024)</strong></li><li>Background diversity — There are various backgrounds presented in CelebA images, such as banners, fields, cars, etc. But, we have an almost identical background in the case of generated ones.</li><li>Brightness — CelebA images are naturally highlighted, whereas stylegan images have generated synthetic lights.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*09WS9xTaPu1z-7tVyKoyTw.png" /></figure><p>In this case, model will easily overfit on the data, for sure. <br>To make it clearer — I’m not building an optimal fake-face detector, just trying to classify the generated images of these specifications. So, a little bit overfitting is not a big issue.</p><p>I do my work in PyTorch, and I’ve incorporated two additional augmentations besides <strong><em>horizontal/vertical flipping </em></strong><em>and </em><strong><em>color jittering:</em></strong></p><h4>Clache filtering (histogram equalization algorithm):</h4><p>We are taking 3 channels (LAB) where (L) channel denotes whiteness intensity on the image,</p><p>and is calculated between Black (0) and White(100).</p><p>A Channel — between Green (-) and Red (+)</p><p>B Channel — between Blue (-) and Yellow (+)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*unJuGVaQfQLPWsL4IQJvpQ.png" /></figure><p>And, the histogram equalization for image <em>g</em> will be represented by</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tdJf2LSCwo8BNEdq0LLRxQ.png" /></figure><h4><strong>Brightness and contrast normalization</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6JoBaEIlA9zzMvqTGNCD5Q.png" /><figcaption>CLACHE and B/C Normalization</figcaption></figure><p>Pre-processed images by applying brightness and contrast normalization and CLACHE seems to distinguish the abnormalities of the images and make it as clear as possible.<br>The images are resized to <strong>299x299.</strong></p><h3>ResNeXt</h3><p>Idea is to use torchvision pre-trained ResNeXt-101 model by accomplishing the next steps:</p><ol><li>Training only network heads [<strong><em>lr=1e-3, SGD</em></strong>]</li><li>Training Layer4 and up [<strong><em>lr=1e-3, SGD</em></strong>]</li><li>Training the whole network [<strong><em>lr=1e-4, SGD</em></strong>]</li></ol><h3>Training and Results</h3><pre>Epoch 1 Train loss: 0.452.. Test loss: 0.495.. Test accuracy: 0.795 Epoch 1 Train loss: 0.363.. Test loss: 0.400.. Test accuracy: 0.827 Epoch 2 Train loss: 0.302.. Test loss: 0.331.. Test accuracy: 0.843 Epoch 2 Train loss: 0.166.. Test loss: 0.271.. Test accuracy: 0.880 Epoch 3 Train loss: 0.015.. Test loss: 0.252.. Test accuracy: 0.909 Epoch 3 Train loss: 0.062.. Test loss: 0.194.. Test accuracy: 0.911 Epoch 4 Train loss: 0.108.. Test loss: 0.183.. Test accuracy: 0.936 Epoch 4 Train loss: 0.029.. Test loss: 0.142.. Test accuracy: 0.964 Epoch 5 Train loss: 0.279.. Test loss: 0.135.. Test accuracy: 0.968 Epoch 5 Train loss: 0.119.. Test loss: 0.110.. Test accuracy: 0.973</pre><p>The model has shown really promising results on the test set. <br>And, as long as in most cases models don’t perform the same way they show in the test set, and that happens because of many reasons: poor tuning, not normalizing data, etc., I always try to manually test them on unseen data.</p><p>By choosing <strong><em>100 True </em></strong>and<strong><em> 100 False </em></strong>images for manual validation, I’ve ended up having only 3 errors, but the model was completely confused while doing prediction my social media profile picture after the validation procedure.</p><p>The idea of the whole writing was to encourage people to test their own ideas, try different approaches for the detection of fake-generated data, even though you might not have too much time for fine-tuning the model for research purposes in the different field than yours. Because, your work could be an inspiration for others, and we can really see the possible risks of impressive GANs usage for illegal purposes.</p><h4>Link for tuned model:</h4><p><a href="https://drive.google.com/drive/folders/1QRvun5knO4Awo2hcl0C1INPkHO5UdNMf?usp=sharing">ResNext101 - Google Drive</a></p><p><strong><em>You can use it by simply loading with torch.load() function, and declaring classes = [‘generated’,’groundtruth’].</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19535ed1d91d" width="1" height="1" alt=""><hr><p><a href="https://pub.towardsai.net/stylegan-generated-face-classification-with-resnexts-19535ed1d91d">StyleGAN Generated Face Classification with ResNexts</a> was originally published in <a href="https://pub.towardsai.net/">Towards AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[APTOS 2019 Blindness Detection — Playing around with ResNeXts and Progressive NASNets]]></title>
            <link>https://pub.towardsai.net/aptos-2019-blindness-detection-playing-around-with-resnexts-and-progressive-nasnets-2ab82163daea?source=rss-ff274931ab45------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ab82163daea</guid>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[kaggle]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[healthcare]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Luka Chkhetiani]]></dc:creator>
            <pubDate>Tue, 03 Sep 2019 06:29:07 GMT</pubDate>
            <atom:updated>2019-10-03T13:51:28.774Z</atom:updated>
            <content:encoded><![CDATA[<h4>APTOS 2019 Blindness Detection | <a href="https://towardsai.net/">Towards AI</a></h4><h3>APTOS 2019 Blindness Detection — Playing around with ResNeXts and Progressive NASNet</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jGqZUe-koITWYjzdvCn1wQ.png" /></figure><h4>A while ago Kaggle announced challenge: APTOS 2019 Blindness Detection — Detect diabetic retinopathy to stop blindness before it’s too late.</h4><p>The idea of competition is to predict the severity of diabetic retinopathy on a scale of 0–4.</p><pre>0 - No DR</pre><pre>1 - Mild</pre><pre>2 - Moderate</pre><pre>3 - Severe</pre><pre>4 - Proliferative DR</pre><p>The training set consists of 3661 images and 4 classes. We should note that the dataset is not well-balanced. Well, we’ll use a couple of tricks to maximize the possible outcome, including augmentation, freezing &amp; unfreezing layers, etc.</p><p>I’ve tried a couple of models, such as <strong>DenseNet, ResNet50/101, Inception v3/v4</strong> and even <strong>ResNeXt-101–32x8d </strong>— architecture with <strong>88M </strong>parameters, <strong>82.2</strong> <em>top-1</em> and <strong>96.4 </strong><em>top-5 </em>errors weren’t able to surpass the <strong>66.2%</strong> accuracy limit on submission set, nonetheless, some of them have shown <strong>&gt;95.0%</strong> acc on validation.</p><p>So, I sat down and analyzed the dataset, and a couple of models.<br>Idea is that — big models overfitted, and small models under fitted, no matter how good I’ve tuned them.</p><p>Searched through models once again, and I got:</p><ul><li><strong><em>ResNeXt 5 32x4d — {</em></strong><a href="https://arxiv.org/pdf/1611.05431.pdf"><em>see paper here</em></a><strong><em>}</em></strong></li><li><strong><em>PNASNet 5 Large — {</em></strong><a href="https://arxiv.org/pdf/1712.00559.pdf"><em>see paper here</em></a><strong><em>}</em></strong></li></ul><p>And, decided to try both models.</p><p>I’ve implemented <strong>TensorboardX </strong>, which generates<em> ‘run’ </em>directory after execution, so we can visualize the training process.</p><p>torch.DataParallel?<br>No, I’m a victim of Google Colab for now.</p><h3>My PyTorch code for ResNeXt50 training:</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/97d9a50d063600f458d62f9e27784641/href">https://medium.com/media/97d9a50d063600f458d62f9e27784641/href</a></iframe><h3>For PNASNet 5 Large:</h3><p>I used <a href="https://github.com/Cadene">Cadene’s</a> implementation initially, and then converted to my code for fine-tuning, by just loading the model.</p><p><strong>Training Set</strong></p><p>After combining the datasets, the total number of images per class looks like the next:</p><pre>Total - 3661 images<br><br><br>0 - No DR : 1805 images</pre><pre>1 - Mild : 370 images</pre><pre>2 - Moderate : 999 images</pre><pre>3 - Severe : 193 images</pre><pre>4 - Proliferative DR : 295 images</pre><p>Actually, there’s a huge difference between the classes. We’ll use augmentation, but anyway — augmenting images can help, but not a lot.</p><p>A simple code that will help you to sort the images by classes after unzipping them would be:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d3b146179a6613016a9c91aa46f9eff5/href">https://medium.com/media/d3b146179a6613016a9c91aa46f9eff5/href</a></iframe><h3>Data Augmentation</h3><p>Dataset is not so rich. We’ve 3661 images total. So, I’m going to use PyTorch’s data augmentation techniques, such as:</p><blockquote><em>transforms.RandomVerticalFlip(p=0.5),</em></blockquote><blockquote><em>transforms.RandomRotation((0,360), center=None),</em></blockquote><blockquote><em>transforms.RandomHorizontalFlip(p=0.5)</em></blockquote><p>Randomly flipping images vertically with 0.5 probability.<br>Random Rotation within 0,359 range (basically giving the ability to make a full rotation)<br>Randomly flipping horizontally with 0.5 probability.</p><p>PyTorch data transformation techniques work perfectly. By the end of the epoch, the model will have seen additionally 3 different augmentations on a single image.</p><h3><strong>Data Resizing</strong></h3><p><strong>ResNeXt</strong> is being trained on <em>299x299</em> resized images. But, <strong>PNASNet </strong>requires <em>331x331 </em>inputs. Thus, I’m going to modify the code respectively.</p><h4><em>Little UX:</em></h4><p>In case we want the process to run in the background, and not have a laptop/PC up all night, we can use <em>nohup.</em></p><p>The command will be:</p><pre>nohup python3 train.py &amp;</pre><p>And, we can see the stdouts via:</p><pre>cat nohup.out</pre><p>Or, tail them via:</p><pre>tail -f nohup.out</pre><p>Additionally, I really didn’t want to mess with ngrok. So, I used <strong>subprocess </strong>function to download the <strong>tensorboard</strong> output every once in a while, and refresh it.</p><pre>from time import sleep</pre><pre>import subprocess</pre><pre>for i in range(10000):</pre><pre>subprocess.run(&#39;scp user@ip_address:~/APTOS/runs/Aug30_21-58-43/* runs/&#39;, shell=True)</pre><pre>sleep(20)</pre><h3>Let’s start training.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XpjBNsES6BezhY-Bi-RPyg.gif" /></figure><p>Plan:</p><ul><li><strong>Train the ResNeXt for 3 and PNASNet for 2 epochs with learning rate 1e-3.</strong></li><li><strong>Train the ResNeXt and PNASNet for 3 epochs with learning rate 1e-4</strong></li><li><strong>ResNeXt — Freeze all layers but 3,4, decrease lr to 1e-5, and unfreeze the blocks step-by-step by decreasing lr by 10x.</strong></li><li><strong>PNASNet — Freeze everything but cell_9, 10, 11 and continue training on 1e-5 lr. Afterward, unfreeze the cells step by step and anneal the lr by 10x.</strong></li></ul><p>Why?</p><p>While playing around with those two models, I noticed that it yielded persuasive accuracy on the first two epochs with lr <strong>1e-3</strong>, but if the training was continued with the same parameters, it drafted around the same accuracy and loss.<br>Decreasing lr 10x times helps a lot to increase accuracy and continue decreasing the loss. 4 epochs are perfectly enough for the whole model to get to know with the dataset and study enough features.</p><p>But, after leaving only the deepest layers, which are responsible for deeper features makes the model more sophisticated and fastens up the training procedure. To say it in other words: I’m giving the model some time to familiarize with the dataset and study it, and afterward concentrating it on the most powerful components of the dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BLgnqpdggadO44nfkxdEGw.png" /></figure><h3>1st Part</h3><p>Learning rate <strong>1e-3</strong>, all layers, 2 epochs.</p><p><strong><em>PNASNet 5 Large</em></strong></p><pre>Epoch 1/50.. Train loss: 3.503.. Test loss: 5.913.. Test accuracy: 0.011 <br>Epoch 1/50.. Train loss: 1.449.. Test loss: 1.084.. Test accuracy: 0.697 <br>Epoch 1/50.. Train loss: 0.806.. Test loss: 0.673.. Test accuracy: 0.745 <br>Epoch 1/50.. Train loss: 0.630.. Test loss: 0.606.. Test accuracy: 0.776 <br>Epoch 1/50.. Train loss: 0.681.. Test loss: 0.591.. Test accuracy: 0.773 <br>Epoch 2/50.. Train loss: 0.610.. Test loss: 0.546.. Test accuracy: 0.796 <br>Epoch 2/50.. Train loss: 0.711.. Test loss: 0.564.. Test accuracy: 0.792 <br>Epoch 2/50.. Train loss: 0.474.. Test loss: 0.582.. Test accuracy: 0.790 <br>Epoch 2/50.. Train loss: 0.484.. Test loss: 0.539.. Test accuracy: 0.807 <br>Epoch 2/50.. Train loss: 0.555.. Test loss: 0.527.. Test accuracy: 0.811 <br>Epoch 3/50.. Train loss: 0.559.. Test loss: 0.520.. Test accuracy: 0.814 <br>Epoch 3/50.. Train loss: 0.455.. Test loss: 0.507.. Test accuracy: 0.821 <br>Epoch 3/50.. Train loss: 0.572.. Test loss: 0.486.. Test accuracy: 0.822 <br>Epoch 3/50.. Train loss: 0.408.. Test loss: 0.520.. Test accuracy: 0.831 <br>Epoch 3/50.. Train loss: 0.546.. Test loss: 0.466.. Test accuracy: 0.829</pre><p><strong><em>ResNeXt 50 32x4d</em></strong></p><pre>Epoch 1/50.. Train loss: 2.787.. Test loss: 3.990.. Test accuracy: 0.254 <br>Epoch 1/50.. Train loss: 1.460.. Test loss: 0.893.. Test accuracy: 0.684 <br>Epoch 1/50.. Train loss: 0.722.. Test loss: 0.654.. Test accuracy: 0.738 <br>Epoch 2/50.. Train loss: 0.817.. Test loss: 0.640.. Test accuracy: 0.771 <br>Epoch 2/50.. Train loss: 0.590.. Test loss: 0.533.. Test accuracy: 0.807 <br>Epoch 2/50.. Train loss: 0.517.. Test loss: 0.496.. Test accuracy: 0.820 <br>Epoch 3/50.. Train loss: 0.579.. Test loss: 0.559.. Test accuracy: 0.772 <br>Epoch 3/50.. Train loss: 0.470.. Test loss: 0.493.. Test accuracy: 0.809 <br>Epoch 3/50.. Train loss: 0.512.. Test loss: 0.477.. Test accuracy: 0.836</pre><h3>2nd Part</h3><p>All Layers</p><p><strong><em>PNASNet 5 Large</em></strong></p><pre>Epoch 1/50.. Train loss: 0.472.. Test loss: 0.402.. Test accuracy: 0.848 <br>Epoch 1/50.. Train loss: 0.452.. Test loss: 0.370.. Test accuracy: 0.857 <br>Epoch 1/50.. Train loss: 0.474.. Test loss: 0.383.. Test accuracy: 0.840 <br>Epoch 1/50.. Train loss: 0.402.. Test loss: 0.383.. Test accuracy: 0.855 <br>Epoch 2/50.. Train loss: 0.552.. Test loss: 0.398.. Test accuracy: 0.848 <br>Epoch 2/50.. Train loss: 0.453.. Test loss: 0.378.. Test accuracy: 0.867 <br>Epoch 2/50.. Train loss: 0.431.. Test loss: 0.391.. Test accuracy: 0.846 <br>Epoch 2/50.. Train loss: 0.307.. Test loss: 0.379.. Test accuracy: 0.857 <br>Epoch 3/50.. Train loss: 0.453.. Test loss: 0.378.. Test accuracy: 0.855 <br>Epoch 3/50.. Train loss: 0.372.. Test loss: 0.376.. Test accuracy: 0.851 <br>Epoch 3/50.. Train loss: 0.429.. Test loss: 0.380.. Test accuracy: 0.862 <br>Epoch 3/50.. Train loss: 0.408.. Test loss: 0.385.. Test accuracy: 0.855</pre><p><strong><em>ResNeXt 50</em></strong></p><pre>Epoch 1/50.. Train loss: 0.230.. Test loss: 0.423.. Test accuracy: 0.837 <br>Epoch 1/50.. Train loss: 0.454.. Test loss: 0.416.. Test accuracy: 0.846 <br>Epoch 1/50.. Train loss: 0.462.. Test loss: 0.410.. Test accuracy: 0.841 <br>Epoch 2/50.. Train loss: 0.458.. Test loss: 0.416.. Test accuracy: 0.837 <br>Epoch 2/50.. Train loss: 0.437.. Test loss: 0.386.. Test accuracy: 0.854 <br>Epoch 2/50.. Train loss: 0.407.. Test loss: 0.406.. Test accuracy: 0.846 <br>Epoch 3/50.. Train loss: 0.425.. Test loss: 0.401.. Test accuracy: 0.845 <br>Epoch 3/50.. Train loss: 0.424.. Test loss: 0.394.. Test accuracy: 0.836<br>Epoch 3/50.. Train loss: 0.552.. Test loss: 0.398.. Test accuracy: 0.846</pre><h3>After freezing &amp; unfreezing layers and tuning the lr</h3><p><strong><em>PNASNet 5 Large</em></strong></p><pre>Epoch 1/50.. Train loss: 0.220.. Test loss: 0.344.. Test accuracy: 0.884 <br>Epoch 1/50.. Train loss: 0.477.. Test loss: 0.361.. Test accuracy: 0.873 <br>Epoch 1/50.. Train loss: 0.428.. Test loss: 0.345.. Test accuracy: 0.881 <br>Epoch 1/50.. Train loss: 0.410.. Test loss: 0.358.. Test accuracy: 0.872 <br>Epoch 1/50.. Train loss: 0.403.. Test loss: 0.356.. Test accuracy: 0.874 <br>Epoch 1/50.. Train loss: 0.414.. Test loss: 0.332.. Test accuracy: 0.884 <br></pre><p><strong><em>ResNeXt 50</em></strong></p><pre>Epoch 1/50.. Train loss: 0.176.. Test loss: 0.354.. Test accuracy: 0.876 <br>Epoch 1/50.. Train loss: 0.332.. Test loss: 0.370.. Test accuracy: 0.865 <br>Epoch 2/50.. Train loss: 0.401.. Test loss: 0.361.. Test accuracy: 0.865 <br>Epoch 2/50.. Train loss: 0.376.. Test loss: 0.366.. Test accuracy: 0.866 <br>Epoch 2/50.. Train loss: 0.342.. Test loss: 0.354.. Test accuracy: 0.870 <br>Epoch 3/50.. Train loss: 0.399.. Test loss: 0.372.. Test accuracy: 0.870 <br>Epoch 3/50.. Train loss: 0.330.. Test loss: 0.349.. Test accuracy: 0.875</pre><h3>Results</h3><p>We’ve <strong><em>87.5% </em></strong>accuracy on <strong>ResNeXt 50</strong>, and <strong><em>88.4% on </em>PNASNet 5.</strong></p><p>Basically, I’ve tried SOTA, mediocre, and lastly — two out of top architectures for image classification. <br>And, we know — the models don’t work exactly the same way in real life as they show in test/validation procedures.</p><p>Anyway, tuning two models overnight was fun, and lastly — I’ll make predictions on actual test (submission) set, and we’ll see the results.</p><h3>Prediction</h3><p>My inference for the prediction part.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dd131bd7b3a300941ed6f464ace5b1e6/href">https://medium.com/media/dd131bd7b3a300941ed6f464ace5b1e6/href</a></iframe><p>In case we’re using <a href="https://colab.research.google.com/">Google Colab</a> for prediction, we should note that sometimes <strong>tqdm </strong>is not a great option, as long as it refreshes the stdout for every output, and the page will crash. I always try with <strong>tqdm</strong> firstly, and if it’s not working well, just erasing it on the loop, and writing my version of the script to see the prediction process. <strong>We should make sure that we erase the *.csv file after the first try, or it’ll append the new predictions to it.</strong></p><h3>Kaggle</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7nSbUCdEHnjr48TsKW3NoA.png" /><figcaption><a href="https://www.kaggle.com/">https://www.kaggle.com</a></figcaption></figure><p>While trying to make a submission after the prediction part, <a href="https://www.kaggle.com/"><strong>kaggle</strong></a> made me furious. Basically they had a bug in the kernel, that threw submission error every time I tried to submit the predictions. <br>After searching for a while, I saw one kaggler’s comment, that actually helped me.</p><p>P.S. Turning off GPU and Internet in Kernel were helpful as well, in addition to downgrading Python docker image to 1–7 versions on Kaggle.</p><p>I’m gonna lend their code for submission part:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/13ce48d8e8cbb8ae973c4fbe872625a4/href">https://medium.com/media/13ce48d8e8cbb8ae973c4fbe872625a4/href</a></iframe><h3>Final Results:</h3><p><strong><em>ResNeXt 50</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0XCSSStDggg5WIA6ESVZTA.png" /></figure><p><strong><em>PNASNet 5</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ux51jCAY5V-W6yM0LOQ41A.png" /></figure><p>When I checked the reason why PNASNet worked so poorly, I noticed many of 0’s and 2’s, a couple of 1’s as prediction numbers in submission. And absolutely no 4’s or 3’s. <br>NASNet overfitted on 0 and 2 classes, as long as they held the most of the data, and made poor predictions on other classes, or didn’t make at all.</p><p>And, ResNeXt 50 turned out to work well for just overnight tuning.</p><p>There are 3 more days until the challenge closes, and I’m planning to try more <br>promising approaches as soon as I have time.</p><p>Hope you enjoyed it!</p><h3><strong>UPDATE:</strong></h3><p>By cropping dataset, and training the last layers longer, I made 4.1% improvement.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qytF_9NMysNRLHM_MuJWAg.png" /></figure><h3>2nd UPDATE</h3><p>Mean color subtraction gave 2.0% improvement.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V0qlo2HOy53gCpV811GcMQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ab82163daea" width="1" height="1" alt=""><hr><p><a href="https://pub.towardsai.net/aptos-2019-blindness-detection-playing-around-with-resnexts-and-progressive-nasnets-2ab82163daea">APTOS 2019 Blindness Detection — Playing around with ResNeXts and Progressive NASNets</a> was originally published in <a href="https://pub.towardsai.net/">Towards AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NDA or “you can’t have the same idea”]]></title>
            <link>https://medium.com/coinmonks/nda-or-you-cant-have-the-same-idea-b4419f184a67?source=rss-ff274931ab45------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4419f184a67</guid>
            <category><![CDATA[ideas-to-execution]]></category>
            <category><![CDATA[ideas]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[nda]]></category>
            <dc:creator><![CDATA[Luka Chkhetiani]]></dc:creator>
            <pubDate>Thu, 09 Aug 2018 16:22:41 GMT</pubDate>
            <atom:updated>2018-08-09T16:34:32.186Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZmAR9zZ2Vpgq8P1FAPPtvg.jpeg" /></figure><p>Mostly in the tech world, the NDA is a popular thing. NDA means a non-disclosure agreement, which protects your idea from being stolen.<br>Let’s agree, as big companies, investors and even Silicon Valley inspires people to come up with new business ideas, tech solutions or startups, it’s pretty hard to think about something, that hasn’t been even thought by anyone. And later on, executing it is much more intense work than actually thinking about a new idea.<br>Most of the experts would say, that success is about 1% idea and 99% execution. Personally, I agree with that.</p><h4>Why?</h4><p>If you look around, you’ll see some companies with tech or non-tech solution services, that have amazing success, pretty good income and almost everything that new startup would ever wish to have.</p><h4>How?</h4><p>“How they do it” is a pretty interesting question. <br>The answer is simple <em>— </em><strong><em>execution.</em></strong></p><p>They just create a special, “one-thing oriented” solution that is demanded by the market and a pretty good business plan, good timing, few connections and one big initial project is a key to enter the market. For instance, let’s take <strong>Airbnb</strong> — the idea of renting homes online was not a game-changing idea for 2008. But what happened? <br><strong>Good timing </strong>— The crisis in the subprime mortgage market have begun in 2007 which then developed into one huge international crisis era. In the beginning, people thought that the idea of allowing strange people to rent a room in the same house was crazy. But later on, when they found out that extra cash is always appreciated, and they could use their extra rooms as an additional income source, they started to use the service. <br>And now, look at them — their revenue was 2.7 billion USD by 2017.</p><p>So, just remember — there are more than seven billion humans on the planet, and all of them have different ideas, and all of them think their idea is game-changing. Only the ones, who knows what is execution and how it should be done, are successful.</p><p>When you are trying to pitch an idea to the possible investor, trying to make them sign an NDA, think twice about it.</p><p>Firstly, almost all the investors are investing in a group of people, or a person, not in an idea. If the idea is just an idea, then you have pretty low chances of getting funding.</p><p>If you already have a prototype, you have nothing to worry about — if someone steals your idea, turning it into a product will be such a huge deal for them. They’ll lose extra money, extra recourses and still may not have the same technology as your own. A good investor always knows the equilibrium between how good the idea is to be executed, and how good the idea is for the needed execution recourses.</p><p>Just think, is the idea really worth of NDA?</p><p>If you have execution plan and the steps, that should be covered to get maximum attention of the consumers, then you shouldn’t think about it — you need the NDA for sure.</p><p>A simple way to get “NDA-like document”, that legally works is to appoint a meeting via email, by a brief explanation of the idea you’re going to pitch them. Email has actual legal importance, and in any case, you could use it as an evidence.</p><p>The main point of the whole writing is to distinguish the NDA-needed “plans” from just ideas. <br>Remember, if they steal your idea, they still need huge resources to have the same technology as you have, they need to invest money in the management, marketing, design and etc. Reverse-engineering anyone’s product is a pretty hard thing to do. And if it’s easy in some case, than the previous company wasn’t worth to own it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4419f184a67" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coinmonks/nda-or-you-cant-have-the-same-idea-b4419f184a67">NDA or “you can’t have the same idea”</a> was originally published in <a href="https://medium.com/coinmonks">Coinmonks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Neural Style Transfer Using Tensorflow in Python]]></title>
            <link>https://medium.com/coinmonks/neural-style-transfer-using-tensorflow-in-python-499b39084827?source=rss-ff274931ab45------2</link>
            <guid isPermaLink="false">https://medium.com/p/499b39084827</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Luka Chkhetiani]]></dc:creator>
            <pubDate>Tue, 03 Jul 2018 02:28:50 GMT</pubDate>
            <atom:updated>2018-08-11T18:43:32.817Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zV7GGD_qoNXwgA0EtClWvA.png" /><figcaption>Credits to Magdiel Lopez</figcaption></figure><p>In contemporary high-tech world, Deep Learning is used in different ways to achieve specific goals in specific topics. Engineers and developers across the world use the AI algorithms for mainteance, cybersecurity, mathematical solutions, customer service and etc.</p><p>Image recognition and classification is not a hard job, thanks to world-class algorithms such as <strong>Inception</strong>, or <strong>ResNet </strong>are. But today, I’m going to discuss algorithm that needs much less processor power, but is able to give you amazing results in case of good data propagation and pre-processing. <br><strong>Tensorflow </strong>implementation with several techniques gives us ability to synthesize ordinary pictures with specific styles.</p><p>Let’s start with dependencies. <br>Some of you may not have installed all of the demanded dependencies, so that, to make sure everything’s going smoothly, I’m gonna start from zero.</p><h3>P.S. I’m mac user, so I’m gonna re-train the neural net on CPU.</h3><p>I’ve used this project couple of times, so to make sure I’m showing you everything from the beginning, I’m gonna do all the work in virtual environment (because I’ve installed all the dependencies earlier).</p><p>I’m gonna start with installing pip, homebrew, tensorflow, opencv. But, as I’ve installed them, I’m gonna show you the commands how you can do the same. it’s pretty easy, even if you’re starter.</p><h3>Requirements:</h3><p><strong>Pip: </strong>sudo easy_install pip<br><strong>Brew: </strong>pip install homebrew<br><strong>Tensorflow: </strong>pip install tensorflow<br><strong>OpenCV: </strong>pip install opencv-python</p><p>(In case of denying access, please just use administration privileges using “sudo” command. Example: <strong>sudo pip install homebrew</strong>)</p><p>After installing the dependencies, let’s check the environment by command <br><strong>pip freeze</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*Oz7mdz9w4EzuPgsZdz_ayQ.png" /></figure><p>Go to somewhere, for instance on Desktop, and make a new folder, let’s call it deepstyle. Enter the directory using the command: <br><strong>cd Desktop/deepstyle</strong></p><h3>Clone into the repository</h3><p>After all the dependencies are installed, and you’ve created new directory, lets go on github and clone the deepstyle repository from <a href="https://github.com/cysmith/neural-style-tf.git">https://github.com/cysmith/neural-style-tf.git</a> using the command:</p><p><strong>git clone </strong><a href="https://github.com/cysmith/neural-style-tf.git">https://github.com/cysmith/neural-style-tf.git</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3IBqRTEeeCGNf4K8ikZ6nw.png" /></figure><p>If everything’s going smoothly, then it’s ok. After cloning into repository, lets enter it’s directory: <br><strong>cd neural-style-tf</strong></p><h3>Pre-trained models</h3><p>The next step is to download the pre-trained models. We are going to synthesize one image into other, and as you know, two images are not enough data for AI. Lets go on the link : <a href="http://www.vlfeat.org/matconvnet/pretrained/">http://www.vlfeat.org/matconvnet/pretrained/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7kx5eoXOlP7aQP6MBn29eQ.png" /></figure><p>We should search for <strong>imagenet VGG-19</strong> pretrained model (imagenet-vgg-verydeep-19) weights. Just download it. It’s size is 534.9Mb so it may take a while. After downloading the file, just move it to the project directory (neural-style-tf folder) as it’s shown down.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p56sY5PS8hEivjCBkM3P6Q.png" /><figcaption><strong>Name of the file is imagenet-vgg-verydeep-19.mat</strong></figcaption></figure><h3>Input &amp; style images</h3><p>After all of this, we are almost done. Now, we need two images to extract style from one of them, and implement it into another one. Let’s keep it in a romantic way and imagine: what if <strong>Magda Eisenhardt</strong> (mother of <strong>Quicksilver</strong>)<strong> </strong>and <strong>Henry Allen </strong>(father of <strong>The Flash</strong>) met each other.<br>You guess it, let’s synthesize the images of <strong>The Flash </strong>and <strong>Quicksilver</strong>.</p><p>I’m gonna use the flash as a style, and implement it into image of quicksilver. One advice: use as accurate images of the faces as possible. If you’re using CPU and even more, it’s not so powerful, the neural net would find pretty hard to synthesize them. Thus, there might be some inaccuracies.</p><p>I’ve searched and downloaded their images, that I’m gonna show you in the next image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qyo-dW67FFeVe0WIhpKlfw.png" /><figcaption>Sources: SharkAttack.com &amp; Bustle.com</figcaption></figure><p>Copy the downloaded images to the project directory.<br>The image, which you’re using for input image should be copied into folder named <strong>“image_input”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lDpLJxC7NjFUimJybj72lg.png" /></figure><p>And the input image should be copied into folder named <strong>“styles”.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EudG1msTNG7KWdrYDcQ3Vg.png" /></figure><h3>Training (re-training)</h3><p>We’re all set. Lets go in terminal and run the following command:<br>Be sure you’re in the <strong>neural-style-tf </strong>directory.</p><p><strong>bash stylize_image.sh ./image_input/quicksilver.png ./styles/theflash.png</strong></p><p><em>The command stands for : bash stylize_image.sh ./&lt;input image directory&gt;/&lt;input image name&gt; ./&lt;styles image directory&gt;/&lt;styles image name&gt;</em></p><p>Press enter, it’ll ask you if you’ve installed required dependencies, just push “y” button on keyboard and press enter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vdj8KLWDGhGtNSNjrjOr_g.png" /></figure><p>After that, it’ll ask you for <strong>CUDA</strong> enabled GPU, but as I mentioned above, I’m a mac user, so I’ll press “n” button.</p><p>If something goes wrong, don’t be scared. It’s just happening because you’ve not installed all of the required dependencies. In my case, it was <strong>scipy </strong>library. <br>Just go on and use the command: <strong>pip install &lt;name of library&gt;<br></strong>In my case: <strong>pip install scipy</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yiZUvnGNi5A_VhPlErjvhA.png" /></figure><p>After installing the demanded library, just use the same command I’ve shown you above:</p><p><strong>bash stylize_image.sh ./image_input/quicksilver.png ./styles/theflash.png</strong></p><p>Here the magic happens:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IgiLrs4SiBcRB0PdXAz3kg.png" /><figcaption>The model is being re-trained on your input images</figcaption></figure><p>The process is not taking too long. The detailed info about how many iterations are made and how accurate is the image precision becoming will come up in terminal window like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*chCeZ4_Tg3yrBtKF_ZakNg.png" /></figure><p>The neural network needs <strong>1000 iterations</strong> to synthesize the images. Just wait for some time. For my <strong>MacBook Pro </strong>with <strong>2.2GHz i7 processor </strong>and <strong>16GB RAM </strong>that “some time” is about <strong>47.62306 minutes</strong>.</p><h3>The Result</h3><p>After the process is done, you’ll see the precision details and the elapsed time:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EQ6_zgEq_5w32jUK4yntOQ.png" /><figcaption>The process is done.</figcaption></figure><p>Here we go. Let’s go to the <strong>image_output </strong>directory and check the <strong>result </strong>folder. There we’ll see some files including the pre-processed image and metadata.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xozn4nH9tmCV4EQ6uS3r8g.png" /></figure><p>All we need here is the <strong>result.png</strong> .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*31jb6FsMfy_Zd26JQe0Xyw.png" /></figure><p>As we can see, the style of the flash’s image has been implemented into our input image.</p><p>It doesn’t have surprising accuracy, but the algorithm have done it’s job: it transfered the style from one image, to other.</p><p>You can use this neural net to transfer the styles from world-class painters into some people’s images, maybe yours, and it’s working pretty well.</p><h3><em>And, finally:</em></h3><p><em>If you find reading this post interesting, just press like and appreciate my work</em></p><p><em>I’d like to hear your feedback and questions below!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=499b39084827" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coinmonks/neural-style-transfer-using-tensorflow-in-python-499b39084827">Neural Style Transfer Using Tensorflow in Python</a> was originally published in <a href="https://medium.com/coinmonks">Coinmonks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>