<?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: Waqas Ahmad</title>
    <description>The latest articles on DEV Community by Waqas Ahmad (@waqas_ahmad_a106e943c110d).</description>
    <link>https://dev.to/waqas_ahmad_a106e943c110d</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4176054%2Fef5c853d-97b0-4ef8-8a05-70f75304dfb3.png</url>
      <title>DEV Community: Waqas Ahmad</title>
      <link>https://dev.to/waqas_ahmad_a106e943c110d</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/waqas_ahmad_a106e943c110d"/>
    <language>en</language>
    <item>
      <title>We Built a Batch Annotation Platform for Dental X-rays Using SAM 2 — Here's What We Learned</title>
      <dc:creator>Waqas Ahmad</dc:creator>
      <pubDate>Sat, 10 Oct 2026 22:33:57 +0000</pubDate>
      <link>https://dev.to/waqas_ahmad_a106e943c110d/we-built-a-batch-annotation-platform-for-dental-x-rays-using-sam-2-heres-what-we-learned-1p85</link>
      <guid>https://dev.to/waqas_ahmad_a106e943c110d/we-built-a-batch-annotation-platform-for-dental-x-rays-using-sam-2-heres-what-we-learned-1p85</guid>
      <description>&lt;p&gt;&lt;em&gt;For our final year project, we tackled one of the most tedious bottlenecks in medical AI: annotation. Here's how Meta's Segment Anything Model 2 helped us label a dental X-ray dataset in batches instead of one painful image at a time.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  The problem nobody warns you about
&lt;/h2&gt;

&lt;p&gt;Everyone talks about training models. Nobody warns you that before you train anything, you'll spend weeks drawing polygons around teeth.&lt;/p&gt;

&lt;p&gt;For our final year project, we set out to build a data annotation platform for dental X-rays — panoramic radiographs where a dentist needs structures like cavities and wisdom teeth precisely segmented. Manual annotation is slow, expensive, and inconsistent: two annotators will draw two different boundaries around the same cavity. Doing this by hand, image after image, was not feasible in a single semester.&lt;/p&gt;

&lt;p&gt;We needed leverage. That leverage turned out to be SAM 2.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why SAM 2 fits annotation perfectly
&lt;/h2&gt;

&lt;p&gt;The Segment Anything Model 2 (SAM 2), released by Meta, is a promptable segmentation model: give it a point, a box, or a rough mask, and it returns a precise segmentation mask. Its killer feature for our use case is &lt;strong&gt;propagation&lt;/strong&gt; — SAM 2 was designed to track objects across video frames, which means it can carry a segmentation from one image to the next.&lt;/p&gt;

&lt;p&gt;That gave us our core idea: &lt;strong&gt;annotate once, propagate to the batch.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Instead of drawing every mask by hand, the annotator:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Selects a target class — e.g. &lt;em&gt;cavity&lt;/em&gt; or &lt;em&gt;wisdom tooth&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Provides a single prompt (a click or bounding box) on one representative X-ray&lt;/li&gt;
&lt;li&gt;Lets SAM 2 segment that structure and propagate the segmentation across the batch&lt;/li&gt;
&lt;li&gt;Reviews the results and corrects only the failures&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The human shifts from &lt;em&gt;drawing&lt;/em&gt; to &lt;em&gt;reviewing&lt;/em&gt; — a fundamentally faster job.&lt;/p&gt;

&lt;h2&gt;
  
  
  System design
&lt;/h2&gt;

&lt;p&gt;Our platform has three layers:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Frontend — the annotation workspace.&lt;/strong&gt; A web-based UI where the annotator uploads a batch of X-rays, picks the target class from a panel (cavity, wisdom tooth, and others), and places a prompt on one image. Results render as editable overlays — every mask can be accepted, tweaked, or rejected before it counts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Inference backend — SAM 2.&lt;/strong&gt; The prompt plus the image goes to a Python backend serving SAM 2, which returns the mask. For batch mode, we propagate the segmentation across the remaining images in the batch, exploiting the anatomical consistency of dental radiographs: teeth sit in roughly the same regions across panoramic X-rays.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Export layer.&lt;/strong&gt; Accepted annotations are exported in CSV format (alongside the mask data), so the labeled dataset can feed directly into a training pipeline — no conversion step, no lock-in to our tool.&lt;/p&gt;

&lt;h2&gt;
  
  
  Dental X-rays are a hard test case
&lt;/h2&gt;

&lt;p&gt;This wasn't an easy dataset to show off on. Panoramic dental X-rays have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Low contrast&lt;/strong&gt; between cavities and healthy enamel in early-stage decay&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Overlapping structures&lt;/strong&gt; — teeth crowd each other, roots overlap the jaw&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;High anatomical variation&lt;/strong&gt; — missing teeth, fillings, implants, braces all break naive assumptions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What we found: SAM 2's promptable design handles this better than fully automatic segmentation, because the human prompt disambiguates &lt;em&gt;which&lt;/em&gt; structure matters. A click on a cavity tells the model exactly what to segment; the model handles the precise boundary. The review step catches the genuinely ambiguous cases — which are also the cases where two human annotators would disagree anyway.&lt;/p&gt;

&lt;h2&gt;
  
  
  What changed in practice
&lt;/h2&gt;

&lt;p&gt;The honest summary of the project isn't a benchmark table — it's a workflow change. Annotating a batch of X-rays went from an hours-long drawing exercise to a review task: prompt once, let SAM 2 do the repetitive segmentation, and spend human effort only where judgment is actually needed. The review-and-correct loop kept final quality at human-expert level while throughput multiplied, because the scarce resource — a trained eye knowing &lt;em&gt;what&lt;/em&gt; a cavity looks like on an X-ray — was no longer spent tracing pixels.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lessons learned
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Promptable &amp;gt; automatic for expert domains.&lt;/strong&gt; In medical imaging, a fully automatic segmenter that silently mislabels a cavity is dangerous. Keeping a human prompt + review in the loop isn't a compromise — it's the correct design.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Batch propagation exploits dataset structure.&lt;/strong&gt; Medical image batches are far more consistent than natural-image collections. Designing around that consistency is free performance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Export format matters as much as the UI.&lt;/strong&gt; An annotation tool that can't hand clean, portable data (in our case, CSV) to a training script is a demo, not a tool. We built the export path as a first-class feature, not an afterthought.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SAM 2 is a force multiplier, not a replacement.&lt;/strong&gt; The annotator's domain knowledge is still the scarce resource. SAM 2 just lets one expert's judgment cover far more data.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What's next
&lt;/h2&gt;

&lt;p&gt;Ideas we didn't get to in a semester: active learning that routes only the lowest-confidence propagations to human review, extending beyond panoramic X-rays to periapical and bitewing views, and packaging the whole thing as a reusable annotation service for other medical imaging datasets.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Built as a final year project at UMT Lahore by Waqas Ahmad. If you're working on medical image annotation or promptable segmentation, I'd love to compare notes — drop a comment.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>python</category>
      <category>datascience</category>
      <category>computerscience</category>
    </item>
  </channel>
</rss>
