<?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 Nawaf Alageel on Medium]]></title>
        <description><![CDATA[Stories by Nawaf Alageel on Medium]]></description>
        <link>https://medium.com/@nawafalageel?source=rss-a60a6bc79953------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*aB-bwUq2sCEdYQbXfVPqrg.jpeg</url>
            <title>Stories by Nawaf Alageel on Medium</title>
            <link>https://medium.com/@nawafalageel?source=rss-a60a6bc79953------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 15:41:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nawafalageel/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[Docker and Nvidia GPU monitoring]]></title>
            <link>https://medium.com/analytics-vidhya/docker-and-nvidia-gpu-monitoring-fb286e7a2a9f?source=rss-a60a6bc79953------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb286e7a2a9f</guid>
            <category><![CDATA[nvidia]]></category>
            <category><![CDATA[nvidia-docker]]></category>
            <category><![CDATA[grafana]]></category>
            <category><![CDATA[prometheus]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Nawaf Alageel]]></dc:creator>
            <pubDate>Fri, 10 Feb 2023 17:56:24 GMT</pubDate>
            <atom:updated>2023-02-15T06:24:39.481Z</atom:updated>
            <content:encoded><![CDATA[<p>We have seen a major shift in how models are created and used (cough, ChatGPT, cough). Nowadays, the models are much larger and require more extensive computational power. This trend is expected to continue into the future. Furthermore, companies with the most computational power will create and deploy AI-powered applications and services quickly and efficiently, allowing them to gain a competitive advantage over their competitors. As AI becomes increasingly prevalent and integrated into our lives, those companies with the most computational resources will likely be the ones that dominate the AI landscape. I highly recommend reading <a href="https://epochai.org/blog/trends-in-the-dollar-training-cost-of-machine-learning-systems">this post</a> on the cost of training ML models. Spoiler alert it might cost over 1 Billion dollars by 2030.</p><p>Back to the purpose of this blog, to make the most of your GPUs, it’s essential to understand how to use them effectively over time. Knowing how to maximize the power of your GPUs can make all the difference when it comes to getting optimal performance. Data Scientists often leverage Nvidia GPUs and Docker to power their work. Docker is the go-to to train deep learning models due to their ability to avoid the dreaded “<a href="https://en.wikipedia.org/wiki/Dependency_hell">dependency hell.</a>”</p><p>Both technologies provide (separately) monitoring and observability features. For example, you can find <a href="https://docs.docker.com/config/daemon/prometheus/">official</a> and <a href="https://github.com/prometheus-net/docker_exporter">non-official</a> exporters for Docker to view the metrics via a Grafana or a Prometheus dashboard. The same for <a href="https://github.com/a0s/nvidia-smi-exporter">Nvidia</a>.</p><p>If you are using Docker and Nvidia GPU on a small scale you might not need to use those fancy exporters. You can run docker stats to be able to see the metrics. On the other hand, for your Nvidia GPU, you can run nvidia-smi to see GPU utilization and other metrics.</p><p>What this post is about is how to know exactly how much each container is utilizing a GPU, also which GPU it is using. However, to my knowledge, there are currently no plugins available from Docker or Nvidia to connect these two pieces, making it difficult to observe the utilization of training infrastructure. Therefore, developing your own methods for understanding and observing the utilization of training infrastructure such as Docker and GPU is important. Moreover, MLOps frameworks may not provide all the features and capabilities needed to effectively deploy, manage, and monitor machine learning models.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/1*cUCza4p94jTsxu6ocLYctw.jpeg" /><figcaption>Bash scripts is all you need (sometimes)</figcaption></figure><p>The repo is to solve the problem we mentioned earlier (we need to know which container utilities which GPU). Utilizing Prometheus to export the results can easily view container utilization through a Grafana dashboard. However, you can use the bash scripts individually for a quick view.</p><p><a href="https://github.com/nawafalageel/docker_container_gpu_exporter">GitHub - nawafalageel/docker_container_gpu_exporter</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb286e7a2a9f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/docker-and-nvidia-gpu-monitoring-fb286e7a2a9f">Docker and Nvidia GPU monitoring</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simple OCR annotation tool using Jupyter Notebook]]></title>
            <link>https://nawafalageel.medium.com/simple-ocr-annotation-tool-using-jupyter-notebook-d43838133432?source=rss-a60a6bc79953------2</link>
            <guid isPermaLink="false">https://medium.com/p/d43838133432</guid>
            <category><![CDATA[text-recognition]]></category>
            <category><![CDATA[jupyter-notebook]]></category>
            <category><![CDATA[annotation-tools]]></category>
            <category><![CDATA[scene-text-detection]]></category>
            <category><![CDATA[ocr]]></category>
            <dc:creator><![CDATA[Nawaf Alageel]]></dc:creator>
            <pubDate>Tue, 23 Aug 2022 19:38:42 GMT</pubDate>
            <atom:updated>2022-08-23T19:38:42.827Z</atom:updated>
            <content:encoded><![CDATA[<p>STR (Scene Text Recognition), or as it is widely known, OCR (Optical Character Recognition), consists of two main steps 1- Text detection and 2- Text recognition. Text detection is the step in which we try to localize the text in an image, and the second step is to recognize what is the text in that area that the detection step has determined. In the literature, text detection considers an object detection task where the annotation requires bounding boxes around the text instances. The text recognition task requires the text label (characters) within an image crop.</p><figure><img alt="Scene text recognition pipeline" src="https://cdn-images-1.medium.com/max/1024/1*zxUR40lZRBpsLSx6pcD9Rw.png" /><figcaption>STR/OCR pipeline. Image from <a href="https://github.com/HGamal11/EvArEST-dataset-for-Arabic-scene-text">[1]</a></figcaption></figure><p>In this blog, we will demonstrate a simple way to annotate images for STR. Since it is a simple way, it should not be used as an optimal solution instead, it should be used for POC or to annotate a small number of images. However, there are many advanced tools and solutions for a variety of tasks, object detection, key-point, image captioning, etc.</p><p>One of the most efficient ways to transcribe an image (OCR annotation) is to see the image and immediately transcribe the image in the same section of the page. This notebook will help the user to annotate image crops with a placeholder to write the word in the image.</p><figure><img alt="Annotate image using Jupyter Notebook" src="https://cdn-images-1.medium.com/max/1024/1*GzMeCexiKbXyYmhaZctQFg.png" /><figcaption>Jupyter Notebook annotation</figcaption></figure><p>We will start importing the main libraries and set the path of the images we need to annotate. Ipywidgets will give us interactive control over the notebook.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3d9cda48aa7f7517b2dacb3b5bfc29c5/href">https://medium.com/media/3d9cda48aa7f7517b2dacb3b5bfc29c5/href</a></iframe><p>Now we define the function that will display the images with a text box:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7d79dfd46caf732837ff426ac1034bdd/href">https://medium.com/media/7d79dfd46caf732837ff426ac1034bdd/href</a></iframe><p>Once we run the previous cell we should be able to see the images with a text box beneath each image to write the label or transcription. We can replace the label which in our case is an empty string with pre-annotated labels and we can use this notebook to only fix the annotation.</p><p>Before we export the data here is a tip we highly recommend to be taken into consideration. Since it is not a perfect solution annotation should be in batches to avoid big losses if something went wrong with the notebook.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0798fb21008b8b3dd562307ddf22625e/href">https://medium.com/media/0798fb21008b8b3dd562307ddf22625e/href</a></iframe><p>A famous approach for storing the data for training a recognition model is with the same structure we demonstrated.</p><p>You can see the notebook here:</p><p><a href="https://github.com/nawafalageel/notebook_ocr_annotation_tool">GitHub - nawafalageel/notebook_ocr_annotation_tool: This is a simple notebook that could help with annotating images for OCR/STR</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d43838133432" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Detect Face Poses]]></title>
            <link>https://medium.com/analytics-vidhya/detect-face-poses-f4910dea4a6a?source=rss-a60a6bc79953------2</link>
            <guid isPermaLink="false">https://medium.com/p/f4910dea4a6a</guid>
            <category><![CDATA[facedetection]]></category>
            <category><![CDATA[face-recognition]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[pytorch]]></category>
            <category><![CDATA[pose-estimation]]></category>
            <dc:creator><![CDATA[Nawaf Alageel]]></dc:creator>
            <pubDate>Tue, 26 Apr 2022 12:55:13 GMT</pubDate>
            <atom:updated>2022-04-26T12:55:13.210Z</atom:updated>
            <content:encoded><![CDATA[<p>This post will look into a technique that might help to detect face orientation or pose. And we will focus on only detecting three main poses which are:</p><ol><li>Frontal Face.</li><li>Right Profile.</li><li>Left Profile.</li></ol><p>Detecting tilted faces either front or back is out of the scope of this post. The technique detects only out-of-plane orientation estimation which is face rotation with respect to the y-axis (pan rotation). Since the technique relies heavily on the face detection model, we used MTCNN because it produces facial landmarks that we will use to detect face poses. Simply explained when a face is detected for the first time, we extract face landmarks (i.e., right eye, left eye, nose, left mouth, and right mouth) and from these points, we calculate the angels between the right eye, left eye, and the nose using a Cartesian coordinate system for Euclidean space 2D. Setting threshold ranges -which we already experimented with (look at the end of the post for full documentation about the experiment we did)- for the right eye angle and left eye angle can estimate if the face is left, or right profile, or frontal face.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*U-NBy4lwaFP03FTfnt4a3Q.png" /><figcaption>Facial Landmarks and Illustration for eyes angles</figcaption></figure><p>As shown in the figure we are going to calculate the angles θ1 and θ2. After the model produces the landmarks we draw an “imaginary” line between three points i.e., the right eye, left eye, and the nose. Forming a triangle and through that triangle, we calculate the angles θ1 and θ2. In this step, a geometric object possesses both a magnitude and a direction. A vector can be pictured as an arrow or a line. Its magnitude is its length, and its direction is the direction that the line points. For more details, I would recommend you to see <a href="https://manivannan-ai.medium.com/find-the-angle-between-three-points-from-2d-using-python-348c513e2cd">Manivannan&#39;s</a> post about how to calculate angles with python, also thanks to him since his post helped us a lot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*Sk9Dmajv4al3sMTPUO2K2g.png" /><figcaption>How to calculate angles</figcaption></figure><p>And here is an example from <a href="http://crowley-coutaz.fr/Head%20Pose%20Image%20Database.html">Head Pose Image Database</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*XRtlpHFBWCzC6t64XrjGtw.gif" /></figure><h4>TL;DR:</h4><p>Starting to import libraries:</p><pre>from facenet_pytorch import MTCNN</pre><pre>from PIL import Image</pre><pre>from matplotlib import pyplot  as plt</pre><pre>import numpy as np</pre><pre>import math</pre><pre>import torch</pre><pre>import cv2</pre><p>Now we have to declare the MTCNN model (i.e., detection model):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b45d10ba0e2446b44a4aa5aea21eef72/href">https://medium.com/media/b45d10ba0e2446b44a4aa5aea21eef72/href</a></iframe><p>Now let us define a function to calculate the angles:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e8b0b402930825508bf3edf5a87aba4f/href">https://medium.com/media/e8b0b402930825508bf3edf5a87aba4f/href</a></iframe><p>For the next step it is just a visualization function:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/14d1c189aa9ff6e32341f3a7c3133bbb/href">https://medium.com/media/14d1c189aa9ff6e32341f3a7c3133bbb/href</a></iframe><p>Now for the main “prediction” function:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b0d1ef9eb8bf36ca2c0a56abae0d42a2/href">https://medium.com/media/b0d1ef9eb8bf36ca2c0a56abae0d42a2/href</a></iframe><p>We only accept faces with a probability of more than 90%, just to avoid false-positive detections.</p><p>The last step is just to run the code and pass the image path to the predFacePose function:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/697d48bfdf3ef3488a7f94da3ac1b823/href">https://medium.com/media/697d48bfdf3ef3488a7f94da3ac1b823/href</a></iframe><p>If you are interested to read more about this work please look into my full “paper” <a href="https://github.com/nawafalageel/Side-Profile-Detection/blob/main/Documents/FacePoseDetection.pdf">here</a>. Or check out the repo:</p><p><a href="https://github.com/nawafalageel/Side-Profile-Detection">GitHub - nawafalageel/Side-Profile-Detection: Detecting face profiles (i.e., frontal, left, and right) using face detection model MTCNN</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4910dea4a6a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/detect-face-poses-f4910dea4a6a">Detect Face Poses</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Solve Iterable Problems in Python]]></title>
            <link>https://medium.com/analytics-vidhya/how-to-solve-iterable-problems-in-python-90b8e620a48d?source=rss-a60a6bc79953------2</link>
            <guid isPermaLink="false">https://medium.com/p/90b8e620a48d</guid>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[problem-solving]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Nawaf Alageel]]></dc:creator>
            <pubDate>Thu, 03 Mar 2022 17:00:17 GMT</pubDate>
            <atom:updated>2022-03-12T10:17:03.083Z</atom:updated>
            <content:encoded><![CDATA[<p>I would like to start this blog with a problem I need you to solve before you continue reading. Assume we have a list of consecutive integer numbers and it is sorted, and we want to find the sum of that list. How would you solve it? Note that we need the optimal solution in terms of “speed”.</p><p>Everyone with different background would tackle such problems like this in their way. Sometimes no matter what is the way they solve the problem but when you have limited time, resources, labor, etc the way the problem is solved has a significant role if the final solution is correct or not. You wouldn’t stumble on an article like this unless you try to find the better solution to your problem using programming as a tool either for college assignments or a task in the workplace. And here is a piece of advice to myself before anyone else to improve my problem skills.</p><p>Now let’s start solving the problem.</p><p><strong>Let’s declare our sorted list:</strong></p><pre># Declare my list which is from 1 - 1000<br>my_sorted_list = range(1, 1001)</pre><p>Like most of us, we would directly think of a solution with a “for loop” especially if we are at the begging of our journey in programming.</p><p><strong>Simple Solution:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1af42856d0809721d840782bb89f70b4/href">https://medium.com/media/1af42856d0809721d840782bb89f70b4/href</a></iframe><p>On my machine, it took 0:00:00.001154 to get the results. It is definitely nothing we could notice right?! Right, but imagine if the list that we have is 100k times bigger than we already have?! We calculated it and it turns out it took 0:00:08.774443 to get the results.</p><p>Other people might tell you just use the built-in function in python or any other lang to calculate the sum! Built-in functions are usually optimized to such problems as iterables. Always think of “do they implement a built-in function for my problem?” This could be extended to more complicated problems such as “sorting”.</p><p><strong>Built-in function solution:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5a417cd80ad20fd644ef1530afcb721c/href">https://medium.com/media/5a417cd80ad20fd644ef1530afcb721c/href</a></iframe><p>The code looks so clean, and it is faster it took 0:00:00.000110 to calculate the sum of the number from 1 to 1000. Even if we expand the list to be 100k times bigger than the original one the time it took to calculate is equal to 0:00:00.165064.</p><p>If you have been exposed to machine learning problems you definitely have been using NumPy. For the ones who don’t know what is NumPy, it is a python library that provides a multidimensional array object and a collection of routines for fast operations on arrays, including mathematical, logical, sorting, linear algebra, statistical operations, and much more.</p><p><strong>NumPy Solution:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5c464bd33afe309cc373aae862bf4440/href">https://medium.com/media/5c464bd33afe309cc373aae862bf4440/href</a></iframe><p>Surprise it actually slower than the built-in function. Took 0:00:00.000125 and that does not include the converting step. Hence, build your code from the start with what is optimal because if we declared a NumPy array with not only 1000 elements instead of 10000000 and that&#39;s is 100k times bigger than the original one.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5bc09949cfe6cce604d3fb2da83840a9/href">https://medium.com/media/5bc09949cfe6cce604d3fb2da83840a9/href</a></iframe><p>It finished with less than 0.01 seconds! (0:00:00.009971 to be precise). A question might raise now, why NumPy is better? NumPy runs in “the background” C code and that is generally faster than python but besides that, it uses vectorization. Ok, the short answer to what is vectorization? is not using loops, alternately they implement everything using vectors so it can use array operations instead. If you have the chance to use NumPy please do! not for the sake of speed also, for space.</p><p>Before I close the NumPy part, this is how long it takes to convert a python list of 10000000 elementals 0:00:01.989980 so please structure your code from the start to use NumPy or the overhead time to convert will probably be the bottleneck to improve the code.</p><p>Wait a minute! Don’t they always say “<strong>A problem well stated is a problem half solved</strong>”. So let’s go back to the problem for a minute, the question started with an assumption that says we have a sorted list of integer numbers. and if we want to represent that in a mathematical formula it would be something like this:</p><pre>Α = {𝕞, 𝕞+1, ..., 𝕞-𝕟, 𝕟} : 𝕞,𝕟 → ℕ</pre><p>Since the question mentioned the list is sorted so assuming m≤n.</p><p>The second part of the question says we want to find the sum of that list.</p><p>Now we should know the answer ahead of time! By using our math knowledge. This is how we formulate the problem:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zlvXt1c_U-uja5G-s9vnNw.png" /><figcaption>S<a href="https://math.stackexchange.com/questions/2713656/how-to-calculate-sum-of-the-integers-from-m-to-n">um of the integers from 𝑚 to 𝑛.</a></figcaption></figure><p><strong>Math Solution:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/03aedf98754c5908af6331459df95529/href">https://medium.com/media/03aedf98754c5908af6331459df95529/href</a></iframe><p>This solution took only 0:00:00.000109. Compared to all other solutions it might not “outperform” them on a small scale (i.e., 1000 elements). However, this would be optimal for any scale, and it would take the same amount of time with a massive list size. For a list of length equals 1 Billion elements to took only 0:00:00.000153.</p><p>Overall, these numbers perhaps are not accurate, and it differs from one machine to another. Regardless of the results, what I want is to focus on now the conclusion of this blog.</p><h3>Conclusion</h3><p>Finally, this problem does not seem like a real-world problem. Nonetheless, I would not write this blog if I did not face a problem like this in the workplace. Finding the best solution would demand A LOT of research and refining the problem. Research requires an excellent definition of a problem so the best problem-solving (as mentioned at the beginning of the blog as an essential skill) effort can succeed. On the other hand, you are likely not the first trying to solve the problem, that is why it is very important to know what other people have done to solve your problem. In addition,<strong> </strong>it is perfectly ok to start with other people’s solutions as a starting point. And there is no one universal way to a problem, and indeed the way you solve a problem has to meet your requirements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NzECUACSY_Ux_Et6cVbpkw.png" /><figcaption><a href="https://transportfutures.institute/key-problem-solving-skills/">One of the images that describe the problem-solving process</a></figcaption></figure><blockquote>If I had an hour to solve a problem I’d spend 55 minutes thinking about the problem and 5 minutes thinking about solutions. — <strong>Albert Einstein.</strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90b8e620a48d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/how-to-solve-iterable-problems-in-python-90b8e620a48d">How to Solve Iterable Problems in Python</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why LaTeX is a Must for Students?]]></title>
            <link>https://nawafalageel.medium.com/why-latex-is-a-must-for-students-80b5a8f118ae?source=rss-a60a6bc79953------2</link>
            <guid isPermaLink="false">https://medium.com/p/80b5a8f118ae</guid>
            <category><![CDATA[latex]]></category>
            <category><![CDATA[text]]></category>
            <category><![CDATA[editor]]></category>
            <category><![CDATA[publication]]></category>
            <category><![CDATA[research]]></category>
            <dc:creator><![CDATA[Nawaf Alageel]]></dc:creator>
            <pubDate>Thu, 26 Nov 2020 14:04:49 GMT</pubDate>
            <atom:updated>2020-11-26T14:04:49.975Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jZ6-zthg418clkertSnk8w.png" /></figure><h3>My story with LaTeX</h3><p>From the beginning of my college years, the only text editor that I used is either Microsoft Word or Notes on macOS or even the notes on my phone for simple needs. But Through time I had to write more and more especially at graduation year where writing the graduation project report required organized references and other stuff like a table of contents, table of figures, and list of figures. We actually did not use it with the graduation project and I am regretting that until this day. After graduation, I started my internship with a research center working specifically with deep learning to classify medical images, and going through a new area you need to do more research work more than anyone how been in the area for a long time. With the first report, I submit using Microsoft Word it was ok to the point one of the professors and researchers frown at the document and told me next time make sure you use LaTeX! I started exploring how to use LaTeX and the first impression was am I going to “code” my documents every time?!! I spent a couple of hours to understand it, and to be honest, was not that difficult to understand since the syntax pretty much like the English language. And before I know it I have become addicted to using LaTeX with every document I write.</p><h3>Why College students must use LaTeX?</h3><p>Microsoft word is perfect for most of the people, but for my situation, I had to switch to LaTeX because Microsoft word it did not meets my need. But when I remember what was the needs actually in college homework that involves complected equations, tables, figures, and so on or writing an essay where references need to be managed. And not only the college needs to that makes the students use LaTeX I think the students must explore what exactly the researcher uses for writing scientific research and make sense of what is the researcher’s job exactly, talking about the researcher’s work in a brief way of course! Like doing adjustments on the paper, handles the bibliography, and work with different sections within the paper separately and obviously more complicated work than this. However, all that talk because what I saw in college there is a huge gap between students and researchers -at least where I study- no collaboration between them, no summer camps in any research center in the college, or even a seminar about the research field.</p><h3>What is Special about laTeX?</h3><p>I encourage everyone to use LaTeX at least once and because these reasons:</p><ul><li><strong>More specific details to build your documents:</strong> Most of the details might be provided by other software but either to be difficult to implement or not easy to find due to UI. Building complex tables could be the important details that not available on other software.</li><li><strong>Easy to organize references, figures numbers, and list of tables:</strong> This feature is not only about “organizing” specifically because all other software provides the idea of organizing so there is no point to mention it but using LaTeX you could easily refer to any kind of reference by labeling the object whether was a table, figure, reference, and equation</li><li><strong>Once you used to it, it becomes so easy:</strong> I am sure that most people will see how to create a document using LaTeX will say “No Thanks”. I think of using LaTeX for the first time like riding a bicycle for the first time, it will be difficult -for some people- no doubts in the beginning but as soon as you learn the syntax and how to build the document and basis needs like figure, equations, …etc. I really encourage you to start building templates for an all-purpose document, or template for images, tables, and others. All this to reduce the time to write the same things all over again.</li><li><strong>Free software: </strong>Colleges might provide for students a free student package for software like (Microsoft Office). Even when the student has free software I don’t think is a good idea to not try other things, and for something that expensive or popular it doesn’t mean to be the best in the market. Besides the student view of the software using LaTeX in the workplace could be a good idea where the template could be shared as a .tex file so anyone who wants to write a formal document must use the .tex template and then fill it with her/his personal information and the content.</li><li><strong>Easy to manage the big documents:</strong> When someone working on any kind of document that contains lots of sections, chapters, references, …etc. This might be annoying or even risky where there is a chance of losing all the document suddenly. LaTeX lets you separate sections or chapters and then easily assemble them together.</li><li><strong>Works on all operating systems:</strong> LaTeX is an open-source, and it is available in most operating systems such as Windows, Mac, and Linux. There is a cloud-based LaTeX editor used for writing, editing, and publishing scientific documents called <strong>Overleaf </strong>It provides official journal LaTeX templates and direct submission links. And I highly recommend using it at the beginning.</li></ul><p>One last this in Microsoft Work whenever you make a tiny adjustment the whole document gets messed up! (the doc doing “Parkour”).</p><h3>Basics for using LaTeX</h3><h4>Simple Template with TOC:</h4><pre>\documentclass[12pt, onside]{article}<br>\usepackage[utf8]{inputenc}<br>\usepackage[a4paper, total={6in, 8in}]{geometry}<br>\renewcommand{\baselinestretch}{1.5}<br>\usepackage[hidelinks]{hyperref} % Allows clickable ref</pre><pre>\begin{document}</pre><pre>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</pre><pre>\newpage</pre><pre>% For the List of figures</pre><pre>\listoffigures</pre><pre>\addcontentsline{toc}{section}{\numberline{}List of Figures}</pre><pre>% For the List of tables<br>\listoftables</pre><pre>\addcontentsline{toc}{section}{\numberline{}List of Tabels}</pre><pre>% Create the table of content<br>\tableofcontents</pre><pre>\newpage % New page to start the sections<br>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</pre><pre>\section{Section1}</pre><pre>\subsection{Subsection}</pre><pre>\subsection{Subsection}</pre><pre>\subsection{Subsection}<br></pre><pre>\section{Section2}</pre><pre>\subsection{Subsection}</pre><pre>\subsubsection{Subsubsection}</pre><pre>\subsubsection{Subsubsection}<br></pre><pre>\subsection{Subsection}</pre><pre>\subsection{Subsection}<br></pre><pre>\section{conclusion}</pre><pre>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</pre><pre>\newpage % New page to start references </pre><pre>\clearpage</pre><pre>\bibliographystyle{IEEEtran} % To use IEEE style in bibliography</pre><pre>% File path fo the .bib which is contains all references \bibliography{ref.bib} </pre><pre>% To include references in the TOC<br>\addcontentsline{toc}{section}{\numberline{}References}</pre><pre>\end{document}</pre><h4>Cover Page:</h4><pre>\begin{titlepage}<br> <br>\begin{center}</pre><pre>\textbf{\LARGE Name of the Company}\\<br> \line(1,0){300}\\<br> [0.30in]<br> \huge{\bfseries Report title}\\<br> [0.30in]<br> \line(1,0){200}\\<br>    [0.30in]<br>    \textbf{\LARGE Subtitle}\\<br>    [0.30in]<br>    \textit{\Large Name}\\<br>    [0.50in]<br>    \textbf{\small Date}<br>\end{center}</pre><pre>\end{titlepage}</pre><h4>Mathematics Formulas:</h4><p>Every time you want to write a math problem make there are many ways the simplest way is but it between two dollar signs $E=mc^2$and it is looking cool! Note that it is going to be within the line of the text, but if you put two dollar signs the equation will be isolated from the whole text $$PV=nRT$$</p><p>we can use fractions like this, and for integration, we can use it like this $$\int_{lower}^{upper}$$ <br>example of integration : $$f(x)=\int_{a}^{b}x^2 dx$$</p><p>Moreover, LaTeX provides chemical equations, but before we can write any chemical equation we have to use preamble (mhchem) at the beginning of the document by writing :</p><p>\usepackage{mhchem} %allow us to write chemistry equations</p><p>now we can write chemistry equations: \ce{ H2O } we can go way beyond that! \ce{CH_{4(g)}+O_{2(g)}-&gt;CO_{2(g)}+2H_2O{(l)}}</p><p>There are many preambles that could help with mathematical equations like: \usepackage{xfrac} %allow us to use tiny fractions.</p><p>Last, the thing is what if we need to arrange or numbering the equation, label them, and refer to them easily in the whole document. By using</p><pre>\begin{equation}lable{eq:relu} <br>ReLu(x)= max(0,x)<br>\end{equation}</pre><p>Now we can refer to the previous equation by writing \ref{eq:relu} and we can refer to the equations in the document.</p><p>In the end, I really encourage you to use <a href="https://oeis.org/wiki/List_of_LaTeX_mathematical_symbols">https://oeis.org/wiki/List_of_LaTeX_mathematical_symbols</a> to help you with the symbols and how to write them in LaTeX.</p><h4>Figures:</h4><p>There are many ways to create figures in LaTeX and here some of the basics. First, this is you must call the preamble \usepackage{graphicx}to use png, jpg, or eps and other formats</p><pre>\begin{figure}[h] % placement specifier h:here, t:top, b:<em>bottom</em>  <br>  \centering % To make the image in the center<br>  \includegraphics[height=3in]{Cat.jpeg} %specify the size and the path to the image. <br>  \caption{Basic Figure.} <br>  \label{fig:Basic Figure}<br>\end{figure}</pre><h4>Not Just for students!</h4><p>LaTeX in general is a text editor so it is not exclusive only for academia or students! Anyone could benefit from it from building a CV, writing books, formal letters, or even a presentation. You could find many many other uses for it. And I will mention one example for the formal letter it is easy to use every time you need to write a formal letter.</p><pre>\documentclass[12pt]{letter} % Change the mode of the document. <br>\usepackage{geometry}[margin=0.5cm,left=0.5cm]</pre><pre>\usepackage{hyperref}<br>\date{} %If you remove the curly brackets it will appear today&#39;s date. <br>\begin{document}</pre><pre>\begin{letter}{<br>\\ Scranton \\ PA 18503 United States\\ March 29, 2005} % Location/date<br>\opening{Dear Employees:}</pre><pre>I am writing to you to explain in his talking head that it&#39;s Diversity Day in the office and we will have a guest speaker at Dunder Mifflin Scranton in the confreres room to talk about diversity in the workplace. <br>I want this for a while. Corporate did not know ant thing it, I still believe it&#39;s very important to have this kind training in the workpalce.</pre><pre>% The \ldots command produces dots in a way that will not upset<br>% the typesetting of the document.<br>\ldots</pre><pre>\closing{Yours Faithfully, \\ Regional Manager of the Scranton branch Michael Scott}</pre><pre>Signature:</pre><pre>\end{letter}<br>\end{document}</pre><p>At the end you can see my repo for more templates</p><p><a href="https://github.com/NawafKhalid/LaTeX">NawafKhalid/LaTeX</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80b5a8f118ae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DICOM and Deep Learning]]></title>
            <link>https://medium.com/analytics-vidhya/dicom-and-deep-learning-63373e99d79a?source=rss-a60a6bc79953------2</link>
            <guid isPermaLink="false">https://medium.com/p/63373e99d79a</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[dicom-viewer]]></category>
            <category><![CDATA[dicom]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Nawaf Alageel]]></dc:creator>
            <pubDate>Thu, 10 Sep 2020 07:11:04 GMT</pubDate>
            <atom:updated>2020-09-14T12:23:26.125Z</atom:updated>
            <content:encoded><![CDATA[<h3>Extract DICOM Images Only for Deep Learning</h3><h3>What is DICOM?</h3><p>DICOM or digital imaging and communications in medicine are image files sourced from different modalities and it is the international standard to transmit, store, retrieve, print, process, and display medical imaging information. However, DICOM groups information into the data set, and that means that the image file contains the patient information ID, date of birth, age, sex, and other information about the diagnosis all this within the image, as shown in the figure the main components of the medical image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BvVR-348gg0qRmVmm8gtxw.png" /><figcaption><strong>Medical Image Components</strong></figcaption></figure><ul><li>Pixel Depth is the number of bits used to encode the information of each pixel. For example, an 8-bit raster can have 256 unique values that range from 0 to 255.</li><li>Photometric Interpretation specifies how the pixel data should be interpreted for the correct image display as a monochrome or color image. To specify if the color information is or is not stored in the image pixel values, we introduce the concept of samples per pixel, also known as (number of channels).</li><li>Metadata is the information that describes the image (i.e. patients ID, date of the image).</li><li>Pixel Data is the section where the numerical values of the pixels are stored. All the components are essential but in our scope the pixel depth and pixel data. To my knowledge that ultrasound images are not an issue with converting the image to another format, but we have to look into consideration the depth of the image since we cannot convert 16-bit DICOM image to JPEG or PNG with 8-bit that might corrupt the image quality and image features. Pixel data the data that we are going to feed it to the network.</li></ul><p>For more information about DICOM format visit:</p><p><a href="http://www.ijri.org/article.asp?issn=0971-3026;year=2012;volume=22;issue=1;spage=4;epage=13;aulast=Varma">Managing DICOM images: Tips and tricks for the radiologist Varma DR - Indian J Radiol Imaging</a></p><h3>Why Extracting the image Only?</h3><p>DICOM format contains a lot of information as we saw and sometimes we only need the images, either because the private information of the patient or we need to reduce the size even though the information not as big as the image itself, so we had to remove the metadata of the images since we are not allowed for a non-medical or as engineers to look at the patient’s data or we do not need to risk the data to be exposed by mistake to anyone. Mainly we just need the image prat (pixel array) without anything else.</p><h3>How to Extract the Images Only?</h3><p>Most of the time we have to prepare the dataset to read all the images and store it as one list to feed it to the network, and this process can be different from one and another like the way how the files are organized.</p><blockquote>Start collecting the data from the directory</blockquote><p>NOTE: The Files must be organized as</p><p>my_directory/</p><p>|<br> ├── Unnamed_154159/<br> └── IM-0005–0001.dcm</p><p>└── IM-0005–0002.dcm<br>|<br>├── Unnamed_136281/<br>| └── IM-0001–0001.dcm<br>|<br>├── Unnamed_190381/<br>| └── IM-0002–0001.dcm<br>|<br>├── Unnamed_102430/<br>|└── IM-0001–0002.dcm<br> .<br> .<br> .</p><pre>import pydicom as di <br>import os<br>from os import listdir</pre><pre>PathDicom = &quot;The/path/to/DICOM/floders&quot;<br>DCMFiles = [] <br>for dirName, subdirList, fileList in os.walk(PathDicom):<br>    for filename in fileList:<br>        if &quot;.dcm&quot; in filename.lower():<br>            DCMFiles.append(os.path.join(dirName,filename))</pre><pre>print(&quot;Number of (.dcm) files =&quot;, len(DCMFiles))</pre><p>Now we have the list contains the .dcm files then we need to remove all the data and only extract the pixel array (the image itself).</p><pre>import pydicom as di</pre><pre>Images1 = []<br>for k in DCMFiles:<br>    Images = di.read_file(k,force=True)<br>    Images1.append(Images.pixel_array)</pre><p>Images1 is the list that contains the images only. We can now store the images or “pickle it”.</p><p>The previous technique is suitable to feed it to the network but unfortunately, this might be not efficient if someone has the labels on each image, and to my knowledge, the dcm format will not be labeled yet! Because the dcm format considered the initial stage to collect the medical images and not yet begin to be labeled by experts (e.g. Doctors, Radiologists). The method keeps the image size without any changes, but it is a good way to make sure that the pixels data does not change.</p><p>On the other hand, using software called <strong>XnView</strong> which is a software that viewing, organizing, and converting the (.dcm) format. And using the software is much easier for people how need to view the images only. Somebody might need to convert the images to PNG format for whatever reason. Converting the images from DICOM format to PNG, I used one of .dcm images and realize that the size of (.dcm) is 3.3MB and the (.png) is only 630KB and this is a great compression. XnView has a feature where the user can export images by batches that make it easy to convert batches to PNG and then using only PNG images without using the previous method using python.</p><p>In the end, The dataset which in our situation is the DICOM images considers one of the main important parts of building a robust model that can classify. So it is really important when we deal with DICOM format to extract the images properly without losing images or manipulate the features of the images, especially when we deal with medical images.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=63373e99d79a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/dicom-and-deep-learning-63373e99d79a">DICOM and Deep Learning</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>