<?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: Kim Carl Macapayad</title>
    <description>The latest articles on DEV Community by Kim Carl Macapayad (@kimcarlmc).</description>
    <link>https://dev.to/kimcarlmc</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%2F4063324%2Fa2dfbac3-5128-4362-b8f2-43be6be275e4.jpg</url>
      <title>DEV Community: Kim Carl Macapayad</title>
      <link>https://dev.to/kimcarlmc</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kimcarlmc"/>
    <language>en</language>
    <item>
      <title>Classifying mud crab sex with YOLOv11 — when 200 images and messy real-world labels fight back</title>
      <dc:creator>Kim Carl Macapayad</dc:creator>
      <pubDate>Wed, 05 Aug 2026 06:23:22 +0000</pubDate>
      <link>https://dev.to/kimcarlmc/classifying-mud-crab-sex-with-yolov11-when-200-images-and-messy-real-world-labels-fight-back-46ik</link>
      <guid>https://dev.to/kimcarlmc/classifying-mud-crab-sex-with-yolov11-when-200-images-and-messy-real-world-labels-fight-back-46ik</guid>
      <description>&lt;h2&gt;
  
  
  The problem: crabs don't sort themselves
&lt;/h2&gt;

&lt;p&gt;Mud crab (&lt;em&gt;Scylla&lt;/em&gt; spp.) sex matters a lot in the Philippine seafood trade. Females fetch a higher price for their roe, males are prized for size and meat yield, and counting how many of each pass through a given batch is normally slow, manual work that depends entirely on a buyer or seller's trained eye.&lt;/p&gt;

&lt;p&gt;For my thesis project (built with Joed Peñamante), we set out to automate that counting step: as a crab passes in front of a camera, detect its abdominal flap and classify it — male, female, or the market category local vendors call "gay" (locally "bakla") — using YOLOv11, with a Tkinter desktop interface, running on a Raspberry Pi for real-world, low-cost deployment. The system counts and logs each classification as crabs pass through; it doesn't physically sort or move them — that's a mechanical engineering problem outside our scope as a Computer Engineering thesis.&lt;/p&gt;

&lt;p&gt;It sounded straightforward. It was not.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the abdominal flap, and why it's genuinely hard
&lt;/h2&gt;

&lt;p&gt;In mud crabs, sex is determined visually from the shape of the abdominal flap folded under the body:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Males&lt;/strong&gt; have a narrow, distinct &lt;strong&gt;T-shaped&lt;/strong&gt; flap — easy to tell apart at a glance, and easy for a model to learn.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mature females&lt;/strong&gt; have a broad, &lt;strong&gt;semi-circular&lt;/strong&gt; flap — also visually distinct once mature.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;"Gay" crabs&lt;/strong&gt; — a real, commonly used market classification in the Philippine crab trade — sit in a visually ambiguous middle ground. Their flap shape doesn't cleanly match either the male or mature-female pattern, and it's easy to confuse with an &lt;em&gt;immature&lt;/em&gt; female, whose flap hasn't yet widened into the semi-circular shape.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That last category was the entire difficulty of this project. The male class was never the problem — it was distinguishing a genuinely ambiguous, underrepresented visual class from a superficially similar one.&lt;/p&gt;

&lt;h2&gt;
  
  
  The dataset problem: 200 images, mostly video frames
&lt;/h2&gt;

&lt;p&gt;We worked with roughly 200 labeled images, annotated in Roboflow. Most of these weren't independently captured photos — they were frames extracted from video footage of live crabs.&lt;/p&gt;

&lt;p&gt;That distinction matters more than the raw count suggests. Consecutive video frames of the same crab are nearly identical — same angle, same lighting, same flap position, frame after frame. So while we had ~200 labeled images, our &lt;em&gt;effective&lt;/em&gt; visual diversity was meaningfully lower than 200 independent samples would give you. This is a common trap when building a dataset under real time and resource constraints, and it's worth knowing about before you assume "more frames = more data."&lt;/p&gt;

&lt;p&gt;Layer the "gay" class's rarity on top of that, and we had a small, imbalanced dataset trying to teach a model to distinguish a subtle shape difference — the hardest possible combination for a classifier.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix: train fine-grained, deploy coarse
&lt;/h2&gt;

&lt;p&gt;Rather than force the model to nail a three-way classification that our data couldn't reliably support, we made a deliberate design decision: &lt;strong&gt;train YOLOv11 on all three classes (male, female, gay), but merge "gay" into "female" at the application's final output.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The reasoning was practical, not just statistical convenience:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The "gay" class had too few reliable samples to trust as a standalone prediction in a live application.&lt;/li&gt;
&lt;li&gt;In terms of what the classification is actually used for — counting crabs by market-relevant category — the "gay"/female distinction matters far less than getting male vs. female right.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is a pattern worth remembering if you're ever building a classifier on a small or imperfect dataset: &lt;strong&gt;you don't have to throw away a hard, low-sample class. You can let the model learn from it during training — which can still help it draw better decision boundaries overall — while collapsing it into a more reliable category at the point where predictions actually get used.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What this taught me
&lt;/h2&gt;

&lt;p&gt;A few things I'd tell anyone starting a similar computer vision project with real-world, resource-constrained data:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Count your effective samples, not your raw file count.&lt;/strong&gt; Video-frame datasets look bigger than they behave.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A "hard" class doesn't have to be a wasted class.&lt;/strong&gt; Merging outputs after training is a legitimate way to get value from data you can't fully trust on its own.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Domain-specific visual differences are often subtler than they sound.&lt;/strong&gt; "Different flap shape" undersells just how close an immature female and a "gay" crab can look — the real work was in recognizing that this wasn't a labeling problem, it was a genuinely hard visual distinction.&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;&lt;em&gt;This project runs as a real-time classifier and counter on a Raspberry Pi with a Tkinter interface — crabs are detected and classified as they pass the camera, no physical sorting involved. You can see the more about this project, process, and other projects on &lt;a href="https://kcmacapayad-portfolio.vercel.app/project.html" rel="noopener noreferrer"&gt;my portfolio&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>computervision</category>
      <category>python</category>
      <category>raspberrypi</category>
    </item>
  </channel>
</rss>
