<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.4.1">Jekyll</generator><link href="https://dmanco.dev/feed.xml" rel="self" type="application/atom+xml" /><link href="https://dmanco.dev/" rel="alternate" type="text/html" /><updated>2025-11-03T10:23:48+00:00</updated><id>https://dmanco.dev/feed.xml</id><title type="html">Doch</title><subtitle>Random stuff from a random person. Ranging from tech topics to more casual ones.</subtitle><author><name>Davide Manco</name></author><entry><title type="html">Detecting AI Fakes with Compression Artifacts</title><link href="https://dmanco.dev/2025/09/15/basics-of-image-forensics-1.html" rel="alternate" type="text/html" title="Detecting AI Fakes with Compression Artifacts" /><published>2025-09-15T18:15:09+00:00</published><updated>2025-09-15T18:15:09+00:00</updated><id>https://dmanco.dev/2025/09/15/basics-of-image-forensics-1</id><content type="html" xml:base="https://dmanco.dev/2025/09/15/basics-of-image-forensics-1.html"><![CDATA[<p>Let’s start with some context. Why am I writing this post?</p>

<p>I work at <a href="https://www.fourthline.com/">Fourthline</a>, a company that manages the Know Your Customer (KYC) process for companies like Revolut, TradeRepublic, and N26. <br />
For those who don’t know what KYC is, think of when you register online to use one of these services and are asked to take a selfie and a picture of your ID document to prove you are who you claim to be. <br />
That’s KYC in a nutshell, and as you may guess, we don’t want fraudsters to slip through. If you’ve ever played <a href="https://en.wikipedia.org/wiki/Papers,_Please">Papers, Please</a>, you can imagine this isn’t always easy. <br /></p>

<p>Fraudsters are getting better, and technology is helping them. <br />
Deepfakes and AI-generated selfies and documents have become some of their tools, and my job at Fourthline is also to fight this kind of AI. <br />
Yes, I’m an AI engineer who fights AI. A sort of cyberwar destined to become even more challenging as technology advances. <br /></p>

<p>But to fight deepfakes, I should also study how similar problems were handled in the past. <br />
Image manipulation has existed for decades, long before generative models reached today’s quality. <br />
So let’s go back to 2007 and talk about compression and <strong>Error Level Analysis (ELA)</strong>.</p>

<hr />

<h1 id="compression">Compression</h1>

<p>Almost every image on the internet is compressed; handling uncompressed images everywhere would be too expensive. <br />
Let’s look at an example. <br /></p>

<p>I took an image with my camera with a resolution of 6000x4000. <br />
Quick math: that’s 24,000,000 pixels. Every pixel stores information about color, and color in computer science is usually expressed with 8 bits. <br />
To cover most colors, we need three channels — red, green, and blue — so every pixel carries 8 × 3 bits of information. <br /></p>

<p>The weight of this image should be <code class="language-plaintext highlighter-rouge">6000 × 4000 × 8 × 3 = 576,000,000 bits</code>, or 72 megabytes. <br />
Instead, it weighs only 6 megabytes. <br /> 
Why? JPEG compression. <br /></p>

<h2 id="jpeg-compression-and-artifacts">JPEG compression and artifacts</h2>

<p>JPEG is the most widely used image compression algorithm. <br /></p>

<p>In simple terms, the algorithm works by removing parts of the image that are barely noticeable to the human eye. It has a parameter called <em>quality</em> that sets how aggressive the compression is.<br />
A quality of 100% means very little is removed, while 1% means heavy information loss. <br /></p>

<p>Because information is lost, the image content is altered in subtle ways. If you look at the single pixel values, you’ll notice differences. Depending on the chosen quality, these differences may be invisible to the eye but still exist. <br />
These differences are a trace left by the JPEG compression, a sort of fingerprint. We call them <em>artifacts</em>. <br /></p>

<p>Now the interesting part comes. <br /> 
Since JPEG compression is applied to the entire image, these artifacts should always be <strong>consistent</strong> inside the image. 
If the image is tampered with in some way - say an object is removed in Photoshop - this will affect the JPEG artifacts as well.
You would notice an inconsistency of these artifacts in the particular area of the image that was altered. <br />
And this is exactly what ELA is based on.</p>

<hr />

<h1 id="error-level-analysis">Error Level Analysis</h1>

<p>In 2007, <a href="https://www.hackerfactor.com/">Dr. Neal Krawetz</a> introduced ELA (among other techniques) in his talk <a href="https://www.blackhat.com/html/bh-usa-07/bh-usa-07-speakers.html#Krawetz">A Picture’s Worth…</a>. <br />
The idea is simple:</p>

<ul>
  <li>Take the image to analyze</li>
  <li>Compress it again with JPEG at a chosen quality - this will become a parameter of ELA</li>
  <li>Calculate the difference between the two images</li>
</ul>

<p>The result is an ELA map to interpret. <br /> 
The assumption here is that the image (or parts of it) was compressed with JPEG at some point. <br /></p>

<p>Let’s use a toy example to explain how it works. <br /></p>

<h2 id="toy-example">Toy example</h2>

<p>Using something from my domain of work, let’s consider this specimen of a French national ID card. <br /></p>

<p><img src="/assets/images/ela/original.jpg" alt="French specimen" /></p>

<p>Suppose I know it was compressed at JPEG quality 95%. I’ll use that later. <br />
Now, I inpaint the image with an AI model and get this:</p>

<p><img src="/assets/images/ela/deepfake.png" alt="Deepfake" /></p>

<p>And, importantly, I <strong>save this deepfake in PNG format</strong>. <br />
Unlike JPEG, PNG uses <em>lossless</em> compression, meaning no information is lost. <br /></p>

<p>Now, using the information above, we perform ELA with a <strong>JPEG quality of 95%</strong>.
In this way, the part of the image that was already compressed with the same quality factor should not produce any new artifact.</p>

<table>
  <thead>
    <tr>
      <th><img src="/assets/images/ela/original.jpg" alt="French specimen" /></th>
      <th><img src="/assets/images/ela/ela_original.jpg" alt="ELA French specimen" /></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><img src="/assets/images/ela/deepfake.png" alt="Deepfake" /></td>
      <td><img src="/assets/images/ela/ela_deepfake.jpg" alt="French specimen" /></td>
    </tr>
  </tbody>
</table>

<p>The tampered area is obvious. We successfully detected the deepfake ID and blocked a fraudster. <br /></p>

<p>But in reality, you may not know the original JPEG quality, and it’s unlikely that the manipulated image (previously a JPEG) would be saved as PNG.</p>

<h2 id="real-example">Real example</h2>

<p>Now let’s assume the deepfake was saved as JPEG. <br />
We don’t know the quality factor. We only know that if the image was altered, part of it will be double-compressed and part single-compressed, producing inconsistency.</p>

<p>We perform ELA with JPEG quality 80% for both images.</p>

<table>
  <thead>
    <tr>
      <th><img src="/assets/images/ela/original.jpg" alt="French specimen" /></th>
      <th><img src="/assets/images/ela/ela_original_80.jpg" alt="ELA French specimen" /></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><img src="/assets/images/ela/deepfake.png" alt="Deepfake" /></td>
      <td><img src="/assets/images/ela/ela_deepfake_80.jpg" alt="French specimen" /></td>
    </tr>
  </tbody>
</table>

<p>Now ELA feels more like art. <br />
There’s a clear difference, but without knowing tampering occurred, could you detect it from the map alone? <br />
To better understand how to interpret an ELA map, we can take some notes from how JPEG works: <br /></p>

<ul>
  <li>JPEG creates more artifacts in high-contrast areas (like text or borders), making ELA brighter there.</li>
  <li>Flat surfaces should have uniform ELA values.</li>
  <li>Similar textures should produce similar ELA.</li>
</ul>

<p>If some part of the image doesn’t respect these ‘rules’, then it might be suspicious. Like the deepfaked face on the ID, with a suspiciously bright ELA. <br />
For more tips, see <a href="https://fotoforensics.com">FotoForensics</a> and their tutorials.</p>

<hr />

<h1 id="conclusions">Conclusions</h1>

<p>So, can ELA be a solution to detect AI-manipulated images? <br />
No, not by itself anyway. <br /></p>

<p>ELA is just a tool in the Image Forensics toolbox that can help fight deepfakes. <br />
But many other things can be used together with ELA, such as EXIF information, PRNU, PCA and so on. <br />
And probably some of these techniques will be the topic for another post.</p>]]></content><author><name>Davide Manco</name></author><category term="ai" /><category term="tech" /><category term="image" /><category term="forensics" /><summary type="html"><![CDATA[Let’s start with some context. Why am I writing this post?]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://dmanco.dev/assets/images/ela/deepfake.png" /><media:content medium="image" url="https://dmanco.dev/assets/images/ela/deepfake.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">AI Engineers aren’t safe from being replaced by AI</title><link href="https://dmanco.dev/2025/08/17/fear-not-even-ai-engineers-will-be-replaced-by-ai.html" rel="alternate" type="text/html" title="AI Engineers aren’t safe from being replaced by AI" /><published>2025-08-17T15:32:31+00:00</published><updated>2025-08-17T15:32:31+00:00</updated><id>https://dmanco.dev/2025/08/17/fear-not-even-ai-engineers-will-be-replaced-by-ai</id><content type="html" xml:base="https://dmanco.dev/2025/08/17/fear-not-even-ai-engineers-will-be-replaced-by-ai.html"><![CDATA[<p>It quickly became small talk; whenever I speak with a fellow engineer working in tech, we somehow always end up in the same direction:</p>

<blockquote>
  <p>“AI agents are getting so smart nowadays, my job will eventually be replaced by them. You don’t have to worry about this instead. You are an AI engineer, you create AIs, you cannot be replaced.”</p>
</blockquote>

<p>My face takes a specific expression at this point, showing some sort of discomfort, mixed with a “how do I explain this now in simple terms?” kind of face. The kind of face you have when you meet a stranger in the elevator and you don’t know how to act.</p>

<p>The fact is, it will be very likely that my job will be replaced sooner than most developer jobs.</p>

<p>Let’s dive into the reasons why I think this, starting by defining what an AI engineer is.</p>

<hr />

<h2 id="what-exactly-is-an-ai-engineer">What exactly is an AI engineer?</h2>

<p>The idea for this post came after seeing this image on my LinkedIn feed:</p>

<p><img src="/assets/images/1_tXcgmhR3NbSYRefglt9g_A.jpeg" alt="Book page" /></p>

<p>This excerpt was posted by Arvind Narayanan, and it comes from his book “AI Snake Oil: What Artificial Intelligence Can Do, What It Can’t, and How to Tell the Difference”, written together with Sayash Kapoor.<sup id="fnref:1"><a href="#fn:1" class="footnote" rel="footnote" role="doc-noteref">1</a></sup></p>

<p>Although I didn’t read the book myself, I think this introduction explains the current situation with AI — and AI engineers — very well. At this moment in the world, artificial intelligence is everything and nothing at the same time.<br />
ChatGPT is AI, the software that post-processes images on your camera phone is AI, the algorithm that selects the best commercials to show you on social media is AI, the non-playing characters on your latest videogame are AI.<br />
And yet, these four types of artificial intelligence are very different from each other.</p>

<p>ChatGPT is an LLM, a transformer-based architecture with billions of parameters.<br />
The image processing algorithms on your phone are likely small and efficient convolutional neural networks designed to work with the computational power of your (relatively) tiny device.<br />
Recommender systems are quite complicated, and they could use many different kinds of technologies specifically engineered for the field of application.<br />
The AI of NPCs in video games are often just classical pathfinding and search algorithms, like A*.</p>

<p>Technologically speaking, the knowledge you need to develop any of these AIs is different from each other. Sure, some of the underground fundamentals are the same — in the end, neural networks are almost everywhere — but going back to the figurative examples used in the image above, you can say that both the car and the bike use wheels, but you wouldn’t call a bike shop to fix your car’s wheel — or a car mechanic to fix the engine of a rocket.</p>

<p>So how do we differentiate between these AIs? The answer is: we don’t.<br />
Currently, everything is marketed as “Artificial Intelligence” without any clarification of what this means. And this affects the job title too; a person having the “AI engineer” title could literally do everything. I have even seen many people claiming they were AI engineers while they were just using ChatGPT APIs to build their software.</p>

<p>If I start looking for a job as an AI engineer, I would receive job offers of any possible kind of AI out there that I don’t even care about.<br />
On the opposite side, since I mainly work with images, I could say I’m a Computer Vision Engineer, and I would receive tons of job offers that have nothing to do with AI, since Computer Vision is a far wider field than only AI.</p>

<p>So, what exactly is an AI engineer? Well, I came to the conclusion that it is whatever you want it to be.</p>

<hr />

<h2 id="why-are-you-worried-that-you-will-be-replaced">Why are you worried that you will be replaced?</h2>

<p>It’s an understandable question. I just said that AI is an umbrella term that encapsulates many different kinds of subjects. LLMs like ChatGPT are only a part of what is called AI.<br />
So why should I be worried?</p>

<p>The thing is, these LLMs and foundation models are becoming so general that they are starting to include way more domains under their “side” of the AI world. Just a few days ago, Meta released their new version of DINO, a versatile, powerful and efficient vision model that could be easily applied to different tasks with very little work. Without using annotations and with very good performances. No more need to do research about a certain topic — you already have a plug-and-play solution that will probably work for many applications.</p>

<p>This is the direction AI is taking: cannibalizing all the other branches of AI into general models that can be applied to everything. Why bother tailoring a solution to a specific problem when you can just use the latest generalization breakthrough from big tech? We’ll eventually reach a point where having AI engineers and researchers will no longer be convenient for most companies. The best AI researchers will be concentrated in big tech, and the rest of the market will be highly saturated. Tailored AI solutions will become a luxury that most companies will happily avoid.<sup id="fnref:2"><a href="#fn:2" class="footnote" rel="footnote" role="doc-noteref">2</a></sup></p>

<p>Luckily, this isn’t the case yet. General models still aren’t specialized enough for many domains — especially when data from those domains is scarce or difficult to obtain. It’s not possible to achieve the best outcomes by only relying on a general model. But give it a few years, and this will change. Models will become so general that with only a small sample from the domain you want to apply them to, they’ll quickly specialize for that application.</p>

<p>Most AI engineers will be replaced by AI sooner than software developers, who will still be needed to integrate these AI models into applications.<br />
And I don’t think AI agents can steal their jobs completely — not yet, at least. Someone still has to use the AI to build the application they want, and that person needs the knowledge to ensure the AI is doing the right thing in the best way possible. This isn’t something AI can fully replace, since agents need a user, and that user has to know what they’re building.</p>

<p>But this is the topic for a different post. :)</p>

<div class="footnotes" role="doc-endnotes">
  <ol>
    <li id="fn:1">
      <p>I do not personally know the authors, and I am not affiliated with them in any way. The purpose of the link is only for credit to the authors — I gain nothing from it. <a href="#fnref:1" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
    <li id="fn:2">
      <p>In my opinion, this will also bring a flattening of the curve of AI progress, as there will be fewer and fewer AI engineers, leading to fewer ideas and research, with only a niche of very experienced and stubborn (as most seniors are) engineers working in the field. <a href="#fnref:2" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
  </ol>
</div>]]></content><author><name>Davide Manco</name></author><category term="ai" /><category term="random" /><summary type="html"><![CDATA[It quickly became small talk; whenever I speak with a fellow engineer working in tech, we somehow always end up in the same direction:]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://dmanco.dev/assets/images/1_tXcgmhR3NbSYRefglt9g_A.jpeg" /><media:content medium="image" url="https://dmanco.dev/assets/images/1_tXcgmhR3NbSYRefglt9g_A.jpeg" xmlns:media="http://search.yahoo.com/mrss/" /></entry></feed>