<?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 Sirojul Alam on Medium]]></title>
        <description><![CDATA[Stories by Sirojul Alam on Medium]]></description>
        <link>https://medium.com/@sirojmu?source=rss-240839453f52------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*F9TKfzy5vXz16elf8NkheA.jpeg</url>
            <title>Stories by Sirojul Alam on Medium</title>
            <link>https://medium.com/@sirojmu?source=rss-240839453f52------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 11:34:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sirojmu/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[Our Phones are Pocket-sized Slot Machines: What 7500 Data Points Taught Me About Addiction]]></title>
            <link>https://medium.com/@sirojmu/our-phones-are-pocket-sized-slot-machines-what-7500-data-points-taught-me-about-addiction-53501dee1551?source=rss-240839453f52------2</link>
            <guid isPermaLink="false">https://medium.com/p/53501dee1551</guid>
            <dc:creator><![CDATA[Sirojul Alam]]></dc:creator>
            <pubDate>Thu, 16 Apr 2026 07:42:39 GMT</pubDate>
            <atom:updated>2026-04-16T07:42:39.420Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T2PLhA_5SyqBBtYct2hQ7A.png" /></figure><p>We’ve been there. You pick up your phone to check the time, and forty-five minutes later, you’re deep in a rabbit hole of short-form videos, wondering where the time went.</p><p>As a data enthusiast, I’ve always been fascinated by the ‘hidden architecture’ of our habits. Recently, I decided to stop guessing and start measuring. I analyzed a dataset of 7,500 smartphone users, I got from <a href="https://www.kaggle.com/datasets/nalisha/smartphone-usage-and-addiction-analysis-dataset">Kaggle</a>, to understand the anatomy of digital addiction. The results weren’t just surprising-they were a wake-up call.</p><p><strong>The Weekend Surge; Why We Never Truly “unplug”</strong></p><p>One of the first patterns I noticed was the Weekend Surge. We often think of weekends as a time to rest, but the data tells a different story.</p><p>Using Python to visualize usage patterns, I found a significant density spike in weekend screen time compared to weekdays. Instead of recovering from a long week, many of us are simply shifting our cognitive load from work emails to infinite scrolling. The “digital weekend” is often more exhausting that the work week.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/0*RztMkuzRLQoqix8c.png" /><figcaption>Screen time comparison</figcaption></figure><p><strong>The Health Toll: Trading Sleep for Dopamine</strong></p><p>Is your phone stealing your sleep? According to the data: <strong>YES.</strong></p><p>Through correlation analysis, I found a clear negative trend. As <em>daily_screen_time_hours </em>climbedm <em>sleep_hours </em>dropped. It’s zero-sum game. We have a finite amount of time each day, and every hour spent behind a glowing screen is often an hour stolen from our body’s recovery.</p><p>But it’s not just about the <em>time. </em>It’s about the stress. Users who reported “High” stress levels didn’t just use their phones more; they interacted with them differently, showing a higher frequency of “App Opens” and notification checks.</p><p><strong>Predicting Addiction: The Random Forest Insight</strong></p><p>To take the analysis further, I built a Machine Learning model (Random Forest) to see if I could predict which users were most at risk of addiction. The model achieved a high accuracy of 93%, and it revealed the “Top Predictors” of digital dependency:</p><ol><li><strong>Daily Screen Time (The Gateway):</strong> This is the #1 predictor. It’s the total “dosage” of digital exposure. The more hours the screen is on, the higher the probability that the usage has crossed from a tool into an addiction.</li><li><strong>Social Media Hours:</strong> Coming in second, social media provides the “dopamine hits” that keep us coming back. It’s the primary engine driving our desire to stay connected.</li><li><strong>Sleep Hours:</strong> This is the first biological red flag. The model found that our sleep patterns are a significant predictor; as addiction levels rise, sleep is almost always the first thing we sacrifice.</li><li><strong>Notifications Per Day:</strong> The “ping” is the hook. High notification frequency acts as a constant trigger, breaking our focus and pulling us back into the digital loop.</li><li><strong>Gaming Hours:</strong> Rounding out the top five, gaming represents the “immersion” factor — where hours can disappear into a virtual environment.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/0*caUvTx0ErgJ1Je8c.png" /><figcaption>Confusion Matrix</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/0*ErAkISxWKGEB_9Cn.png" /><figcaption>Top 5 Predictors of Addiction</figcaption></figure><p><strong>The Actionable Insight; How to Reclaim Your Time</strong></p><p>Data is meaningless unless it leads to change. If I were to summarize these findings into a “Digital Survival Guide,” it would look like this:</p><ul><li><strong>Control the Volume:</strong> Since <strong>Daily Screen Time</strong> is the biggest predictor, setting a hard limit on total usage is more effective than just deleting one specific app.</li><li><strong>Silence the Hooks:</strong> By reducing your <strong>Notifications Per Day</strong>, you remove the external triggers that start the addiction cycle.</li><li><strong>Protect the Sleep Window:</strong> Since <strong>Sleep Hours</strong> is a top predictor, the data suggests that keeping the phone out of the bedroom is the single most effective “health hack” you can implement.</li></ul><p><strong>Final Thoughts</strong></p><p>Data science allows us to hold a mirror up to our behavior. By analyzing these 7,500 users, I realized that smartphone addiction isn’t just a lack of willpower — it’s a measurable outcome of our daily environment.</p><p>The question isn’t whether we should use technology, but whether we are using it to enhance our lives, or letting it consume our most valuable resources: our time and our health.</p><p>Please find the Kaggle Notebook <a href="https://www.kaggle.com/code/sirojalfaqier/knowing-smartphone-addiction-patterns">here.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=53501dee1551" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Metadata Exposure to Metadata Protection: A Defensive Continuation]]></title>
            <link>https://medium.com/@sirojmu/from-metadata-exposure-to-metadata-protection-a-defensive-continuation-854d609f1278?source=rss-240839453f52------2</link>
            <guid isPermaLink="false">https://medium.com/p/854d609f1278</guid>
            <category><![CDATA[cybsersecurity]]></category>
            <dc:creator><![CDATA[Sirojul Alam]]></dc:creator>
            <pubDate>Tue, 06 Jan 2026 11:11:32 GMT</pubDate>
            <atom:updated>2026-01-06T11:11:32.593Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RRUhX1iBYgJuhdWWl1Aimw.png" /></figure><p>In previous hands-on exercice, (<a href="https://medium.com/@sirojmu/security-awareness-your-photo-is-not-just-an-image-79aca91f70eb">click here</a>), we demonstrated how image can unintentionally disclose sensitive information through EXIF metadata. By uploading a photograph, extracting its metadata, converting GPS coordinates, and visualizing the loccation on a map, we showed that location disclosure does not require malware, tracking scripts, or system exploitation. Instead, it often occurs silently through data that users are unware of.</p><p>This article continues that experiment from a defensive and preventive perspective. In cybersecurity practice, understanding how information is leaked is only half of the learning process. The other half is knowing how to mitigate the risk. Therefore, rather than introducing a new dataset or workflow, we intentionally reuse the same image analyzed previously. This allows us to observe how defensive controls can be applied directly after a privacy risk has been identified.</p><p>In this hands-on session, we focus on removing EXIF metadata, particularly GPS-related information, using Python. The objective is demonstrate how an image can be sanitized before sharing, publication, or storage — without altering its visual content. This reflects a realistic security workflow: detect exposure, assess impact, and apply remediation.</p><h4>Hands-On Practice: Removing EXIF metadata</h4><p>Once metadata hase been detected and analyzed, the next step is to remove it. In Python, this can be done using the <em>Pillow</em> library by saving the image without including EXIF data.</p><p>To preserve forensic transparency and allow comparison, we do not overwrite the original image. Instead, we save a new, sanitized copy using this code:</p><pre>def remove_exif(image_path, output_path):<br>    try:<br>        img = Image.open(image_path)<br><br>        img.save(output_path, exif=&#39;b&#39;)<br><br>        print(&quot;EXIF metadata successfully removed&quot;)<br>        print(&quot;Sanitized image saved as: &quot;, output_path)<br><br>    except Exception as e:<br>        print(&quot;Error while removing EXIF metadata: &quot;, e)<br><br>clean_image_path = &quot;image_no_exif.jpf&quot;<br>remove_exif(image_path, clean_image_path)</pre><h4>Explanation:</h4><ul><li><em>Image.open()</em> loads the image into memory</li><li><em>exif=’b’</em> explicitly removes all EXIF tags</li><li>The visual content of the image remains unchanged</li><li>Only metadata is removed</li></ul><h4>Verifying Metadata Removal</h4><p>After sanitizing the image, it is critical to verify the result. We reuse the same EXIF extraction to confirm that the metadata has been removed.</p><pre>print(&quot;\nVerifying metadata after removal: &quot;)<br>exif_data_after_removal = extract_exif(clean_image_path)<br><br>if not exif_data_after_removal:<br>    print(&quot;No EXIF metadata fround after removal.&quot;)<br><br>else:<br>    print(&quot;EXIF metadata is still present.&quot;)<br>    print(&quot;Number of tags: &quot;, len(exif_data_after_removal))<br>    print(exif_data_after_removal)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/463/1*qp3KI5NToUzN9eitvexTHA.png" /><figcaption>The result</figcaption></figure><h4>Cybersecurity Perspective</h4><p>This exercise highlights several key principles:</p><ul><li>Metadata leakage is a form of passive information disclosure</li><li>Privacy risks can exist without any active attack</li><li>Defensive controls can be simple, transparent, and effective</li><li>EXIF metadata should never be assumed to be trustworthy or harmless</li></ul><p>This hands-on approach encourages students and practitioners to think beyond traditional threat models and to consider how everyday digital artifact contribute to security and privacy risks.</p><blockquote>“In digital security, what matters is not only what data we extract, but also what data we choose to remove” — <em>Tukang Remot</em></blockquote><p>By completing both hands-on, readers gain a more complete understanding of how privacy risks emerge and how they can be mitigated in real-world scenarios.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=854d609f1278" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Security Awareness: Your Photo Is Not “Just an Image”]]></title>
            <link>https://medium.com/@sirojmu/security-awareness-your-photo-is-not-just-an-image-79aca91f70eb?source=rss-240839453f52------2</link>
            <guid isPermaLink="false">https://medium.com/p/79aca91f70eb</guid>
            <dc:creator><![CDATA[Sirojul Alam]]></dc:creator>
            <pubDate>Mon, 05 Jan 2026 07:17:34 GMT</pubDate>
            <atom:updated>2026-01-05T07:17:34.326Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>When we share a photo online, we rarely think beyond what appears on the screen. A picture is just an image-just pixels-right?</p><p>In reality, a photo often carries more information than we intend to share. Not hidden messages. Not malicious code. But <strong>METADATA.</strong></p><p>In recent years, stories have circculated about images being used to “track someone’s location” after being sent through messaging apps like WhatsApp. These stories often trigger fear and speculation: <em>Was there hidden code inside the image? Was this a cyberattack?</em></p><p>The truth is far less dramatic, and far more important to understand.</p><p>This article explores EXIF metadata, a standard embedded in most digital photos, and how it can unintentionally reveal sensitive information such as where a photo was taken. No hacking tools. No Malware. Just data quitely recorded by our own devices.</p><p>By understanding how image metadata works, we can better protect our privacy, educate others, and separate cybersecurity facts from myths. This topic is especially relevant for student, educators, and anyone who regularly share images online without realizing the digital footprint they may leave behind.</p><h3>What is EXIF Metadata</h3><p>Every time you take a photo with a smartphone or digital camera, the device does more than capture light and color. It also records context.</p><p>This contextual information is stored as EXIF metadata, short for <em>Exchangeable Image File Format. </em>EXIF is a widely used standard that allows cameras and smartphones to embed technical and environmental details into the image file.</p><p>Some common EXIF fields include:</p><ul><li>Date and time the photo was taken</li><li>Camera or smartphone model</li><li>Lens and exposure settings</li><li>Orientation of the image</li><li>GPS coordinates (longitude and latitude)</li></ul><p>This data is added automatically. In most cases, users are not asked whether they want it recorded, and many are not even aware that is exists.</p><p>From a cybersecurity perspective, EXIF metadata is not inherently dangerous. Its original purpose is benign: helping photographers organize images, reproduce camera settings, and improve image processing. However, when images are shared publicly, this same metadata can become a source of unintended information disclosure.</p><h3>How Location Data Gets Into Your Photos</h3><p>Modern smartphones are equipped with GPS sensors. When location services are enabled, the camera application may attach geographic coordinates to each photo you take.</p><p>This process is entirely passive:</p><ul><li>No app is tracking you in real time</li><li>No code is executed when the image is viewed</li><li>The location is recorded once, at the moment the photo is taken</li></ul><p>The result is pair numbers, latitude and longitude, stored inside the image file. If extracted and interpreted correctly, these numbers can point to a very specific location, sometimes down to a few meters.</p><p>In other words, the photo does not find your location, it just remembers where it was created.</p><h3>Hands on Practice: Extracting EXIF Metadata and Visualizing Location on a Map</h3><p>Understanding EXIF metadata becomes much clearer when you see it in action. In this section, we will extract GPS metadata from an image and visualize the location on an interactive map using Python.</p><p>The steps are:</p><ol><li>Upload an image</li><li>Read its EXIF Metadata</li><li>Extract GPS information</li><li>Convert GPS coordinates into decimal format</li><li>Visualize the location on a map</li></ol><p>This exercise can be executed on Google Colab or any local Python environment. And let’s go for it.</p><figure><img alt="Image Sample for this hands-on" src="https://cdn-images-1.medium.com/max/1024/1*OcUpliBWN0gOGxfE4HXqFA.jpeg" /><figcaption>Image Sample for this hands-on</figcaption></figure><h4>1. Uploading an Image</h4><p>We begin by uploading an image file. This image should be a photo taken with a smartphone with GPS enabled. You can use this standard code:</p><pre>from google.colab import files<br><br>uploaded = files.upload()<br>image_path = list(uploaded.keys())[0]<br><br>print(&quot;Analyzed File:&quot;, image_path)</pre><h4>Explanation:</h4><ul><li><em>files.upload() </em>opens a file upload dialog in Google Colab</li><li>The uploaded file is stored in memory</li><li><em>image_path </em>retrieves the filename of the uploaded image</li><li>This file will be used in all subsequent analysis steps</li></ul><h4>2. Reading EXIF Metadata</h4><p>Let’s extract EXIF metadata from the image with this code.</p><pre>from PIL import Image<br>from PIL.ExifTags import TAGS<br><br>def extract_exif(image_path):<br>    image = Image.open(image_path)<br>    exif = image._getexif()<br><br>    if not exif:<br>        return None<br>    <br>    data = {}<br>    for tag, value in exif.items():<br>        tag_name = TAGS.get(tag, tag)<br>        data[tag_name] = value<br><br>    return data<br><br>exif_data = extract_exif(image_path)<br><br>if not exif_data:<br>    print(&quot;No EXIF metadata found&quot;)<br>else:<br>    print(&quot;EXIF metadata detected&quot;)<br>    print(&quot;Number of tags:&quot;, len(exif_data))<br>    print(exif_data)</pre><h4>Explanation:</h4><ul><li><em>Image.open()</em> loads the image file</li><li><em>_getexif()</em> retrieves raw EXIF metadata</li><li>Each EXIF tag is decoded into a human-readable name using <em>TAGS</em></li><li>The metadata is stored as a Python dictionary</li><li>If no metadata exists, the function returns <em>None</em></li></ul><p>At this stage, we can already see whether the image contains any metadata at all. See this result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*s10Q-XDNFVg6-Y1A9x3GbA.png" /><figcaption>EXIF Metadata including GPS Info and many more</figcaption></figure><p>We see the GPS Info from our image sample.</p><h4>3. <strong>Extracting GPS Metadata</strong></h4><p>If EXIF metadata exists, we now check the whether it contains GPS information using this code:</p><pre>from PIL.ExifTags import GPSTAGS<br><br>def extract_gps(exif):<br>    if &quot;GPSInfo&quot; not in exif:<br>        return None<br><br>    gps_data = {}<br>    for key in exif[&quot;GPSInfo&quot;]:<br>        decoded = GPSTAGS.get(key, key)<br>        gps_data[decoded] = exif[&quot;GPSInfo&quot;][key]<br><br>    return gps_data<br><br>gps_info = extract_gps(exif_data) if exif_data else None<br><br>if not gps_info:<br>    print(&quot;No GPS metadata found&quot;)<br>else:<br>    print(&quot;GPS metadata detected&quot;)</pre><h4>Explanation:</h4><ul><li>GPS data is stored under the GPSInfo tag</li><li>GPSTAGS translates numeric GPS keys into readable names</li><li>The result includes: Latitude, Longitude, and Direction references (N/S/W/E)</li></ul><p>If GPS metadata is present, the image contains location information.</p><h4>4. Converting GPS Coordinates to Decimal Format</h4><p>EXIF GPS coordinates are not stored as decimal values. They are stored in degrees, minutes, and seconds (DMS) format, and we must convert them before using mapping services like Google Maps.</p><pre>def rational_to_float(r):<br>    return float(r)<br><br>def dms_to_decimal(dms, ref):<br>    degrees = rational_to_float(dms[0])<br>    minutes = rational_to_float(dms[1]/60)<br>    second = rational_to_float(dms[2]/3600)<br><br>    decimal = degrees + minutes + seconds<br><br>    if ref in [&#39;S&#39;, &#39;W&#39;]:<br>        decimal = -decimal<br><br>    return decimal</pre><p>And now we apply the conversion:</p><pre>lat = dms_to_decimal(<br>    gps_info[&quot;GPSLatitude&quot;],<br>    gps_info[&quot;LatitudeRef&quot;]<br>)<br><br>lon = dms_to_decimal(<br>    gps_info[&quot;GPSLongitude&quot;],<br>    gps_info[&quot;LongitudeRef&quot;]<br>)<br><br>print(&quot;Latitude  :&quot;, lat)<br>print(&quot;Longitude :&quot;, lon)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/1*7edhq276RAkxZKqcYvigMw.png" /><figcaption>GPS Coordinate</figcaption></figure><h4>Explanation:</h4><ul><li>EXIF stores GPS as three values: degrees, minutes, and seconds</li><li>These values are converted into decimal degrees</li><li>The references <em>(N, S, W, E)</em> determines the sign</li><li>This step is critical, incorrect conversion leads to invalid locations</li></ul><h4>5. Visualizing the Location Using Folium</h4><p>Finally, we display the extracted location on an interactive map.</p><pre>import folium<br><br>m = folium.Map(location = [lat, lon], zoom_start = 15)<br>folium.Marker([lat, lon], tooltip = &#39;Location extracted from EXIF&#39;).add_to(m)<br><br>m</pre><h4>Explanation:</h4><ul><li><em>folium.Map()</em> creates an interactive map</li><li>The map is centered on the extracted coordinates</li><li>A marker highlights the photo’s location</li><li>The results is rendered directly inside the notebook</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/1*9ILADdzPwNS1RNcGi3_zUQ.png" /><figcaption>This is the location where the photo was taken</figcaption></figure><p>We can also use Google Maps with this code:</p><pre>if gps_info:<br>  print(&quot;Google maps link: &quot;)<br>  print(f&quot;https://maps.google.com/?q={lat},{lon}&quot;)<br>else:<br>  print(&quot;Tidak ada metadata GPS&quot;)</pre><p>Then click the link generated from the code and we will go to Google Maps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*cLm1FG0cd3Y2H-VBX6EjbQ.png" /><figcaption>Generated Google Maps link which ready to click</figcaption></figure><blockquote>Thank you for reading, and be aware, be secure.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79aca91f70eb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create Stunning Pencil Sketches from an Image]]></title>
            <link>https://medium.com/@sirojmu/create-stunning-pencil-sketches-from-an-image-d4718e504b26?source=rss-240839453f52------2</link>
            <guid isPermaLink="false">https://medium.com/p/d4718e504b26</guid>
            <category><![CDATA[skechers]]></category>
            <category><![CDATA[image-processing]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[image-manipulation]]></category>
            <dc:creator><![CDATA[Sirojul Alam]]></dc:creator>
            <pubDate>Fri, 06 Sep 2024 12:07:58 GMT</pubDate>
            <atom:updated>2024-09-06T12:07:58.313Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dYA6XepKni3eHKjZ7pORBQ.jpeg" /></figure><p>Ever wanted to turn your favorite photos into pencil sketches without breaking a sweat? With Python and Google Colab, you can do just that! In this post, I’ll walk you through an awesome way to allow users to upload images and instantly transform them into stunning pencil sketches. Ready? Let’s dive in!</p><h3>Step 1: Upload Your Image</h3><p>The first step is to give users the power to upload their own images directly in Google Colab. We’ll use the files.upload() function from the google.colab library. This function opens up a file dialog that allows you to choose any image from your computer. It&#39;s as simple as dragging and dropping!</p><pre>from google.colab import files<br><br># Step 1: Upload image<br>uploaded = files.upload()</pre><h3>Step 2: Process the Image and Create the Sketch</h3><p>Once the image is uploaded, we dive into the magic of image processing with OpenCV. The image is first converted into grayscale to capture the essence of a pencil sketch. Then, we invert the grayscale image and apply a Gaussian blur to smooth out the details. Finally, the sketch is created by blending the grayscale image with the inverted, blurred image, resulting in a pencil-like effect that looks hand-drawn.</p><pre>import cv2<br>import numpy as np<br>import matplotlib.pyplot as plt<br><br>def pencil_sketch(image_path, output_path):<br>    image = cv2.imread(image_path)<br>    gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)<br><br>    inverted_gray_image = 255 - gray_image<br>    blurred_image = cv2.GaussianBlur(inverted_gray_image, (21, 21), 0)<br><br>    inverted_blurred_image = 255 - blurred_image<br>    pencil_sketch_image = cv2.divide(gray_image, inverted_blurred_image, scale=256.0)<br><br>    cv2.imwrite(output_path, pencil_sketch_image)</pre><h3>Step 3: Display the Results</h3><p>After processing, it’s time to showcase the original image side by side with the newly created pencil sketch. We use Matplotlib to display these images directly in the notebook, making it easy to compare and admire the transformation.</p><pre>    plt.figure(figsize=(10,5))<br>    plt.subplot(1, 2, 1)<br>    plt.title(&quot;Original Image&quot;)<br>    plt.imshow(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))<br>    plt.axis(&#39;off&#39;)<br><br>    plt.subplot(1, 2, 2)<br>    plt.title(&quot;Pencil Sketch&quot;)<br>    plt.imshow(pencil_sketch_image, cmap=&#39;gray&#39;)<br>    plt.axis(&#39;off&#39;)<br><br>    plt.show()</pre><h3>Step 4: Automate the Workflow</h3><p>Finally, to bring it all together, we automate the workflow so that once the image is uploaded, the sketching process begins automatically. The output sketch is saved and displayed right after the image is processed.</p><pre># Automate the process<br>for file_name in uploaded.keys():<br>    input_image_path = file_name<br>    output_image_path = &quot;/content/output_image.jpg&quot;<br>    pencil_sketch(input_image_path, output_image_path)</pre><p>And there you have it! A quick, slick way to turn any uploaded image into a beautiful pencil sketch using Python. This simple yet powerful script is a fantastic way to add a creative touch to your favorite photos, and it all runs effortlessly on Google Colab. Give it a try, and bring your images to life with a whole new perspective!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*U_OBNbhoc9JxQ9zMrlF2ow.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d4718e504b26" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Make Your PDF File Speaking]]></title>
            <link>https://medium.com/@sirojmu/make-your-pdf-file-speaking-860c0b2833fc?source=rss-240839453f52------2</link>
            <guid isPermaLink="false">https://medium.com/p/860c0b2833fc</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[pdf-reader]]></category>
            <category><![CDATA[text-to-speech]]></category>
            <dc:creator><![CDATA[Sirojul Alam]]></dc:creator>
            <pubDate>Sat, 31 Aug 2024 14:39:38 GMT</pubDate>
            <atom:updated>2024-08-31T14:39:38.740Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iqeIdQUWDnVpU5xNab9WrQ.jpeg" /></figure><p>In today’s fast-paced digital world, accessibility is everything. Whether you’re multitasking or just prefer listening over reading, converting your PDFs into audio files can be a game-changer. In this post, I’ll show you how to transform any PDF into a handy audiobook using Python on Google Colab. No fuss, no hassle — just pure efficiency.</p><p><strong>Install the necessary Libraries</strong></p><p>First things first, we need to install a couple of Python libraries: gTTS (Google Text-to-Speech) for generating the audio and PyPDF2 for reading PDF files.</p><pre>!pip install gTTS<br>!pip install pyPDF2</pre><p><strong>Import Libraries and Connect Google Drive</strong></p><p>After installing the libraries, import them and connect your Google Drive to Google Colab so you can easily access your PDFs stored there.</p><pre>from gtts import gTTS<br>from google.colab import drive<br>drive.mount(&#39;/content/drive&#39;)</pre><p><strong>Extract Text from the PDF</strong></p><p>Now, let’s create a function to extract text from the PDF. This function reads through each page of the PDF and compiles the text into a single string.</p><pre>from PyPDF2 import PdfReader<br>def pdf_to_text(pdf_path):<br> text = &quot;&quot;<br> reader = PdfReader(pdf_path)<br> for page in reader.pages:<br>   text += page.extract_text()<br> return text</pre><p><strong>Convert Text to Speech</strong></p><p>Once we’ve got the text from the PDF, it’s time to convert it into an audio file. The text_to_speech function takes the extracted text and saves it as an MP3 file.</p><pre>def text_to_speech(text, output_file):<br>  tts = gTTS(text=text, lang=&#39;en&#39;)<br>  tts.save(output_file)</pre><p><strong>Bringing It All Together</strong></p><p>Now, let’s put it all together to convert a PDF into an audio file. In this example, I’m using a PDF titled Literasi_Unpad.pdf stored in my Google Drive, and the output will be saved as Literasi_Unpad.mp3.</p><pre># Sample usage<br>pdf_file = &#39;/content/drive/MyDrive/E-Book/Literasi_Unpad.pdf&#39;<br>output_audio = &#39;/content/drive/MyDrive/E-Book/Literasi_Unpad.mp3&#39;<br>text = pdf_to_text(pdf_file)<br>text_to_speech(text, output_audio)</pre><p>And just like that, you’ve turned a static PDF into a dynamic, portable audio file you can listen to on the go. Whether you’re on a commute, working out, or just chilling at home, your favorite reads are now more accessible than ever.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=860c0b2833fc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Effortlessly Remove Image Backgrounds with Python]]></title>
            <link>https://medium.com/@sirojmu/effortlessly-remove-image-backgrounds-with-python-cf1ff03996f4?source=rss-240839453f52------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf1ff03996f4</guid>
            <category><![CDATA[image]]></category>
            <category><![CDATA[image-editing]]></category>
            <category><![CDATA[image-processing]]></category>
            <dc:creator><![CDATA[Sirojul Alam]]></dc:creator>
            <pubDate>Wed, 28 Aug 2024 13:05:09 GMT</pubDate>
            <atom:updated>2024-09-01T01:33:05.866Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*TF4ai7pd2fI_hEAqoUmDJQ.jpeg" /></figure><p>Let’s face it — removing backgrounds from images can be a hassle, especially if you’re not a Photoshop wizard. But what if I told you that with just a few lines of Python code, you can automate this task in no time? Whether you’re prepping photos for social media, e-commerce, or just spicing up your design workflow, I’ve got you covered. In this post, I’ll show you how to create a slick background removal app using Python, running it all on Google Colab or Jupyter Notebook. No fancy software or expensive tools needed.</p><p><strong>Setting Up Your Environment</strong></p><p>First things first, if you’re new to Google Colab, it’s a free cloud-based platform that lets you run Python code right in your browser — no installation required. So, let’s dive in.</p><p>Start by spinning up a new notebook in Google Colab, and let’s get the essentials installed:</p><pre>!pip install rembg</pre><p>The rembg package is your go-to library for removing backgrounds from images, while PIL (Python Imaging Library) handles all the image processing magic.</p><p><strong>Uploading Your Image &amp; Removing the Background</strong></p><p>With the setup out of the way, it’s time to upload your image and let the magic happen. Here’s how you do it in Google Colab:</p><pre>from rembg import remove<br>from PIL import Image<br>from google.colab import files<br>uploaded = files.upload()</pre><p>This little snippet will pop up a file picker so you can choose the image you want to edit. Once uploaded, we’ll load that image into our program and strip away the background:</p><pre>import io<br># Grab the first uploaded file<br>file_name = list(uploaded.keys())[0]<br>input = Image.open(io.BytesIO(uploaded[file_name]))<br># Remove the background<br>output = remove(input)<br>output.save(&quot;output.png&quot;)<br># Show the original and the result<br>display(input)<br>display(output)</pre><p><strong>Breaking Down the Code</strong></p><ul><li><strong>Uploading &amp; Loading the Image:</strong> We’re using Google Colab’s files.upload() to upload an image from your computer. That image is then loaded into our code as an Image object using PIL.</li><li><strong>Removing the Background:</strong> The remove() function from the rembg library works its magic by automatically detecting and removing the background. The result is saved as output.png.</li><li><strong>Displaying the Images:</strong> Colab makes it super easy to visualize your work. The display() function lets you see the original image side-by-side with the background-free version.</li></ul><p><strong>Wrapping It Up</strong></p><p>Creating a background remover app with Python and Google Colab is a breeze, and it’s incredibly useful for a ton of applications — whether you’re polishing photos for Instagram, prepping product shots, or just having fun with image processing. The best part? It’s all done in the cloud, so no need to clutter your computer with heavy software.</p><p>Got questions or ideas for leveling up this project? Drop a comment below, and I’ll be happy to help you out!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*TF4ai7pd2fI_hEAqoUmDJQ.jpeg" /><figcaption><strong>Original Image</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*jf4pEuW-Ln7J69rHTIoSaA.png" /><figcaption><strong>Result</strong></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf1ff03996f4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unleashing the Power of Python: Turning Video into Text in a Snap!]]></title>
            <link>https://medium.com/@sirojmu/unleashing-the-power-of-python-turning-video-into-text-in-a-snap-727e98d6c454?source=rss-240839453f52------2</link>
            <guid isPermaLink="false">https://medium.com/p/727e98d6c454</guid>
            <dc:creator><![CDATA[Sirojul Alam]]></dc:creator>
            <pubDate>Wed, 31 Jul 2024 07:02:41 GMT</pubDate>
            <atom:updated>2024-09-01T01:30:10.761Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gk-h9WQXqGWXb0BkYgS8Tg.jpeg" /><figcaption>illustraion</figcaption></figure><p>Hey Tech Enthusiasts! 🚀</p><p>Today, I’m diving into an exciting project that’s bound to tweak the interest of any developer, tech guru, or anyone curious about the magic of coding. I’m crafting a super cool application that transforms voice from videos into text — all within the realms of Google Colab using Python!</p><p>Why, you ask? Well, imagine the possibilities! Accessibility features, content analysis, or just saving yourself the hassle of transcribing long hours of interviews or your favorite YouTube videos. The applications are endless!</p><p><strong>Here’s the Scoop:</strong></p><p>Using the versatile and powerful Python language, this project is more than just coding — it’s about making information accessible and manageable. Google Colab offers the perfect playground for this. It’s not just a tool; it’s a powerhouse that allows for seamless coding without the hassle of setup or system dependencies. Plus, with its easy access to GPUs, it’s like having a supercomputer at your fingertips!</p><p><strong>The Journey Begins:</strong></p><p>I start by setting up my Colab environment, importing libraries like `SpeechRecognition` and `moviepy` — trust me, these are the unsung heroes in the world of audio and video processing in Python. Next, I extract audio from the video, convert it into a format that our speech recognition engine devours, and boom! We’re transcribing.</p><p><strong>Here is the code you want:</strong></p><pre>from google.colab import drive<br>drive.mount(&#39;/content/drive&#39;)<br># Install necessary libraries<br>!pip install pydub<br>!pip install moviepy<br>!pip install SpeechRecognition<br>!pip install transformers<br>!pip install torch<br><br>import moviepy.editor as mp<br>import speech_recognition as sr<br>from pydub import AudioSegment<br>from transformers import pipeline<br>import time<br><br># Paths<br>video_path = &#39;/content/drive/MyDrive/Data/[your_video_file_here]&#39;<br>audio_path = &#39;/content/drive/MyDrive/Data/[your_audio_file.wav]&#39;<br><br># Extract audio from video<br>video = mp.VideoFileClip(video_path)<br>video.audio.write_audiofile(audio_path)<br>recognizer = sr.Recognizer()<br><br># Split audio into chunks<br>def split_audio(audio_path, chunk_length_ms=60000):<br>  audio = AudioSegment.from_wav(audio_path)<br>  chunks = []<br>    for i in range(0, len(audio), chunk_length_ms):<br>      chunks.append(audio[i:i+chunk_length_ms])<br>      return chunks<br><br># Recognize speech from audio chunks with retries<br>def recognize_speech_with_retry(audio_data, retries=3, delay=5):<br>  for attempt in range(retries):<br>    try:<br>      text = recognizer.recognize_google(audio_data)<br>      return text<br>      except sr.RequestError as e:<br>    print(f&quot;Attempt {attempt+1} failed: {e}&quot;)<br>   if attempt &lt; retries - 1:<br>   time.sleep(delay)<br>   else:<br>     raise<br>     except sr.UnknownValueError:<br><br>print(&quot;Google Speech Recognition could not understand audio&quot;)<br>return None<br><br># Recognize speech from all chunks<br>def recognize_chunks(chunks):<br>  full_text = &quot;&quot;<br>  for i, chunk in enumerate(chunks):<br>    chunk_path = f&quot;/content/chunk{i}.wav&quot;<br>    chunk.export(chunk_path, format=&quot;wav&quot;)<br>  with sr.AudioFile(chunk_path) as source:<br>    audio_data = recognizer.record(source)<br>    text = recognize_speech_with_retry(audio_data)<br>  if text:<br>    full_text += text + &quot; &quot;<br>    return full_text<br><br>chunks = split_audio(audio_path)<br>text = recognize_chunks(chunks)<br>print(&quot;Extracted Text: &quot;, text)</pre><p><strong>Stay Tuned:</strong></p><p>In the next I will make a text summarizer that will summarize long text perfectly. Still in Python code, OK!</p><p>Until next time, keep coding and stay awesome! 👨‍💻✨</p><p>— -</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=727e98d6c454" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating a Stunning 3D Surface Plot]]></title>
            <link>https://medium.com/@sirojmu/cara-membuat-grafik-3d-dengan-python-c2b7d5237974?source=rss-240839453f52------2</link>
            <guid isPermaLink="false">https://medium.com/p/c2b7d5237974</guid>
            <category><![CDATA[matplotlib]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[graphics]]></category>
            <category><![CDATA[3d]]></category>
            <category><![CDATA[plotting]]></category>
            <dc:creator><![CDATA[Sirojul Alam]]></dc:creator>
            <pubDate>Thu, 16 Jun 2022 03:12:52 GMT</pubDate>
            <atom:updated>2024-09-06T13:49:54.281Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m5sHHIlrWhQ8u--V4nIoPw.jpeg" /><figcaption>from copilot</figcaption></figure><p>In this post, we’ll dive into creating a visually appealing 3D surface plot using Python’s Matplotlib library. Here are the steps to guide you through the process:</p><p><strong>Import the Necessary Libraries</strong></p><p>We begin by importing matplotlib.pyplot for plotting and numpy for handling numerical operations. Additionally, we import Axes3D from mpl_toolkits.mplot3d to enable 3D plotting.</p><pre>import matplotlib.pyplot as plt<br>import numpy as np<br>from mpl_toolkits.mplot3d import Axes3D</pre><p><strong>Set Up the Plot Figure and Axes</strong></p><p>To start visualizing in 3D, we create a figure object using plt.figure(). The figsize argument controls the size of the figure. Then, we use add_subplot() with the argument projection=&#39;3d&#39; to specify that this plot will be 3D.</p><pre>fig = plt.figure(figsize=(12,12))<br>ax = fig.add_subplot(111, projection=&#39;3d&#39;)</pre><p><strong>Generate Grid Data for the Plot</strong></p><p>Next, we create the data for the plot. We define X and Y as arrays using np.arange() within the range of -4 to 4, and the np.meshgrid() function is used to create a coordinate grid from these arrays. This grid will serve as the basis for calculating the values for Z, which represents the height in the 3D plot.</p><pre>X = np.arange(-4, 4, 0.25)<br>Y = np.arange(-4, 4, 0.25)<br>X, Y = np.meshgrid(X, Y)</pre><p><strong>Compute the Z Values</strong></p><p>We calculate the Z values using a mathematical function. In this case, Z is calculated using the sine of the radial distance R, which is computed as the square root of the sum of the squares of X and Y.</p><pre>R = np.sqrt(X**2 + Y**2)<br>Z = np.sin(R)</pre><p><strong>Create the 3D Surface Plot</strong></p><p>Finally, we use ax.plot_surface() to generate the 3D surface plot. The cmap argument is used to specify the color map, and here we choose &#39;cool&#39; for a visually appealing color scheme.</p><pre>ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=&#39;cool&#39;)<br>plt.show()</pre><p>With these simple steps, you can create a beautiful 3D surface plot in Python! Try experimenting with different functions for Z, and see how the plot transforms.</p><p>You will find a pretty graph like this one:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*rYbn9vKYEjGoI7xwiaOLTQ.png" /><figcaption>result</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c2b7d5237974" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>