<?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 otman heddouch on Medium]]></title>
        <description><![CDATA[Stories by otman heddouch on Medium]]></description>
        <link>https://medium.com/@otmanheddouchai?source=rss-e7d361ca183e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*2hywPPDu8ZkiR6IlL0GBHA.jpeg</url>
            <title>Stories by otman heddouch on Medium</title>
            <link>https://medium.com/@otmanheddouchai?source=rss-e7d361ca183e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 07:29:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@otmanheddouchai/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[Coin Sorter End-to-End Project]]></title>
            <link>https://medium.com/@otmanheddouchai/coin-sorter-end-to-end-project-49654ca3809a?source=rss-e7d361ca183e------2</link>
            <guid isPermaLink="false">https://medium.com/p/49654ca3809a</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[instance-segementation]]></category>
            <dc:creator><![CDATA[otman heddouch]]></dc:creator>
            <pubDate>Tue, 08 Sep 2026 01:16:33 GMT</pubDate>
            <atom:updated>2026-09-08T01:16:33.516Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, we will build a coin sorter using computer vision. The goal is to create an app that is able to sorter the moroccan coins and display the total in DIRAHAM.</p><p>The app is end-to-end from data collecting, experiment with different appreaches and models, analyse the results, pick the best one, deploy it to production and create pipeline for future training .</p><p>The entire code is available on my github repo <a href="https://github.com/otman-ai/coin-sorter">https://github.com/otman-ai/coin-sorter</a>.</p><h3>The Prototype</h3><p>We want to build an app that takes an image as input and returns the total quantity of each coin and their sum .To make sure our model is up to date and accurate over time, we want to create a ML pipeline that automate the training, testing and deploying the model and repeating this process based on the trigger .</p><p><em>LET DO IT !</em></p><h3>Proposed Approaches</h3><p>Deep learning is all about expirements, and that is what we are going to do . We will expirement with three different approaches: first, we want to see how will sementic segmentation is doing , second, what if we run Segment Anything Model on input image with an appropriate prompt and then run a classifier model.The last approach, is object detection . The best approach will be selected based on many criterions such as the speed inference and the accuracy.</p><h3>Data Collection</h3><p>There are 6 unique coins in Morocco, 10 DH, 5DH, 1DH, 0.5DH, 2DH, 0.2DH and 0.1DH. We are going to be working with only 4 since I can’t find 0.1D and 2DH .W have collected 76 images of different coins, light, places and sides (since each coin has two sides) since we want our model to be accurate and more generalized.</p><p>We captured several images using my phone and the coins that I have . The dataset is very diverse covering different coins, light conditions, places and quantity.</p><p>We have annotated the images for sementic segmentation, object detection tasks to test with different approaches. The dataset is made public and it is available on <a href="https://www.kaggle.com/datasets/otmanheddouch/moroccan-coins-segementation-and-object-detection">Kaggle</a>. For the classifer task there is already a public dataset on Kaggle <a href="https://www.kaggle.com/datasets/oussamaouardini/moroccan-money-dataset">Moroccan Money dataset | Kaggle</a> .</p><p>Roboflow helped us annotate the image with auto-labeling feature and applying data augmentation without coding it from scratch. We have applied flip, saturation, brightness and noises . This leave us with 184 images in total, not much but it is a good start .</p><p>You can find the dataset here -&gt; <a href="https://universe.roboflow.com/otman-heddouch-zsoii/moroccan-coins-sementic-object-detection/dataset/1">https://universe.roboflow.com/otman-heddouch-zsoii/moroccan-coins-sementic-object-detection/dataset/1</a></p><h3>Expirements</h3><p>With the help of W&amp;B platform, we use it to track our metrics.</p><h3>YOLOV11 Segmentation</h3><p>We first start expirement with YOLOv11 segmentation model, we have trained it on Google Colab GPU for 100 epochs, we have achieved mAP 0.97% in box and mask . For the loss, during training the loss is decreasing to 0.11% in segmentation, 0.3% in classes and 0.14% in boxes. During validation phase, the model achieved 0.17% in segmentation, 0.35% in classes and 0.15% in boxes(see fig below)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*GxwQwym0WtBiuCPu2NEcIg.png" /></figure><p>We have plotted confusion matrix to see where the model is confused(fig below)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o0QnYx2LbY-BmrBYZhcyYQ.png" /></figure><p>The 1DH ,0.5DH and 5DH coins are all in silvere, this explain why sometimes the model find it hard to distinguish between the three classes .</p><h3>Segment Anything</h3><p>Segment Anything performs poorly on our task and it can’t distinguish between the coin and its components like the 5DH coin has two circeles one inside another . So without explicitly give it a prompt like points of the object(fig below is the results of SA without a prompt), it will not perform well .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/1*kO9VTBegVesCdLMeV0P9IA.png" /></figure><h3>Mask R-CNN</h3><p>We have trained Mask R-CNN for one epoch since we cant go furhter because of GPU limitation on Google Colab but still managed to get a good results but there are not good as YOLOV11 segmentation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/579/1*0L_BFFXETDAackIiS3egJQ.png" /></figure><p>Mask R-CNN performs very well on validation dataset even with only one epoch compare to YOLOV11 with 100 epoches. However, what makes R-CNN bad choice is the speed and the memory needed to do such task. YOLOv11 has trained on 100 epoches with the Free GPU on Google Colab just fine in less then 10 minutes but Mask R-CNN takes about 2 minutes for the first epoch then we got hit by the GPU memory limitation error hence no more training unless we deleted the runtime and re-run again .</p><h3>Inference</h3><p>We load our models including YOLOv11 and Mask R-CNN and YOLOv11 performs very well on inference images but Mask R-CNN didnt recognize the coins well (all the objects were classified as one)</p><h3>Conclusion</h3><p>After we have tested several algorithms, YOLOv11 is the best, combining speed and accuracy while it have trained on a small dataset making it the best for our usecase .</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49654ca3809a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to be Computer Vision engineer]]></title>
            <link>https://medium.com/@otmanheddouchai/how-to-be-computer-vision-engineer-26d0bc09ab85?source=rss-e7d361ca183e------2</link>
            <guid isPermaLink="false">https://medium.com/p/26d0bc09ab85</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[learn]]></category>
            <category><![CDATA[engineering]]></category>
            <dc:creator><![CDATA[otman heddouch]]></dc:creator>
            <pubDate>Wed, 18 Jun 2025 21:44:43 GMT</pubDate>
            <atom:updated>2025-06-18T21:44:43.759Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*S7U3-Era1FXyM2_9" /><figcaption>Photo by <a href="https://unsplash.com/@vackground?utm_source=medium&amp;utm_medium=referral">vackground.com</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>As Artificial Intilligence continue to explode, companies and businesses are looking for talented people to help them intigrate AI into their businesses .</p><p>One of the fasicanting field in AI is computer vision .</p><p>But how would I learn computer vision in 2025 ?</p><p>In this article I will breakdown the steps to learn and master the field .</p><h4>Maths</h4><p>I would start with the basic maths of computer vision : Calculus, Algebra, Statistics and Probability .<br>Learning these would help you have a solid understanding and you wont struggle learning the other theories of computer vision as these are the backbones of the field .</p><h4>Python</h4><p>Next, I will need to learn Python. Start with the basics such as variables, functions, classes.<br>When you have master these you can jump to machine learning libraries like Pandas, NumPy, Matplotlib and OpenCv .<br>These libraries are essential as it will save you a lot of time .</p><h4>Learn Basic Modeling.</h4><p>How can you train a machine learning model ? How to evaluate it ? How to make inference ? How to work with different datasets ? How to deploy it to production ?<br>I would suggest to learn about sickit-learn library . It has many built in machine learning architectures such as Linear regression, Random forests, Logistic regressions just to name a few ! <br>You can import and use them right a way</p><p>Now you will move to the next level.</p><h4>Learn about Neural Network</h4><p>Dive into neural Network, theory behind it , try to implement it from scratch using NumPy only . Build models for real use cases and try to play around with the parameters and see what works best .<br>Learn about different activation functions, back propagations. <br>If you can try implement everything from scratch that will be extra .</p><p>Now pick a deep learning framework like Pytorch or Tensorflow .</p><p>I would suggest Pytorch as many state-of-the-art models built using Pytorch such as GPT .<br>Learn the basics of the framework and try to get used to it .</p><h4>Explore CNN architecture</h4><p>How deos it works ? Use it to build mini projects such as hand digits recognition and animal classification .</p><p><em>Bonus</em> : Dont stuck on watching tuto, create your own projects and for each project you finish, try to deploy it to production and create documentation on how to use it .</p><p>Dont be selfish, when you have figure something new share it on public, someone may stuck and you have just helped them .</p><p>Read papers , implement them , create articles, conduct experiments on different models and publish your findings.</p><p>You have be more curious and hungry for knowledge . <br>Make sure you learn something new everytime, there is no end line in learning .</p><p>Remember, this field is all about experiment.<br>What work for other people deos not necessary means it will work for you . Them are not you , test by yourself and see what work and what didn’t</p><p><em>EXPERIMENT ,EXPERIMENT, EXPERIMENT !</em></p><p>And that is it , I hope you have find something useful here .</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26d0bc09ab85" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Summerize YOLOv8 paper]]></title>
            <link>https://medium.com/@otmanheddouchai/summerize-yolov8-paper-43adde4529f6?source=rss-e7d361ca183e------2</link>
            <guid isPermaLink="false">https://medium.com/p/43adde4529f6</guid>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[object-detection]]></category>
            <category><![CDATA[yolo]]></category>
            <dc:creator><![CDATA[otman heddouch]]></dc:creator>
            <pubDate>Mon, 16 Jun 2025 21:32:31 GMT</pubDate>
            <atom:updated>2025-06-16T21:32:31.433Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*_vlLYALl6h_d4GgQH0P8BQ.png" /><figcaption>from <a href="https://visionplatform.ai/object-detection/">https://visionplatform.ai/object-detection/</a></figcaption></figure><p>Introduced in 2023 by <a href="https://docs.ultralytics.com/models/yolov8/">Ultralytics</a> , <a href="https://arxiv.org/abs/2305.09972">YOLOv8</a>, a family of You Only Look once and state-of-arts objects detection model . A real-time flying objects detection that can be used for transfer learning and further research. The model was trained on 40 different classes of flying objects, forcing the model to learn more abstract features . Transfer learning then applied on more data set with real world envirements such as rotation, small objects and so on .</p><p>Detecting Flying objects remains challenging due to variances in object size, speed of the inference and changing the location quickly. By solving this issues, we will have a SOTA objects detection model. Researchers and engineers can fin-tuning the model on their use cases and produce a model that is capable of detecting objects accurately regarding their variances .</p><p>The model first was trained on data set comprised of 15,064 images with various flying objects : drones, bird, p-airline and c-helicopter . The second times, transfer learning is applied to refine the model on different data set with flying objects at noticeably further distance then the first one .</p><p>YOLOv8 follow the same architecture as its predecessors, but it introduced numerous improvement such as the introducing of a new neural network that combines Feature Pyramid Network and Path Aggregation Network and auto labeling tools .</p><p>FPN works by gradually reducing the input image while increasing the number of feature channels .</p><p>In the other hand we have PAN that combines the features from a different levels (that was produced by FPN) . With this architecture, we have a model that is able to capture features at multiple scales (see the figure below) .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/593/1*s7Yl91NRkSsqGgGkYN3dkg.png" /><figcaption>PAN and FPN architecture</figcaption></figure><p>YOLOv8 architecture is from <a href="https://arxiv.org/abs/1506.02640">You Only Look Once: Unified, Real-Time Object Detection</a> which I have summarize <a href="https://medium.com/@otmanheddouchai/summary-of-you-only-look-once-unified-real-time-object-detection-yolov1-70fb0fafaea1?source=user_profile_page---------0-------------e7d361ca183e----------------------">here</a> .</p><p>To refine the detection results, YOLOv8 uses Soft-NMS which is a variance of NMS (Non-Max Suppression) .</p><p>For data augmentation, Ultralytics incoperate Mosaic data augmentation on the training data to enhance the model’s ability to recognize objects on various contexts . In our case, we take four random images from the training data set and combine them into a single mosaic image .</p><p>To learn more about how YOLO works behind the scenes, I have already explain it here -&gt; <a href="https://medium.com/@otmanheddouchai/summary-of-you-only-look-once-unified-real-time-object-detection-yolov1-70fb0fafaea1?source=user_profile_page---------0-------------e7d361ca183e----------------------">https://medium.com/@otmanheddouchai/summary-of-you-only-look-once-unified-real-time-object-detection-yolov1-70fb0fafaea1?source=user_profile_page---------0-------------e7d361ca183e----------------------</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=43adde4529f6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Segement Anything]]></title>
            <link>https://medium.com/@otmanheddouchai/segement-anything-8c58161ac972?source=rss-e7d361ca183e------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c58161ac972</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[segement-anything]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[instance-segementation]]></category>
            <dc:creator><![CDATA[otman heddouch]]></dc:creator>
            <pubDate>Sun, 08 Jun 2025 18:24:46 GMT</pubDate>
            <atom:updated>2025-06-08T18:45:39.517Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://arxiv.org/abs/2304.02643">Segment Anything</a> is state-of-the-art sementic segementation that was introduced in 2023 by Meta .</p><p>Segement Anything identify which image pixels belong to an object . One of the challenging tasks in computer vision and it used on various application from medical imaging, object detection, data annotation to editing photos .</p><p>Segement Anything has trained on <a href="https://ai.meta.com/micro_site/url/?click_creative_path[0]=section&amp;ums_creative_detail=section&amp;click_from_context_menu=true&amp;country=MA&amp;destination=https%3A%2F%2Fai.facebook.com%2Fdatasets%2Fsegment-anything%2F&amp;event_type=click&amp;last_nav_impression_id=172QoscdYDt9e3yya&amp;max_percent_page_viewed=97&amp;max_viewport_height_px=792&amp;max_viewport_width_px=1592&amp;orig_http_referrer=https%3A%2F%2Fgithub.com%2Ffacebookresearch%2Fsegment-anything&amp;orig_request_uri=https%3A%2F%2Fai.meta.com%2Fblog%2Fsegment-anything-foundation-model-image-segmentation%2F&amp;primary_cmsid=593423119509660&amp;primary_content_locale=en_US&amp;region=emea&amp;scrolled=true&amp;session_id=0EtekgzmrLJf9JSK6&amp;site=meta_ai&amp;extra_data[create_type]=section&amp;extra_data[create_type_detail]=section&amp;extra_data[creative_detail]=section">SA-1B dataset</a>, the largest ever segmentation dataset .</p><h3>How it works ?</h3><p>Segement anything returns a valid segmentation mask for any prompt, where a prompt can be a box, mask, freeform text or even foreground/background points</p><p>Under the hood, the input image is encoded to an image embedding using Mask AutoEncoder (MEA) and pre-trained vision transformers (ViT) .</p><p>The first part in image encoder is MEA. The input image is splited into different patches (Patch embedding) using Convolution layer then we added it to position embedded to retain the positional informations .The second part is Vision transformers ;</p><p>For the prompt which can be text, box or points are encoded to an embedding vector. The two information are combined in lightweight mask decoder that produces a valid masks with the confidence score each . A valid masks means even if the prompt is ambigious and refer to multiple objects, the outputs should be reasonable mask for at least one of the objects .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wkrLAJwrN1o7TmH4" /><figcaption>source : <a href="https://ai.meta.com/blog/segment-anything-foundation-model-image-segmentation/">https://ai.meta.com/blog/segment-anything-foundation-model-image-segmentation/</a></figcaption></figure><p>SAM has trained on a high quality dataset contain over 1 billion masks .</p><p>What makes SAM achieve strong generalization is “data engine” solution. This solution used SAM to interactively annotate images, and then the newly annotated data used to update SAM in turn .</p><p>Right now this model is used in almost every data labelling platforms to automate labeling such as <a href="https://roboflow.com/model/segment-anything-2">Roboflow</a> .</p><h4>More resources:</h4><ul><li><a href="https://ai.meta.com/blog/segment-anything-foundation-model-image-segmentation/">https://ai.meta.com/blog/segment-anything-foundation-model-image-segmentation/</a></li><li><a href="https://medium.com/@fernandopalominocobo/demystifying-visual-transformers-with-pytorch-understanding-patch-embeddings-part-1-3-ba380f2aa37f">https://medium.com/@fernandopalominocobo/demystifying-visual-transformers-with-pytorch-understanding-patch-embeddings-part-1-3-ba380f2aa37f</a></li><li><a href="https://roboflow.com/model/segment-anything-2">https://roboflow.com/model/segment-anything-2</a></li><li><a href="https://arxiv.org/abs/2111.06377">https://arxiv.org/abs/2111.06377</a></li><li><a href="https://www.youtube.com/watch?v=eYhvJR4zFUM">https://www.youtube.com/watch?v=eYhvJR4zFUM</a></li><li><a href="https://arxiv.org/abs/2304.02643">https://arxiv.org/abs/2304.02643</a></li><li><a href="https://segment-anything.com/">https://segment-anything.com/</a></li><li><a href="https://github.com/facebookresearch/segment-anything">https://github.com/facebookresearch/segment-anything</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c58161ac972" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Image Segementation]]></title>
            <link>https://medium.com/@otmanheddouchai/what-is-image-segementation-66bfcbd10949?source=rss-e7d361ca183e------2</link>
            <guid isPermaLink="false">https://medium.com/p/66bfcbd10949</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[deeplab]]></category>
            <category><![CDATA[image-segmentation]]></category>
            <category><![CDATA[deeplabv3]]></category>
            <category><![CDATA[image-processing]]></category>
            <dc:creator><![CDATA[otman heddouch]]></dc:creator>
            <pubDate>Mon, 19 May 2025 20:31:37 GMT</pubDate>
            <atom:updated>2025-05-19T20:31:37.297Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dJv3ujCS4EfL_crZOUvocg.jpeg" /><figcaption>from <a href="https://viso.ai/wp-content/uploads/2021/03/image-segmentation-background.jpg">image-segmentation-background.jpg (1060×706)</a></figcaption></figure><p><strong>Image Segmentation</strong> is one of the computer vision tasks where the image is deviding into different regions . This task is very used in background removal, green screen , self-driving cars, aiding diagnosis in medical imaging and so much more .</p><p>There are three types of image segementation :</p><p><strong>Sementic Segmentation</strong> : devide the image into different regions where ever pixel is assigned to class label</p><p><strong>Instance Segmentation</strong> : just like object detection but instead of bounding boxes we have the mask of the objects meaning differentiate each object from another</p><p><strong>Panaptic Segmentation</strong> : combine sementic segmentation with instance segementation</p><p>Lets take more about Sementic Segmentation :</p><p>The goal of sementic segmentation is to assign sementic labels (person, dog, etc) to every pixel in the input image .</p><p>There are many open source models that do this task in a different ways like Segement Anything by Meta , DeepLab by Google , etc.</p><p>In Sementic segementation architecture, it takes image as input and it categories it to pre-determined classes, so it is like image classfication task but instead of assigning the entire image to one label , we want to do it for every pixel in the image .</p><p>DeepLab utilze Atrous convolution (dilatec convolution), unlike standard convolution , the filter of atrous convolution is applied with gaps between the filter elements . One might assume that this could lead to missing the imporant features. However, the gaps allows to capture multi-scale contextual information and this useful in sementic segmentation .</p><p>The model architecteur is from VGG-16 without Dense layer as it is not designed to perform upsampling .</p><p>The model ouput tensor with shape [W,H,C] where W is the width, H is the height and C is the number of class labels. Applying argmax function to get the class with highest probability , this leave us with [W, H, 1] . then cross entropy to calculate the loss with the ground thruths .</p><p>Segmentation has three components, Convolution to capture spatial information, downsampling using convolution striding or pooling operation to reduce the spatial dimensions of the feature maps and upsampling to reconstructe the output to be the same dimension as the input.</p><p>Usually upsampling layers is based on atrous convolution with different dilation rates .</p><p>After sementic segmentation is done, DeepLab uses CRF post-processing to refine the segmentation and sharpen the object bounderies .</p><p>Resources:</p><ul><li><a href="https://sthalles.github.io/deep_segmentation_network/">https://sthalles.github.io/deep_segmentation_network/</a></li><li><a href="https://viso.ai/deep-learning/deeplab/">https://viso.ai/deep-learning/deeplab/</a></li><li><a href="https://arxiv.org/pdf/1606.00915">https://arxiv.org/pdf/1606.00915</a></li><li><a href="https://arxiv.org/pdf/1411.4038">1411.4038</a></li><li><a href="https://medium.com/@saba99/deeplab-095f387f891f">DeepLab. DeepLab is a family of convolutional… | by Saba Hesaraki | Medium</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66bfcbd10949" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is an OCR]]></title>
            <link>https://medium.com/@otmanheddouchai/what-is-an-ocr-5a7e6f98fc92?source=rss-e7d361ca183e------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a7e6f98fc92</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[image-processing]]></category>
            <category><![CDATA[ocr]]></category>
            <category><![CDATA[optical-character-recogn]]></category>
            <dc:creator><![CDATA[otman heddouch]]></dc:creator>
            <pubDate>Thu, 15 May 2025 15:20:16 GMT</pubDate>
            <atom:updated>2025-05-15T15:20:16.995Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is an OCR ?</h3><p>OCR stand for Optical Character Recognition is the process of identify and extract the text from the image using artificial neural network .</p><h3>How it works ?</h3><p>There many algorithms of OCR but of of them is <a href="https://arxiv.org/pdf/1507.05717v1">Image-based Sequence Recognition</a> . In the paper they use Architecture called CRNN, consist of three parts: 1) convolutional layers, which extract a feature sequence from the input image; 2) recurrent layers, which predict a label distribution for each frame, meaning we have set of all the characters we want our model to know like : a, b, c, …z?!^$ ,etc. 3) transcription layer : translate the per-frame prediction into the final label sequence (final text) .</p><h3>Feature Extraction</h3><p>The first layer in the CRNN model, feature extraction construct of convolution and max-pooling layers. These components used to extract a sequencial feature representation from the input image .</p><p>The input image first resized to fixed dimenstion before feeding it to the network. Convolution and max-pooling layers extract feature vectors that will be feeded to the next layer (recurrent layers)</p><h3>Sequence Labeling</h3><p>A deep bidirectional recurrent layer is used in this phase (LSTM).</p><p>This layer predict label distrubition for each frame in the feature sequence by convolution layers.</p><h4>Why LSTM ?</h4><p>LSTM is type of recurrent neural network , which is a powerful for capturing contextual information within a sequence . LSTM allows the previous outputs to be used as inputs while having hidden state that decides what to store and what to forget since we have sequence of features that needs the context to perfom better at label distrubition .</p><h3>Transciption</h3><p>After having sequence of label distributions, we need something that convert this inputs to text . By finding the label sequence with highest probability conditioned on the per-frame prediction , remove blanks and repeated characters, then we decode the character index to its character name until we have the final results .</p><p>And that is how OCR works .</p><p>Resources:</p><ul><li><a href="https://stanford.edu/~shervine/teaching/cs-230/cheatsheet-recurrent-neural-networks">https://stanford.edu/~shervine/teaching/cs-230/cheatsheet-recurrent-neural-networks</a></li><li><a href="https://arxiv.org/pdf/1507.05717v1">1507.05717v1</a></li><li><a href="https://www.youtube.com/watch?v=AsNTP8Kwu80">Recurrent Neural Networks (RNNs), Clearly Explained!!!</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a7e6f98fc92" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What are Diffusion models ?]]></title>
            <link>https://medium.com/@otmanheddouchai/what-are-diffusion-models-baabdc66b132?source=rss-e7d361ca183e------2</link>
            <guid isPermaLink="false">https://medium.com/p/baabdc66b132</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[diffusion-models]]></category>
            <dc:creator><![CDATA[otman heddouch]]></dc:creator>
            <pubDate>Sun, 11 May 2025 19:46:03 GMT</pubDate>
            <atom:updated>2025-05-11T19:46:03.549Z</atom:updated>
            <content:encoded><![CDATA[<h3>What are Diffusion models ?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/915/1*z0lvFGLl4OhAMpVngAuAIg.png" /><figcaption>DIffusion models</figcaption></figure><p>Diffusion models or diffusion probabilistic models are generative models, they generate data similar to what they have trained on . It consist of three componenets, forward proces which destroys the training images by adding Gaussain noises, reverse process which learns to recover the data by reversing the noising process and sampling procedure.</p><p>We start with the image without noises, we gradually adding Gaussian noise to the image from t=1 to t=T given B the variance schedule which is how much noise we will add at each step. This called forward process or diffusion process .</p><p>The reverse process is what we want the model to learn .</p><p>So during training process, we pick the image , we add B of noise, the output is feeded to the model to undo it, we add again some noise to the previous noise image , we give it to the model to undo it,so we gradually remove noises until we end back at what the network think the original image was .</p><p>So the problem is how we do the “undo it” process ? in diffusion models, we use encoder network where we feed the noisy image at given t : xt, to the network to predict the noise that where added , we subsctract xt with the prediction to get the image back as it was at t=0, we add back the guassian noises, we feed it to the network and we do this for T times .</p><h3>What about the involvement of text in diffusion models ?</h3><p>There are a lot of how you can represent the text with in a diffusion models but one of the best one is called CLIP (Contrastive Language-Image Pre-Training) by OpenAI.</p><h3>How CLIP works ?</h3><p>CLIP is neural network that represent the correct pairing of text and image in the space by combining Vision Transformers to encode the image and Transformers to encode the text .</p><h3>Then ?</h3><p>The embeded text is feeding to the network along with the noisy image .</p><p>AND that is how diffusion models works .</p><p>This is just the surface of diffusion models, to dive deep into it i recommand these resources:</p><ul><li><a href="https://arxiv.org/pdf/2006.11239">2006.11239</a></li><li><a href="https://www.assemblyai.com/blog/diffusion-models-for-machine-learning-introduction">https://www.assemblyai.com/blog/diffusion-models-for-machine-learning-introduction</a></li><li><a href="https://en.wikipedia.org/wiki/Diffusion_model">Diffusion model — Wikipedia</a></li><li><a href="https://www.youtube.com/watch?v=1CIpzeNxIhU&amp;pp=ygUeZGlmZnVzaW9uIG1vZGVscyBjb21wdXRlcnBoaWxl">https://www.youtube.com/watch?v=1CIpzeNxIhU&amp;pp=ygUeZGlmZnVzaW9uIG1vZGVscyBjb21wdXRlcnBoaWxl</a></li><li><a href="https://www.youtube.com/watch?v=-lz30by8-sU&amp;pp=ygUeZGlmZnVzaW9uIG1vZGVscyBjb21wdXRlcnBoaWxl">https://www.youtube.com/watch?v=-lz30by8-sU&amp;pp=ygUeZGlmZnVzaW9uIG1vZGVscyBjb21wdXRlcnBoaWxl</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=baabdc66b132" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Summary of You Only Look Once: Unified, Real-Time Object Detection (YOLOv1)]]></title>
            <link>https://medium.com/@otmanheddouchai/summary-of-you-only-look-once-unified-real-time-object-detection-yolov1-70fb0fafaea1?source=rss-e7d361ca183e------2</link>
            <guid isPermaLink="false">https://medium.com/p/70fb0fafaea1</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[yolo]]></category>
            <category><![CDATA[object-detection]]></category>
            <dc:creator><![CDATA[otman heddouch]]></dc:creator>
            <pubDate>Mon, 10 Feb 2025 11:55:11 GMT</pubDate>
            <atom:updated>2025-02-11T17:34:24.337Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="You Only Look Once Logo" src="https://cdn-images-1.medium.com/max/1024/1*bSLNlG7crv-p-m4LVYYk3Q.png" /></figure><p>In this article we will summeries everything in <a href="https://arxiv.org/abs/1506.02640"><em>You Only Look Once: Unified, Real-Time Object Detection</em></a><em> </em>paper which is a state-of-the-art object detection that was introduced in 2016 . <em>YOLOv1 </em>is extremly fast and it can processes images in real-time at 45 frames per second . Another small version of the network, <em>Fast YOLO </em>processes 155 frames per second . YOLO makes more localization errors but is less likely to predict false positives on the background compare to other approachs .</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FMPU2HistivI%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DMPU2HistivI&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FMPU2HistivI%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/783d25819023d1628fdddf97100fd0e7/href">https://medium.com/media/783d25819023d1628fdddf97100fd0e7/href</a></iframe><p>Current detection systems use complex pipeline that are slow and hard to optimize . The traditional methods use sliding window over the image and generate potential bounding boxes in an image and then run a classifier on these proposed boxes . Then refine the bounding boxes and eliminate duplicate detections . With this approach , each individual component must be trained seperately compared to YOLO. A single convolution network uses the image to predict multiple bounding boxes and class probabilities for those boxes.</p><h3>Unified Detection</h3><p>All the seperate components of object detection is unified into a single neural network . The network sees the entire image and predict each bounding box across all the classes simultaneously. This helps the network to understind the context and to reason globally the full image .</p><h4>How deos it work ?</h4><p>The system divides the input image into an <em>S x S</em> grid ( in this case<em> S=7</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/849/1*VR9dd4ya6onSmQuj8sKsww.png" /><figcaption>Yolo steps</figcaption></figure><p>Each grid cell has <em>B (B = 2) </em>bounding boxes and their confidence score and class probability of all the labels <em>C (C = 20)</em>. The confidence score reflect how confident the model is that box contains the object. For class probability, it’s the probability of that label being in that grid cell.</p><h3>Deep Down Inside the network</h3><h4>Inferencing</h4><p>The model is implemeneted as convolution neural network and evaluated on PASCAL VOC detection dataset . The model learns to predict <em>S </em>x <em>S </em>x <em>(B ∗ 5 + C)</em>, where S = 7 , B = 2 and C = 20 (20 labels). For B, it consists of 5 predictions, <em>x, y, w, h</em> and <em>c. </em>So our final prediction is 7 x 7 x 30 tensor .</p><p>All the final tensor is just numbers , so we need to extract the real values .</p><p>First we extract the predictions probability of each class of each bounding boxes :</p><p><em>P(Class)=P(Class∣Object)×Confidence Score</em></p><p>where <em>P(Class∣Object) </em>is the predicted probability . Now we have 20 probabilities for each bounding boxes. Filter each probability by a <em>threshold . </em>Then for each class , we get the bounding box with highest probability . Now, across all the <em>S x S </em>grid cells we get multiples predictions of the same object, to remove the duplicate boxes, we apply <a href="https://medium.com/analytics-vidhya/non-max-suppression-nms-6623e6572536">Non-max suppression</a> .</p><h4>Training</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ySGu1s0hrh-7je1HEvMQig.jpeg" /><figcaption>The architecture of YOLO</figcaption></figure><p>The system was pretrained on ImageNet 1000-class dataset. 20 convolution layers followed by averge-pooling layer and fully connected layer . The network trained for approximatly a week and acheived the top-5 accuracy of 88% on ImageNet 2012 validation set. The model then converted to perform detection , the input dimension was 228 x 228 x 3 in classification task and 448 x 448 x 3 in detection since it requires fine-grained visual information . For activation function , Leaky Rectified Linear activation was used .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/358/1*--gzvu6IEkfJ8kNnxAEfZQ.png" /><figcaption>LRL Activation function</figcaption></figure><p>For loss function, sum-square error was applied . It is easy to optimize, however it deos not perfectly align with the goal of maximizing the average precision. In every image many grid cells do not contain any object, this pushes the confidence score towards zero. This leads to model instability . To remedy this, we use two parameters, <em>λcoord=5</em> to<em> </em>increase the loss of bounding box predictions. <em>λnoobj = 0.5</em> to decrease the loss from confidence score for grid cells that don’t contain no objects.</p><p>Another issue is, sum-square error equally the error of large boxes and small boxes. Instead we want to make the small error of large boxes matter less then in small boxes. To address this, we use square root of bounding boxe width and height instead of raw width and height .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OhGlZdorUtHvf53PybvnWg.jpeg" /><figcaption>Sum-square error in YOLO</figcaption></figure><p>where <em>1obj i</em> denotes if object appears in cell <em>i</em> , <em>1obj ij</em> denotes that the <em>j</em>th bounding box if object appears cell <em>i</em> and <em>1noobj ij </em>denotes that the <em>j</em>th bounding box if no object appears cell <em>i .</em></p><p>The network trained for 135 epochs on training and validation dataset from PASCAL VOC 2007 and2012 with batch size of 64 and momentum of 0.9 and a decay 0.0005 . Dropout of 0.5 and extensive of data augmentation used to avoid overfitting .</p><h3>Comparison to other Object Detection Systems</h3><p>There are other top object detection systems that uses different approaches .</p><p><strong>DPM(Deformable part methods)</strong> uses sliding window approach. DPM involves different pipelines, extracting features, classify region, predict bounding boxes for high scoring region, etc. In <strong>YOLO</strong> all this can be summaries in a single convolution network making it more efficient? fast and easy to optimized then <strong>DPM .</strong></p><p>R-CNN, uses region proposal to find objects in the image, run Selective Search to generate bounding boxes, convolution network to extract the features , SVM scores the boxes, a linear model adjust the bounding boxes, etc . Each stage need to be trained separately and the resulting system is very slow , taking more then 40 seconds per image at test time .</p><p><strong>YOLO </strong>and<strong> R-CNN </strong>share some similarity, each grid cell proposes potential bounding boxes and score those boxes using convolution network . However in <strong>YOLO, </strong>there is only 98 bounding boxes which is far from Selective Search that proposes 2000 bounding boxes, in addition to the rest components of R-CNN is combined individually in a single convolution network in <strong>YOLO</strong> .</p><h3>Expirements</h3><h4>Comparison to Other Real-Time System</h4><p>The detector systems below have trained on PASCAL dataset . The table below compares the performance and speed .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*5oDazElsWGcYVW0DVeSyhg.png" /><figcaption>Real-Time Systems on PASCAL VOC 2007</figcaption></figure><p><em>Sadeghi et al</em> is produces DPM and it is the only detection system that runs in real-time of 30 frames per second with 16% mAp on 100Hz, 100 fps and 26.1% on 30Hz . Fast YOLO is the fastest model on PASCAL, reaching 155 fps and 52.7% on mAP. Fast R-CNN takes a significant accuracy of 73.2% mAP while still fall short of real-time .</p><h4>VOC 2007 Error Analysis</h4><p>Since Fast R-CNN is the only detector that made 70% mAP on PASCAL , we will compare it to YOLO .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*adeiPfhR2U-hKwupCUnQlA.png" /><figcaption>Localization and background error of the top N prediction</figcaption></figure><p>As you can see in the chart above, Fast R-CNN makes more correct prediction of 71.6% then YOLO. However Fast R-CNN is likely to predict false positive(background) as it is 13.6% of its prediction. YOLO on other hand struggles to localize the object correctly .</p><h4>Combining Fast R-CNN and YOLO</h4><p>YOLO makes less background errors and with Fast R-CNN predict the correct localization, if we combine the two, we get a significant performance .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/635/1*dvC6FS1poc6RpKXTHgmLPw.png" /><figcaption>Model combinition expirement on VOC 2007</figcaption></figure><p>The best combination is Fast R-CNN and YOLO, you can see the mAP increase by 3.2% to 75% . Other combinations with other version of Fast R-CNN produce a small increase in mAP between 0.3% and 0.6% which makes the ideal one is Fast R-CNN with YOLO. However, this combination doesn’t benefit from the speed of YOLO. Each model is runining seperatly and then combine the results and this doesn’t add any signifant computational time compared to Fast R-CNN .</p><h4>VOC 2012 results</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vmExCvHj-manmshSz6N1mg.png" /><figcaption>Object detection Leaderboard</figcaption></figure><p>YOLO scores 57.9% mAP on VOC 2012 results . It is lower then the current state-of-the-art. Fast R-CNN + YOLO is one of the highest performance in the leaderboard by taking the 4th spot .</p><p>YOLO is the only real-time detection in the leaderboard</p><h4>Generalizability: Person Detection in Artwork</h4><p>We compare YOLO to other detection systems on two dataset of person, People-Art and Picasso .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*GirvUn7lGR9xN0Abb0E1Lg.png" /><figcaption>Results of detection systems on VOC 2007, Picasso and People-Art dataset</figcaption></figure><p>YOLO has the highest AP in VOC 2007 , and it is decreasing when applied to artwork such as Picasso and People-Art, thus YOLO can still predict well on artwork compared to other systems. R-CNN drops significantly when applied to artwork. The reason behind this, is R-CNN uses region proposal which is tuned for natural images .</p><h3>Conclusion</h3><p>YOLO, a unified model for object detection. Fast, accurate and can perform well on different uses cases, making it one of the best object detection out their .</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=70fb0fafaea1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Summary of ImageNet Classification with Deep Convolution Neural Networks paper]]></title>
            <link>https://medium.com/@otmanheddouchai/summery-of-imagenet-classification-with-deep-convolution-neural-networks-paper-8ea67ee16b34?source=rss-e7d361ca183e------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ea67ee16b34</guid>
            <category><![CDATA[aipapersummary]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[imagenet]]></category>
            <category><![CDATA[convolutional-network]]></category>
            <dc:creator><![CDATA[otman heddouch]]></dc:creator>
            <pubDate>Wed, 05 Feb 2025 16:45:19 GMT</pubDate>
            <atom:updated>2025-02-05T16:51:50.494Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="ImageNet’s Architechture" src="https://cdn-images-1.medium.com/max/827/1*jHGIiTjG3hHuXyG728Yrdg.png" /><figcaption>source : <a href="https://courses.cs.duke.edu/compsci527/spring19/papers/Krizhevsky.pdf">ImageNet Classification with Deep Convolution Neural Networks paper</a></figcaption></figure><p><a href="https://proceedings.neurips.cc/paper/4824-imagenet-classification-with-deep-convolutional-neural-networks.pdf">ImageNet Classification with Deep Convolution Neural Networks paper</a> introduced in 2012 By Alex Krizhevsky, Ilya Sustsker and Geoffrey E.Hinton . They trained a large, deep convolution neural network to classify the 1.2 milltion high-resolution images in the ImageNet LSVRC-2010 contest into 1000 different classes and they have acheived remarkable results which will discusse early .</p><h3>Introduction</h3><p>Building high accurate object recognition model is one of the most challanging task in deep learning. Given the amount of data and hardware needed to collect and train the model , making it very hard and expensive to do . However the scientists behind this research did their best to overcome those challenges .</p><p>The architechture discussed in this paper trained on the largest convolutional neural networks to 2012 data on subset of ImageNet used in the ILSVRC-2010 and ILSVRC-2012 competitions and acheived by far the best results ever reported (in 2012) .</p><p>The data have trained between five and six days on two GTX 580 3GB GPUs . This suggests that the results obtiened can be imporved simply by waiting for faster GPUS and bigger datasets to become available .</p><h3>The Dataset</h3><p>ImageNet dataset contains over 15 million labeled high-resolution images belonging to roughly 20.000 classes . In 2012 ImageNet Large-Scale Visual Recognition Challenge has been held. The competition used a subset of ImageNet with roughly 1000 images of each 1000 categories . In total there is 1.2 million images . 50.000 validation images, 150.000 testing images and the rest 1million for the training .</p><p>Since all supervised learning requires to have a constant input dimenstionanility . Therefore, the images has been down-sampled to a fixed resolution of 256 x 256.</p><h3>The Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/1*jHGIiTjG3hHuXyG728Yrdg.png" /></figure><p>As you can see above , the architecture of the proposed network consist of eight learned layers, five convolution and fully connected that is feed to a 1000-way softmax which produces a distribution over the 10000 class labels. For 224 x 224 input dimension you see above, it is after we did data augmentation, we cropped the images to a new size .</p><h4>1.Training on multiples GPUs</h4><p>Training the model on two GPUs using a method called <strong>model parallelism</strong>. Each node on the model perform it’s calculation on different GPUs (in this case two) . This appreach fastest the training process and make it more smoothly and less expensive .</p><h4>2.Overall Architecture</h4><p>The images were down-sampled to a fixed input dimension (224,224, 3), then it feeded to the CNN. There are five convolutions . The first , filters the 224 x 224 x 3 input image with 96 kernels of size 11 x 11 x 3 with a stride of 4 pixels . The activation function <strong>ReLU</strong> applied, then <strong>The Local Response Normalization(LRN)</strong> and max pooling consecutively . We repeat this fourth times more but with different kernel size and strides and sometimes without LRN . The fully connected layer takes as inputs the outputs of the last pooling layer . 2 Dense layers with 4096 neurons each and 1000 neurons at the end .</p><p><strong>1.ReLU Nonlinearity</strong></p><p>Rectified Linear Units is an non linear activation function with the following formula:</p><p><em>f(x) = max(0, x)</em></p><p>The goal of ReLU is to introduce non linearity . The data at hand is much more complex then just linear function .</p><p><strong>2.Why Local Response Normalization ?</strong></p><p>Local Response Normalization follows the first and second convolution layers right after the activation function which aids in generalization , hence better performance and reduces overfitting . Here is the formula</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/425/1*WsCIRmuvus9kUrz_S4_Caw.png" /><figcaption>Local Response Normalization formula</figcaption></figure><p><strong>3.Overlapping Pooling</strong></p><p>In traditinal CNN, the pooling units do not overlape and the reason behind it is because the pooling size <em>z</em> always<em> </em>equal the stride <em>s </em>denoting by<em> z =s. </em>However , if we set <em>s &lt; z</em> , we obtain overlapping pooling and this is what used in the network with s= 2 and z = 3 . This reduces the top-1( the first prediction with highest probability ) and top-5 (The first five predictions with the highest prababilities ) error rate by 0.4%</p><h3>Reduce Overfitting</h3><p>Overfitting is one of the common issues machine learning engineers face during the training . Even with 1.2 million images of 1000 classes, this turns out to be insufficient to learn so many parametres without overfitting .</p><h4>1.Data Augmentation</h4><p>Enlarge the data is the first thing cames to my mind to reduce overfitting using label-preserving transformations . Tow distinct forms of data augmentation have been employed .</p><p>The first consists of generating image translation (cropping) and horizantal reflections . Extracting random 224 x 224 patches and their horizantal reflections from the 256 x 256 images and training the network on it . For testing, we extract five patches 224 x 224 (the four corner and center patch) as well as thier horizontal reflection , and averaging the predictions made by the network’s softmax layer on the ten patches.</p><p>The second form of data augmentation consists of changing the intensities of the RGB channels . PCA used on the set of RGB pixel values .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/302/1*j0EbndH85RBncAJ1o9eOhA.png" /><figcaption>Principal component analysis of RGB Image formula</figcaption></figure><p>where <em>pi </em>and <em>λi</em> are the <em>i</em>th eigenvector and eigenvalue of 3 x 3 covariance matrix of RGB pixel values, respectively.</p><p>The<em> </em>aforementioned <em>αi</em> is a random variable draw from a Gaussian with mean zero and standard deviation 0.1 .</p><p>This PCA result is added to each training image (Color change in the image below)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*hPUkr0IQDt4ikagRUmNNdw.png" /><figcaption>source : <a href="https://towardsdatascience.com/complete-guide-to-data-augmentation-for-computer-vision-1abe4063ad07/">Complete Guide to Data Augmentation for Computer Vision | Towards Data Science</a></figcaption></figure><p>The PCA helps reduces the top-1 error rate by over 1% .</p><h4>2.Dropout</h4><p>Of the effective ways to reduce overfitting and help with generalizing is dropout .Instead of combining the predicition of different models which is very expensive to do , we can just set zero at random of the outpout of each hidden neuron with probability x , in this case we used 0.5 . The neuron which are dropped out do not contribute to the forward pass and backpropagation. This technique reduces relaying all the neurons on each other (co-adaption).</p><h3>Details of learning</h3><p>The model trained using stochastic gradient descent with batch size of 128 . Momentum varaiable was added to keep the previous wieghts .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*PNZ18dDnMDBmYaRefQuSyw.png" /><figcaption>Stoschastic gradient descent with momentum variable</figcaption></figure><p>where <em>i </em>is the iteration index (or step) <em>, ϵ </em>is the learning rate, 0.9 is the momentum, 0.0005 is the weight decay .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/113/1*M-c208ObU-yXytPbC-siWg.png" /><figcaption>The derivative of loss with respect to the weight</figcaption></figure><p>The above terms represent the average gradient descent over the mini-batch. In other word we sum all the gradient descent of all the 128 examples and then we divid them by the total . For each iteration <em>i</em> the entire weights of the model were updated .</p><p>The wieghts were initialized from a zero-mean Gaussion distribution with standard deviation 0.01 . For the baises , the constant 1 initialized . Providing with positive inputs to the ReLUs accelerate the learning process and limits the dead neurons and this is for the second, fourth and fifth convolution as well as in the fully connected hidden layers . The remain baises initialized with the constant 0 .</p><h3>Results</h3><p>The discussed network acheived <strong>37.5%</strong> on top-1 error rate and <strong>17.0%</strong> on top-5 error rate which is the top results during <strong>ILSVRC-2010 . </strong>In <em>italics </em>are the best results acheived by others</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/381/1*23YKIwsU8d3GfwWJGwsfyA.png" /><figcaption>The results on ILSVRC-2010</figcaption></figure><p>During ILSVRC-2012 competition, the results reported on the table below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/573/1*xHuZ-DJO4uEHGulKgPk84Q.png" /><figcaption>The results on ILSVRC-2012</figcaption></figure><p>For the test error rate , some were not publicaly available so it cannot be reported . In <em>italics </em>are the best results acheived by others . The first one is the result of the CNN described in this paper . The second is the average predictions of five similar CNNs . The third is the same CNN with an extra sixth convolution layer over the last pooling layer and trained on ImageNet Fall 2011 and then fine-tuning on ILSVRC-2012 . The last model is two CNNs pre-trained on the entire Fall 2011 release with the the second model ( 5 CNNs ) and then average the predictions .</p><h4>Qualitative Evaluations</h4><p>The convolution kernels learned by the first convolution layer on the input images which trained on GPU 1(The top of the figure below). You can see that it is largely color-agnostic and only focuses on edges, features and shapes while the second GPU 2 is largely color-specific .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/459/1*704NUCSP1bJ4mVXKZhivHg.png" /><figcaption>The learned convolution kernels</figcaption></figure><p>For the figure below there are eight test images and five most probable labels predicted by the model . The correct one is written under the image and if it is exist in the prediction it’s shows on the red bar . Notice how the top-5 predictions most of the time contains similar lables such as in container ship , it also predict lifeboat, fireboat etc. Also you can see even if the object is off the center like the mite it still managed to get it right .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/377/1*GDdWPXeSRHGYE7zAPhCuvQ.png" /><figcaption>The top-5 predictions and the truth labels of CNNs</figcaption></figure><p>Another way to see the network in the visual knowledge side . If we took two similar images and measure their Euclidean seperation of the feature activation in the last hidden layer , you will see that the value is very small . The figure below shows five images from the test set and six images from the training set that are most similar to each other according to this measure .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/663/1*sLCOmOIOdXs7zF_moH0yOQ.png" /><figcaption>The similar images of the training set from the test set acoording to the last hidden layer</figcaption></figure><p>Doing this measurement with two 4096-dimensional is inefficient , but it could be made efficient by training an auto-encoder to compress these vectors into shorts binary codes . Then use the outputs to retrieve the similar image by measuring Euclidean distance . This way produce much better results then applying auto-encoder to a raw pixels or use the high dimensional feature activation .</p><h3>Discussion</h3><p>The results obtained were good given the resources available back then . This could be improved since all the resources needed available now by increasing the size of the network and the data and the time to train the model .</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ea67ee16b34" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Summeries End-to-End Trainable Neural Network for Image-based Sequance Recognition and Its…]]></title>
            <link>https://medium.com/@otmanheddouchai/summeries-end-to-end-trainable-neural-network-for-image-based-sequance-recognition-and-its-385ed47ebabb?source=rss-e7d361ca183e------2</link>
            <guid isPermaLink="false">https://medium.com/p/385ed47ebabb</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[machine-learning-paper]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[ocr]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[otman heddouch]]></dc:creator>
            <pubDate>Sun, 14 Jan 2024 00:56:31 GMT</pubDate>
            <atom:updated>2024-01-25T22:46:13.735Z</atom:updated>
            <content:encoded><![CDATA[<h3>Summeries End-to-End Trainable Neural Network for Image-based Sequance Recognition and Its Application to Scene Text Recognition Paper .</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*D759MraTV6w1_EvM" /><figcaption>Photo by <a href="https://unsplash.com/@maxchen2k?utm_source=medium&amp;utm_medium=referral">Max Chen</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In this article we will summeries all the imporant informations in<a href="https://arxiv.org/pdf/1507.05717v1.pdf"> End-to-End Trainable Neural Network for Image-based Sequance Recognition and Its Application to Scene Text Recognition Paper</a> by <strong>Baoguang Shi, Xiang Bai</strong> and <strong>Cong Yao School of Electronic Information and Communications Huazhong University of Science and Technology, Wuhan, China .</strong></p><p>Note: This Article is still working on progress .</p><h3>Abstract:</h3><p>This paper covered all the details about how they build end-to-end trainable neural network for image-based sequance recognition and its application to scene text recognition .</p><p>Image-based sequence recognition is one of the most challenging tasks in Computer vision. A novel neural network architechture was proposed, which integrate feature extraction, <em>sequence modeling</em> and transcription.</p><h3>Expirements:</h3><h4>Dataset:</h4><p>The dataset used in this paper is contains 8 millions training images and their cooresponding ground truth words. The network has trained on <em>Synthetic dataset </em>and test on real world test dataset.</p><p>Four populare benchmarks for scene text recognition used for evaluation: <strong>ICDAR 2003</strong>, <strong>ICDAR 2013</strong>, <strong>IIIT 5k-words </strong>and <strong>Street view text</strong>.</p><p>The data is split to features which is cropped text images and labels which is the ground thruth text.</p><h4>Implementation details:</h4><p>The following is the architechture of the proposed algorithm:</p><blockquote><em>Input ==&gt; Convolution ==&gt; MaxPooling ==&gt; Convolution ==&gt; MaxPooling ==&gt; Convolution ==&gt; Convolution ==&gt; MaxPooling ==&gt; Convolution ==&gt; BatchNormalization ==&gt; Convolution ==&gt; BatchNormalization ==&gt; MaxPooling ==&gt; Convolution ==&gt; Maps-to-Sequence ==&gt; Bidirection LSTM ==&gt; Bidirection LSTM ==&gt; Transcription</em></blockquote><p><strong><em>Model Architecture</em></strong></p><p>1. T<strong>ranscription Layer:</strong><br> — Configuration: N/A</p><p>2. <strong>Bidirectional LSTM</strong>:<br> — Hidden Units: 256</p><p>3. <strong>Bidirectional LSTM:</strong><br> — Hidden Units: 256</p><p>4. <strong>Maps-to-Sequence Layer:</strong><br> — Configuration: N/A</p><p>5. <strong>Convolution Layer:</strong><br> — Number of Maps: 512<br> — Kernel Size: 2 × 2<br> — Stride: 1<br> — Padding: 0</p><p>6. <strong>MaxPooling Layer:</strong><br> — Window Size: 1 × 2<br> — Stride: 2</p><p>7. <strong>BatchNormalization Layer</strong>:<br> — Configuration: N/A</p><p>8. <strong>Convolution Layer:</strong><br> — Number of Maps: 512<br> — Kernel Size: 3 × 3<br> — Stride: 1<br> — Padding: 1</p><p>9. <strong>BatchNormalization Layer:</strong><br> — Configuration: N/A</p><p>10. <strong>Convolution Layer:</strong><br> — Number of Maps: 512<br> — Kernel Size: 3 × 3<br> — Stride: 1<br> — Padding: 1</p><p>11. <strong>MaxPooling Layer:</strong><br> — Window Size: 1 × 2<br> — Stride: 2</p><p>12. <strong>Convolution Layer:</strong><br> — Number of Maps: 256<br> — Kernel Size: 3 × 3<br> — Stride: 1<br> — Padding: 1</p><p>13. <strong>Convolution Layer</strong>:<br> — Number of Maps: 256<br> — Kernel Size: 3 × 3<br> — Stride: 1<br> — Padding: 1</p><p>14. <strong>MaxPooling Layer</strong>:<br> — Window Size: 2 × 2<br> — Stride: 2</p><p>15. <strong>Convolution Layer:</strong><br> — Number of Maps: 128<br> — Kernel Size: 3 × 3<br> — Stride: 1<br> — Padding: 1</p><p>16. <strong>MaxPooling Layer:</strong><br> — Window Size: 2 × 2<br> — Stride: 2</p><p>17. <strong>Convolution Layer:</strong><br> — Number of Maps: 64<br> — Kernel Size: 3 × 3<br> — Stride: 1<br> — Padding: N/A</p><p>18. <strong>Input Layer:</strong><br> — Dimensions: W × 32 gray-scale image</p><p>This architechture is based on VGG-VeryDeep architechtures, here is the <a href="https://arxiv.org/pdf/1409.1556.pdf">paper</a>.</p><p>The batch normalization technique is very useful for training network. In the network configuration provided there are two batch normalization inserted after 5th and 6th convolution layers respectively. Using this technique make the training much more faster . During the training, all the images are scaled to 100 x 32 to minimize computing resources .<br>For optimization, ADEDELTA used with 0.9 learning rate</p><h4>Comparative Evaluation :</h4><p>In the paper they compared the CRNN model and the recent state-of-arts with the Four public datasets .<br>The CRNN model perform well in III5k and SVT compared to the other state-of-arts and lower perform on IC03 and IC13 . They provid comprehensive comparison on several properties:</p><p>1. End to end Trainable: this shows whather the model is end to end trainable without any futher steps .</p><p>2. Convolution features: this defines if use convolution features instead of handcraf features like HOG or SIFT and more .</p><p>3. Character-GroundThruth free : this indicate if the character annotation is essential for the training .</p><p>4. Unconstrained : this indicate if the model is not limited to know dictionnary .</p><p>5. Model size : The storage space of the trained model. This calculated by the total number of parametres . CRNN has 8.3 million parametres result in 34 MB</p><h3>Definitions:</h3><p><strong>Sequence modeling</strong>: is the task of predict the next element in the sequence (e.g, sentence).</p><p><strong>End-to-end trainable neural network</strong> : apreach where the entire system from the input to the output is considerd as single integrated model.</p><p><strong>Synthetic dataset</strong>: is dataset that generated by artificiel intelligent rather then human .</p><p><strong>ADEDELTA</strong>: is an optimization algorithm like Adam.</p><h4>Resources :</h4><p>Synthic dataset : Check their officiel <a href="https://www.robots.ox.ac.uk/~vgg/data/text/">website</a> .</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=385ed47ebabb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>