<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sudhanshu</title>
    <description>The latest articles on DEV Community by Sudhanshu (@sudhanshu1304).</description>
    <link>https://dev.to/sudhanshu1304</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F680376%2Fe7071889-27b6-47a7-80fd-59a1858b6671.jpeg</url>
      <title>DEV Community: Sudhanshu</title>
      <link>https://dev.to/sudhanshu1304</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sudhanshu1304"/>
    <language>en</language>
    <item>
      <title>Open-Source Table Extraction Tool: Extract Structured Data from Documents with OCR and Computer Vision</title>
      <dc:creator>Sudhanshu</dc:creator>
      <pubDate>Fri, 24 Jan 2025 19:19:18 +0000</pubDate>
      <link>https://dev.to/sudhanshu1304/revolutionising-table-extraction-simplifying-document-processing-open-source-528n</link>
      <guid>https://dev.to/sudhanshu1304/revolutionising-table-extraction-simplifying-document-processing-open-source-528n</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy309w4l6i0e0hisoufvi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy309w4l6i0e0hisoufvi.png" alt="table extraction tool" width="800" height="397"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Extracting tabular data from documents remains one of the biggest challenges in industries like healthcare, insurance, and finance. When processing claims, invoices, or contracts, maintaining the structure of complex tables is crucial for accurate insights.&lt;/p&gt;

&lt;p&gt;Traditional methods — such as OCR paired with Language Models — often lose the structural integrity of tables, leading to mismatched columns and rows. Vision-based LLMs promise better accuracy but come with significant computational costs and occasional hallucinations.&lt;/p&gt;

&lt;p&gt;I’m excited to share a &lt;strong&gt;cost-effective and scalable open-source solution&lt;/strong&gt; that addresses these challenges!&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/IOptiw6xRk0"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  🛠️ What Does the Tool Do?
&lt;/h2&gt;

&lt;p&gt;My solution is designed to extract structured tabular data from document images, combining the best of OCR and computer vision technologies with custom processing logic.&lt;/p&gt;

&lt;p&gt;Here’s how it works:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Table Detection&lt;/strong&gt;: Identifies and extracts tables from images using HuggingFace’s Table Detection.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;OCR Integration&lt;/strong&gt;: Uses PaddleOCR to read text within table cells.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Linked List Algorithm&lt;/strong&gt;: Builds a structured linked list to preserve the table layout and outputs it in multiple formats like Pandas DataFrames, HTML tables, or CSVs.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  🔍 Why Is This Important?
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Maintains Structural Integrity&lt;/strong&gt;: The tool ensures tables retain their format, significantly improving downstream processing accuracy.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Adaptable to Complex Cases&lt;/strong&gt;: It can handle basic to moderately complex tables and provides a foundation for applying custom post-processing logic.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Cost-Effective&lt;/strong&gt;: Unlike Vision LLMs, this solution uses lightweight open-source tools, making it highly affordable and efficient.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  💡 How Can You Use It?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Directly use the structured output for simple workflows.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Feed the output into an LLM to improve the accuracy of information extraction, as the structural context is retained.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Replace the open-source components (e.g., PaddleOCR) with advanced tools for higher precision.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🔗 Get Started Today
&lt;/h2&gt;

&lt;p&gt;This project is completely open-source and available on GitHub! It’s easy to set up and comes with detailed instructions for implementation.&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://github.com/Sudhanshu1304/table-transformer" rel="noopener noreferrer"&gt;Explore the Repository on GitHub&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you’re looking for a scalable, reliable, and accurate solution to extract tabular data from documents, this tool is for you. Let me know your thoughts, and feel free to contribute to the project!&lt;/p&gt;

</description>
      <category>huggingface</category>
      <category>paddleocr</category>
      <category>opensource</category>
      <category>documentprocessing</category>
    </item>
    <item>
      <title>Improve your APIs Response Time, use threading!</title>
      <dc:creator>Sudhanshu</dc:creator>
      <pubDate>Wed, 06 Mar 2024 16:31:16 +0000</pubDate>
      <link>https://dev.to/sudhanshu1304/improve-your-apis-response-time-use-threading-34lg</link>
      <guid>https://dev.to/sudhanshu1304/improve-your-apis-response-time-use-threading-34lg</guid>
      <description>&lt;h2&gt;
  
  
  When to use?
&lt;/h2&gt;

&lt;p&gt;In general, threading is a valuable technique to employ in scenarios where your program is not primarily engaged in computational tasks but rather is &lt;strong&gt;waiting for some external event&lt;/strong&gt;, such as &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I/O operations, &lt;/li&gt;
&lt;li&gt;network requests, &lt;/li&gt;
&lt;li&gt;user input,&lt;/li&gt;
&lt;li&gt;waiting for resources to become available&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How to apply?
&lt;/h2&gt;

&lt;p&gt;Their are various methods in python for applying threading. &lt;br&gt;
Example: &lt;br&gt;
a. threading library&lt;br&gt;
b. concurrent.futures&lt;br&gt;
c. asyncio and async functions &lt;/p&gt;
&lt;h3&gt;
  
  
  General Approach
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import threading

def download_from_cloud():
    pass

threads = []
for url, filename in zip(urls, filenames):
  # Create and start thread for each download
  thread = threading.Thread(target=download_from_cloud, args=(url, filename))
  threads.append(thread)
  thread.start()

# In the above code the downloading has started concurrently

# Wait for all threads to finish (optional)
for thread in threads:
  thread.join()

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;thread.join()&lt;/strong&gt; will make the program to wait for all the threads to first finish and than continue with the further code. You can also choose to move further without waiting for them to complete depending on your programs dependency on the operations performed by the above thread.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Below is a Helper Module
&lt;/h2&gt;

&lt;p&gt;Past the below code in a .py file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from concurrent.futures import ThreadPoolExecutor
import time

class ConcurrentThreadExecutor:

    def __init__(self):
        pass

    def execute_parallel(self, tasks, max_threads):
        with ThreadPoolExecutor(max_workers=max_threads) as executor:
            results = list(executor.map(lambda task: self.execute_task(*task), tasks))
        return results

    def execute_task(self, task_name, task_function, task_args):
        t1 = time.time()
        print(f"Started ThreadTask : {task_name}")
        result = self.run_function(task_function, *task_args)
        print(f'ThreadTask : "{task_name}" took : {round(time.time() - t1,2)}sec')
        return (task_name, result)

    def run_function(self, func, *args, **kwargs):
        return func(*args, **kwargs)

class MultiThreadExecutor(ConcurrentThreadExecutor):

    def __init__(self, debug: bool = True) -&amp;gt; None:
        self.max_threads = ThreadPoolExecutor()._max_workers 
        if debug:
            print("Initialized Multi-Thread Executor, Number of threads: " + str(self.max_threads))
        self.debug = debug


    def execute_tasks(self, tasks: list, no_of_cores : int = None):
        """
         ** Note Input must Follow the following format **
            tasks : [ ( TASK_NAME, FUNCTION, ARGS ), ]
        """
        num_threads = min(self.max_threads, len(tasks)) if no_of_cores is None else min(no_of_cores, self.max_threads)
        if self.debug:
            print("Number of threads being used: " + str(num_threads))
        results = self.execute_parallel(tasks, num_threads)

        results = dict(results)
        return results


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now just call the &lt;strong&gt;MultiThreadExecutor&lt;/strong&gt; to run multiple functions concurrently as below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
def func1(name ):
    time.sleep(5)
    print(f"Completed : {name}")


def func2(name):
    [i*i for i in range(100000)]
    print(f"Completed : {name}")

# Create the MultiThreadExecutor Object
execute_concurrent = MultiThreadExecutor(debug = False)

# Pass All the function to be executed concurrently

execute_concurrent.execute_tasks([
    ('func1', func1, ('Function 1',)),
    ('func2', func2, ('Function 2',))
])

print('Ended!')

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Unlocking Efficiency with Threading:
&lt;/h2&gt;

&lt;p&gt;Threading is a powerful tool to enhance responsiveness in Python applications. By allowing your program to handle waiting tasks concurrently, it can deliver a smoother user experience.&lt;/p&gt;

&lt;p&gt;Hope you found it informative!&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Search Word BOT (Tesseract | Tkinter | Selenium)</title>
      <dc:creator>Sudhanshu</dc:creator>
      <pubDate>Sun, 03 Mar 2024 08:21:11 +0000</pubDate>
      <link>https://dev.to/sudhanshu1304/search-word-bot-3j1g</link>
      <guid>https://dev.to/sudhanshu1304/search-word-bot-3j1g</guid>
      <description>&lt;p&gt;This bot takes input from a website (URL provided) in the form of an image and converts it into text using Pytesseract, a Python library (which was the most challenging part).&lt;/p&gt;

&lt;p&gt;Once the text preprocessing is complete, it searches for words in all eight possible directions and displays the final output using Tkinter.&lt;/p&gt;

&lt;p&gt;Stack Used : Tkinter, Pytesseract, Selenium&lt;/p&gt;

&lt;p&gt;Find more such projects at : &lt;a href="https://github.com/Sudhanshu1304"&gt;Sudhanshu1304 GitHub&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>python</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Multicollinearity</title>
      <dc:creator>Sudhanshu</dc:creator>
      <pubDate>Thu, 29 Feb 2024 17:52:08 +0000</pubDate>
      <link>https://dev.to/sudhanshu1304/multicollinearity-18fn</link>
      <guid>https://dev.to/sudhanshu1304/multicollinearity-18fn</guid>
      <description>&lt;h3&gt;
  
  
  &lt;strong&gt;What, Why, and How to solve the multicollinearity.&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2100%2F1%2A7ZGYVUEWHC5Zi5O70Lmbtg.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2100%2F1%2A7ZGYVUEWHC5Zi5O70Lmbtg.jpeg" alt="Image by [Analytics Vidhya](https://www.analyticsvidhya.com/)"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Do you know that Multicollinearity has &lt;strong&gt;almost no effect&lt;/strong&gt; on the &lt;strong&gt;final accuracy&lt;/strong&gt; of the machine learning model? &lt;strong&gt;So why is multicollinearity a problem&lt;/strong&gt;, and &lt;strong&gt;what is it in the first place?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this article, we will learn answers to such questions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Description —
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The assumption in the Regression-based model.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What is Coliniarity?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;About Multicoliniarity.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Why is Multicoliniarity a problem?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;How to remove Multicollinearity?&lt;/p&gt;

&lt;blockquote&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Using VIF&lt;/strong&gt; and its Code Implementation&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Using Correlation&lt;/strong&gt; and its Code Implementation&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;python library&lt;/strong&gt; that automates the above methods.&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Assumption —
&lt;/h2&gt;

&lt;p&gt;It is very important to know that one of the assumption’s for the &lt;strong&gt;regression-based model&lt;/strong&gt; is —&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;No or little multicollinearity&lt;/strong&gt; i.e Input features have no Correlation among themselves or in other words they are &lt;strong&gt;independent&lt;/strong&gt; of each other.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But generally, it is not the case i.e the dataset contains features that are significantly correlated with each other. This leads to Multicollinearity.&lt;/p&gt;

&lt;p&gt;Let’s quickly see what is Coliniarity in brief.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Collinearity?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Collinearity&lt;/strong&gt; or &lt;strong&gt;Correlation&lt;/strong&gt; is a statistical measure that indicates the extent to which two or more variables move together. In other words, &lt;strong&gt;it simply is a number(+ve or -ve) to indicate how are two features interacting with each other like if one increases the other feature is increasing, decreasing, or showing a random growth.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;correlation could be positive or negative.&lt;/strong&gt; A positive correlation indicates that the variables increase or decrease together. A negative correlation indicates that if one variable increases, the other decreases, and vice versa.&lt;/p&gt;

&lt;h2&gt;
  
  
  About Multicoliniarity —
&lt;/h2&gt;

&lt;p&gt;As we all know that it is very important to understand what factors affect the growth of a business firm, this is done in many ways and one of them is by understanding the equation given by our machine learning model. Let’s take an example -&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No of Covied19&lt;/strong&gt; &lt;strong&gt;= 4*Area + intercept&lt;/strong&gt; (Just an Assumption)&lt;/p&gt;

&lt;p&gt;Let’s say our model gave us the above equation which basically states that if the intercept is 0 then we can directly say that if the Area doubles the no of covid cases will increase by a &lt;strong&gt;factor of 4&lt;/strong&gt;. As you can understand that knowing this factor as &lt;strong&gt;accurately&lt;/strong&gt; as possible is very important &lt;strong&gt;because based on that we are supposed to decide the no of vaccines and hospital beds to produce daily.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why is Multicoliniarity a problem?
&lt;/h2&gt;

&lt;p&gt;So what does multicollinearity have to do with the above example?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Due to multicollinearity&lt;/strong&gt; of we may get different &lt;strong&gt;coefficients&lt;/strong&gt; for the same factors and hence leading to &lt;strong&gt;wrong interpretations&lt;/strong&gt;, which could have serious effects. For example, we may get a factor as &lt;strong&gt;2*Area&lt;/strong&gt; but this will lead to a &lt;strong&gt;shortage&lt;/strong&gt; of &lt;strong&gt;no of beds&lt;/strong&gt; and &lt;strong&gt;vaccines&lt;/strong&gt; which are produced daily and hence will lead to &lt;strong&gt;increase in no of deaths per day&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  In general, we can say that —
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Multicollinearity has a great negative impact on these coefficients and could lead to a wrong inference.&lt;/strong&gt;&lt;br&gt;
 &lt;strong&gt;Technically it also affects the p-values which again affects the feature selection process.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  How to Remove Multicollinearity?
&lt;/h2&gt;

&lt;p&gt;In general, there are two different methods to remove Multicollinearity —&lt;/p&gt;

&lt;blockquote&gt;
&lt;ol&gt;
&lt;li&gt;Using Correlations&lt;/li&gt;
&lt;li&gt;Using VIF (variation inflation factor)&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  1. Using Correlation
&lt;/h3&gt;

&lt;p&gt;General, A correlation between two features is more than 0.7, which indicates the those features&lt;/p&gt;

&lt;p&gt;A correlation greater than 0.7 between two features indicates the presence of Multicoliniarity and we should drop one of the two features to solve it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Code —
&lt;/h3&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h3&gt;
  
  
  2. &lt;strong&gt;Variation Inflation Factor(VIF) —&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;There is a simple test to identify multicollinearity called &lt;strong&gt;VIF&lt;/strong&gt;(variance inflation factor).&lt;strong&gt;VIF **starts with 1 and has no upper boundary.&lt;/strong&gt;VIF **between 1 to 5 is considered moderate, but if VIF is above 5 then those are to be removed.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**VIF = 1/(1-R2)**
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;R2 is the coefficient of Determination which indicates the extent to which a predictor can explain the change in the response variable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A VIF of 10 means that the variance of the coefficient of the predictor is 10 times more than what it should be if there’s no collinearity.&lt;/strong&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Code —
&lt;/h3&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;h3&gt;
  
  
  Library Support —
&lt;/h3&gt;

&lt;p&gt;You can use the Python library **ModelAuto to **solve Muticoliniarity easily.&lt;/p&gt;

&lt;p&gt;It has an inbuilt package to remove Multicoliniarity via both methods.&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&lt;strong&gt;pip install ModelAuto&lt;/strong&gt;

&lt;p&gt;&lt;strong&gt;from ModelAuto.Multicollinearity import handel_Multico_Corr&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;OR&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;from ModelAuto.Multicollinearity import handel_Multico_VIF&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Conclusion —&lt;br&gt;
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Multicollinearity affects the coefficients and p-values, &lt;strong&gt;but it does not influence the predictions, precision of the predictions, and the goodness of fit. So if our primary goal is just to make predictions we don’t need to reduce multicollinearity.&lt;/strong&gt;&lt;br&gt;
 &lt;strong&gt;Majorly multicollinearity affects Linear models like-Linear Regression, Logistics Regression. Not much impact on the Algorithms like KNN, Decision Tree, etc which are non-linear.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you found the information helpful consider leaving a 👏😏.&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>python</category>
      <category>datascience</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Dockerizing Django, A Step-by-Step Guide</title>
      <dc:creator>Sudhanshu</dc:creator>
      <pubDate>Mon, 19 Feb 2024 10:14:35 +0000</pubDate>
      <link>https://dev.to/sudhanshu1304/dockerizing-django-a-step-by-step-guide-4h44</link>
      <guid>https://dev.to/sudhanshu1304/dockerizing-django-a-step-by-step-guide-4h44</guid>
      <description>&lt;p&gt;Docker is a popular containerization tool that allows you to package your applications and their dependencies into lightweight, portable containers. Docker makes it easy to run your applications in a consistent environment, regardless of the host operating system.&lt;/p&gt;

&lt;p&gt;Let's see, what we will learn.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Creating a quick Django project&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Dockerizing the Django app using two methods:&lt;/li&gt;
&lt;li&gt;Using only Docker File&lt;/li&gt;
&lt;li&gt;Using Docker Compose (.yml file)&lt;/li&gt;
&lt;li&gt;Understanding the syntax of a docker file&lt;/li&gt;
&lt;li&gt;Understanding the syntax for Docker-compose file&lt;/li&gt;
&lt;li&gt;Make real-time changes in the docker image as you make changes in your local files (Volume mount)&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;/ol&gt;

&lt;h2&gt;
  
  
  Step 1: Create the Django project
&lt;/h2&gt;

&lt;p&gt;First, let’s create a Django project named dockertestusing the following command:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2588%2F1%2APvxXmPYwHwVO6uQgpgQ-8Q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2588%2F1%2APvxXmPYwHwVO6uQgpgQ-8Q.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This will create the basic file structure for the Django project, including the manage.py file, which is used to manage the project. The file structure should look like this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dockertest
|
|-- dockertest
|    |-- __init__.py
|    |-- asgi.py
|    |-- settings.py
|    |-- urls.py
|    |-- wsgi.py
|
|-- manage.py
|-- db.sqlite3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now you should navigate to the parent dockertest folder in your command prompt (CMD/Bash) such that the path should look like this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3160%2F1%2AOiAEzL9N4YKxptZF787KHQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3160%2F1%2AOiAEzL9N4YKxptZF787KHQ.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To check if the application is running properly run the following command in the terminal&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3692%2F1%2ADOqeoRaDLHzWyv-lJLJTcQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3692%2F1%2ADOqeoRaDLHzWyv-lJLJTcQ.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This should give you this page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2174%2F1%2AYkMPeoZF-tBKFV1GKSaSdA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2174%2F1%2AYkMPeoZF-tBKFV1GKSaSdA.png" alt="**Django default landing page**"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you can see the above page you have successfully created the basic Django application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Create the requirements.txt file
&lt;/h2&gt;

&lt;p&gt;Next, we need to create a requirements.txt the file that specifies the Python libraries and dependencies required to run the Django project. Run the following command to create the requirements.txt file:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3780%2F1%2AWUivPO7yD42fRrS57cpahQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3780%2F1%2AWUivPO7yD42fRrS57cpahQ.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This will create a requirements.txt file in the same directory as your Django project. The file structure should now look like this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dockertest
|
|-- dockertest
|    |-- __init__.py
|    |-- asgi.py
|    |-- settings.py
|    |-- urls.py
|    |-- wsgi.py
|
|-- manage.py
|-- db.sqlite3
|-- requirements.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Step 3: Dockizing
&lt;/h2&gt;

&lt;p&gt;There are two methods for Dockerizing the Django project: using only a Dockerfile, or using Docker Compose.&lt;/p&gt;
&lt;h3&gt;
  
  
  Method A: Using only a Dockerfile
&lt;/h3&gt;

&lt;p&gt;This method is suitable for smaller applications. Now, we need to create a Dockerfile that specifies the steps needed to build a Docker image for the Django project. Such that the file structure should look like&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dockertest
|
|-- dockertest
|    |-- __init__.py
|    |-- asgi.py
|    |-- settings.py
|    |-- urls.py
|    |-- wsgi.py
|
|-- manage.py
|-- db.sqlite3
|-- requirements.txt
|-- Dockerfile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Add the following content in the docker file:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3016%2F1%2ARClE9ZgTYxFEx33XbeCGsw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3016%2F1%2ARClE9ZgTYxFEx33XbeCGsw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This Dockerfile specifies the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The base image to use is python:3.8-slim-buster, which is a minimal Python image based on Debian Buster. We can use different base images which you can find on the docker hub.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The working directory is set to /app.This basically creates a folder in which we can place all our project files, and all the commands below will work on this folder by default.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The COPY directive copies the requirements.txt file from the host to the image. This will copy the requirements.txt file into the &lt;strong&gt;WORKDIR&lt;/strong&gt; specified above.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The RUN directive installs the required libraries using pip.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The COPY . . the command copies the rest of the Django project files from the host to the image. The first . represents the source directory (i.e. the current directory on the host), and the second . represents the destination directory (i.e. the working directory specified by the WORKDIR directive in the Dockerfile). This command will copy all the Django project files into the /app directory in the image.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;CMD ["python3", "manage.py", "runserver", "0.0.0.0:8000"]. This command will tell the docker how to run the python application created within the container.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Method B: Using Docker Compose
&lt;/h3&gt;

&lt;p&gt;This method is suitable for larger or more complex applications that involve multiple services. When using the docker-compose file we can make small changes in the docker file created above.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3380%2F1%2AXeW-cwWJhYxd8XxNkSCmwg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3380%2F1%2AXeW-cwWJhYxd8XxNkSCmwg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First, create a docker-compose.yml file&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dockertest
|
|-- dockertest
|    |-- __init__.py
|    |-- asgi.py
|    |-- settings.py
|    |-- urls.py
|    |-- wsgi.py
|
|-- manage.py
|-- db.sqlite3
|-- requirements.txt
|-- Dockerfile
|-- docker-compose.yml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;And add the below content&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3368%2F1%2AEvK55iHBTctSXd-i_5B9pg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3368%2F1%2AEvK55iHBTctSXd-i_5B9pg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This docker-compose.yml the file specifies the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;version&lt;/strong&gt;: In a docker-compose.yml file, the version the field specifies the version of the Docker Compose file format. Docker Compose uses this field to determine how to interpret the rest of the file.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A service name myapp is defined, with the following configuration:&lt;br&gt;
— The service is built using Dockerfile the current directory.&lt;br&gt;
— The current directory is mounted as a volume in the container.&lt;br&gt;
— Port 8000 on the host is mapped to port 8000 in the container.&lt;br&gt;
— The service is given the name docker_image_1 and the container is given the name docker_container_1.&lt;br&gt;
— The command to run the Django server is specified as python manage.py runserver 0.0.0.0:8000.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 4: Running the Dockerized Django Project
&lt;/h2&gt;

&lt;p&gt;Now that you have Dockerized your Django project, you can use the following commands to run and manage your containers.&lt;/p&gt;

&lt;p&gt;Before moving ahead let’s quickly learn about Volume in docker.&lt;/p&gt;

&lt;h3&gt;
  
  
  Solving the Issue of Persistent Changes in Volumes
&lt;/h3&gt;

&lt;p&gt;One issue with Docker is that changes made to the files on the host system are not reflected in the container unless the container is rebuilt. This means that if you make changes to the files on your local machine and want to see those changes in the container, you will have to rebuild the container every time. This can be time-consuming and inconvenient, especially if you are making frequent code changes. To solve this issue, you can use a volume to mount the host directory in the container. This allows you to make real-time changes to the files on your local machine and have those changes immediately reflected in the container. This way, you don’t have to rebuild the container every time you make a change, which saves time and makes it easier to work with your Django project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Method A: Using a Dockerfile
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Build the Docker image using the following command:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3856%2F1%2AA23pUAe63_iSg_YQ166NXw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3856%2F1%2AA23pUAe63_iSg_YQ166NXw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Replace MyDockerImage with the name, you want to give to your Docker image. The . at the end specifies the location of the Dockerfile.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Run the Docker image to create a container using the following command:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F4096%2F1%2AKM9fdsXVqFTdJBuJUJE62g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F4096%2F1%2AKM9fdsXVqFTdJBuJUJE62g.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This command will create an interactive terminal (-it), delete the container after it is stopped ( — rm), map port 8080 on your host to port 8000 in the container (-p 8080:8000), and mount the volume (-v $&lt;strong&gt;(pxd)&lt;/strong&gt;:/app) to enable real-time updates between your local files and the container. Replace MyDockerImage with the name of your Docker image.&lt;/p&gt;

&lt;p&gt;If you are on windows use *&lt;em&gt;“%cd%” **instead *&lt;/em&gt;$(pxd). **They return the path to the current directory.&lt;/p&gt;

&lt;h2&gt;
  
  
  Method B: Using Docker Compose
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;If you are using a docker-compose file you can build the image easily by using&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3680%2F1%2AmRk8xyn_ZdNC8K1rcOZxuw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3680%2F1%2AmRk8xyn_ZdNC8K1rcOZxuw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This will build the images for all the services defined in the file.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Note that the docker-compose build the command only builds the images for the services, it does not start the containers. To start the containers, you can use the docker-compose up command.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3768%2F1%2Aunijzg_lJukYSTv4i4hlAw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3768%2F1%2Aunijzg_lJukYSTv4i4hlAw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Some useful commands
&lt;/h2&gt;

&lt;p&gt;docker images: This command lists all the Docker images on your system. It displays the image ID, the repository and tag, the image size, and the creation date.&lt;/p&gt;

&lt;p&gt;docker run -it Image_Name bash: This command runs the specified Docker image and starts a bash shell inside the container. The -it flag creates an interactive terminal and allows you to input commands directly into the container.&lt;/p&gt;

&lt;p&gt;docker rm: This command removes one or more Docker containers. You can specify the container ID or name as an argument to remove a specific container.&lt;/p&gt;

&lt;p&gt;docker rmi: This command removes one or more Docker images. You can specify the image ID or repository and tag it as an argument to remove a specific image.&lt;/p&gt;

&lt;p&gt;docker ps -a: This command lists all the Docker containers on your system, both running and stopped. The -a flag shows all containers, not just the running ones. The output includes the container ID, the image used to create the container, the command is run, the created and status, and the container name.&lt;/p&gt;

&lt;p&gt;To look at all the code visit my GitHub&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://github.com/Sudhanshu1304/Dockerizing-Django-Application" rel="noopener noreferrer"&gt;https://github.com/Sudhanshu1304/Dockerizing-Django-Application&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Congratulations on completing this tutorial on Dockerizing a Django project! By following the steps outlined in this tutorial, you have successfully set up Docker for your Django project.&lt;/p&gt;

&lt;p&gt;We hope you found this tutorial on Dockerizing a Django project helpful and informative, &lt;strong&gt;please consider giving it a clap👏 and following me on Medium&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Thank you for reading this tutorial!!!.&lt;/p&gt;

</description>
      <category>django</category>
      <category>docker</category>
      <category>python</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Autoencoders</title>
      <dc:creator>Sudhanshu</dc:creator>
      <pubDate>Thu, 05 Aug 2021 06:09:41 +0000</pubDate>
      <link>https://dev.to/sudhanshu1304/autoencoders-5hn6</link>
      <guid>https://dev.to/sudhanshu1304/autoencoders-5hn6</guid>
      <description>&lt;p&gt;

If you are new to Deep learning, and would love to understand Neural Network Architecture or would like to tinker with CNN’s / ANN’s then autoencoder is the best point to start with. In this post, we will go through a quick Introduction to Autoencoders.

&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;br&gt;
Visit — &lt;a href="https://machine-learns.herokuapp.com/"&gt;machine.learns&lt;/a&gt; — Here you can Visualize the working of Autoencoders in different configurations and more.&lt;br&gt;
&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;

So before directly jumping into the technical details, let’s first see some of its applications.



&lt;/p&gt;
&lt;ol&gt;

&lt;li&gt;

Noise Reduction: Autoencoders can be used for Reducing Noise. Noise could be in an Image or in Sound. 






&lt;/li&gt;

&lt;li&gt;

Image Compression: So using autoencoders if you have an image of size 784 pixels, you can convert this image into 64 pixels and then again get the original image from that low dimensional image.

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxtnghtj3bp89vg02qpor.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxtnghtj3bp89vg02qpor.jpeg" alt="Alt Text" width="404" height="125"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;/li&gt;




&lt;li&gt;

&lt;p&gt;Converting a Black and White Image to a Colored Image.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F49bpjlm1987wxzihz805.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F49bpjlm1987wxzihz805.png" alt="Alt Text" width="528" height="176"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;


&lt;/li&gt;




&lt;li&gt;

Removing Watermarks from an image.
&lt;/li&gt;

&lt;li&gt;

 Fraud Detection eg. credit card fraud detection.
&lt;/li&gt;

&lt;/ol&gt;






&lt;h2&gt;What is an Autoencoders?&lt;/h2&gt;
&lt;p&gt;
Autoencoder is an Artificial Neural Network learning technique. It is an Unsupervised Learning Approach. It mainly helps in achieving representation learning i.e. we come up with an architecture that forces the model to learn a compressed representation of the input data.
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxa5sdtj5b1n4jf120pwm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxa5sdtj5b1n4jf120pwm.png" alt="Alt Text" width="700" height="319"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
This compressed representation is also known as a bottleneck or latent representation. The bottleneck basically learns the features of the data, i.e. it learns to represent a particular data point based on a certain number of features. For example — if the input is a digit dataset then it may learn features like no of horizontal and vertical edges and based on these features it identifies each data point.

&lt;/p&gt;





&lt;h2&gt;Latent Representation (Bottleneck)&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgnovwcl5wn55z9b2vn4e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgnovwcl5wn55z9b2vn4e.png" alt="Alt Text" width="640" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above figure is a plot of Latent space or Bottleneck&lt;/p&gt;



&lt;p&gt;
We can see clusters of similar colors. Each cluster above is representing similar types of objects example the blue dots are representing asphalt etc.

&lt;br&gt;&lt;br&gt;

&lt;strong&gt;
It is important to know that each dot is representing a unique type of object.
&lt;/strong&gt;

&lt;br&gt;&lt;br&gt;

So in total, we can divide an Autoencoder into three parts

&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
Encoder: Part of the Architecture which compresses or forces the model to capture the important information from the data.
&lt;/li&gt;
&lt;li&gt;
Bottleneck(latent representation): This is the compressed representation of the original data.
&lt;/li&gt;
&lt;li&gt;
Decoder: This Part tries to reconstruct the original image from latent representation.
&lt;/li&gt;
&lt;/ol&gt;

&lt;br&gt;&lt;br&gt;

This concept of Autoencoders can be applied using architectures like CNNs and LSTMs.







&lt;h2&gt;Conclusion
&lt;/h2&gt;

&lt;p&gt;
Despite being a very basic architecture it helps a lot in understanding the various concepts of Neural networks and their architectures. So I will highly encourage you two to learn the implementation of Autoencoders too.

&lt;br&gt;&lt;br&gt;

Hope you would have learned something valuable.

&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;&lt;br&gt;
Visit: &lt;a href="https://machine-learns.herokuapp.com/"&gt;machine.learns&lt;/a&gt; 😄&lt;br&gt;
&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>deeplearning</category>
      <category>machinelearning</category>
      <category>python</category>
    </item>
  </channel>
</rss>
