<?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: jins zhu</title>
    <description>The latest articles on DEV Community by jins zhu (@jins_zhu_10096cef92aba38b).</description>
    <link>https://dev.to/jins_zhu_10096cef92aba38b</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%2F4020471%2F41ae1b6e-dd24-4139-b9e3-8b6a25b4dd72.png</url>
      <title>DEV Community: jins zhu</title>
      <link>https://dev.to/jins_zhu_10096cef92aba38b</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jins_zhu_10096cef92aba38b"/>
    <language>en</language>
    <item>
      <title>How We Trained a 90.6% mAP50 Valve Detection Model with Iterative Pseudo-Labeling</title>
      <dc:creator>jins zhu</dc:creator>
      <pubDate>Wed, 08 Jul 2026 03:56:29 +0000</pubDate>
      <link>https://dev.to/jins_zhu_10096cef92aba38b/how-we-trained-an-837-map50-valve-detection-model-with-iterative-pseudo-labeling-4lhi</link>
      <guid>https://dev.to/jins_zhu_10096cef92aba38b/how-we-trained-an-837-map50-valve-detection-model-with-iterative-pseudo-labeling-4lhi</guid>
      <description>&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;Underground gas infrastructure inspection generates hundreds of thousands of photos. Each valve well contains multiple valves of different types — gate valves, globe valves, ball valves, and others. Manually classifying and cataloging these is slow, expensive, and error-prone.&lt;/p&gt;

&lt;p&gt;We needed an AI model that could automatically detect and classify valves in inspection photos. The challenge? We started with only &lt;strong&gt;30 manually annotated images&lt;/strong&gt; and a budget of zero for professional annotation.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Solution: Iterative Pseudo-Labeling
&lt;/h2&gt;

&lt;p&gt;Instead of paying for annotations, we built a self-improving pipeline:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Start small&lt;/strong&gt;: Train on 30 hand-labeled images&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pseudo-label&lt;/strong&gt;: Use the current model to annotate unlabeled images&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Filter&lt;/strong&gt;: Keep only high-confidence predictions (≥0.5)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Retrain&lt;/strong&gt;: Train a new model on the expanded dataset&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Repeat&lt;/strong&gt;: Each iteration improves the model, which improves the labels&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Results After 10 Iterations
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Round&lt;/th&gt;
&lt;th&gt;Images&lt;/th&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;mAP50&lt;/th&gt;
&lt;th&gt;mAP50-95&lt;/th&gt;
&lt;th&gt;Notes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;R1&lt;/td&gt;
&lt;td&gt;30&lt;/td&gt;
&lt;td&gt;YOLOv8n&lt;/td&gt;
&lt;td&gt;28.1%&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;td&gt;Hand-labeled only&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;R3&lt;/td&gt;
&lt;td&gt;368&lt;/td&gt;
&lt;td&gt;YOLOv8n&lt;/td&gt;
&lt;td&gt;50.9%&lt;/td&gt;
&lt;td&gt;30.2%&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;R4&lt;/td&gt;
&lt;td&gt;1,626&lt;/td&gt;
&lt;td&gt;YOLOv8n&lt;/td&gt;
&lt;td&gt;65.5%&lt;/td&gt;
&lt;td&gt;49.6%&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;R6&lt;/td&gt;
&lt;td&gt;2,007&lt;/td&gt;
&lt;td&gt;YOLOv8s&lt;/td&gt;
&lt;td&gt;70.8%&lt;/td&gt;
&lt;td&gt;52.1%&lt;/td&gt;
&lt;td&gt;Architecture upgrade&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;R7&lt;/td&gt;
&lt;td&gt;3,937&lt;/td&gt;
&lt;td&gt;YOLOv8s&lt;/td&gt;
&lt;td&gt;80.5%&lt;/td&gt;
&lt;td&gt;63.6%&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;R8&lt;/td&gt;
&lt;td&gt;8,506&lt;/td&gt;
&lt;td&gt;YOLOv8s&lt;/td&gt;
&lt;td&gt;90.6%&lt;/td&gt;
&lt;td&gt;68.9%&lt;/td&gt;
&lt;td&gt;Previous best&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;R9&lt;/td&gt;
&lt;td&gt;18,608&lt;/td&gt;
&lt;td&gt;YOLOv8s&lt;/td&gt;
&lt;td&gt;81.3%&lt;/td&gt;
&lt;td&gt;65.0%&lt;/td&gt;
&lt;td&gt;Too much noise!&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;R10&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;9,038&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;YOLOv8s&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;90.6%&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;79.3%&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Filtered dataset&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Key Lessons
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Model Architecture Matters More Than Data Size (Early On)
&lt;/h3&gt;

&lt;p&gt;Upgrading from YOLOv8n (3M params) to YOLOv8s (11M params) at Round 6 gave a &lt;strong&gt;+4.3% mAP50&lt;/strong&gt; boost — the single largest improvement from any single change. If your model is underfitting, more data will not help until you increase capacity.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Data Quality &amp;gt; Data Quantity
&lt;/h3&gt;

&lt;p&gt;When we doubled the dataset from 8,506 to 18,608 images (R9), performance actually &lt;strong&gt;dropped&lt;/strong&gt; from 90.6% to 81.3% mAP50. The culprit? Low-confidence pseudo-labels introducing noise.&lt;/p&gt;

&lt;p&gt;The fix was counterintuitive: we &lt;strong&gt;removed&lt;/strong&gt; 60% of the data. By filtering to confidence ≥0.5, we reduced the dataset to 9,038 images — and mAP50 jumped to &lt;strong&gt;90.6%&lt;/strong&gt; (R10). That is a &lt;strong&gt;+6.9% improvement over R8&lt;/strong&gt; with &lt;em&gt;fewer&lt;/em&gt; images.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rule of thumb&lt;/strong&gt;: A smaller, cleaner dataset beats a larger, noisier one. Always filter pseudo-labels aggressively. In our case, cutting the dataset in half while raising quality gave the biggest single-round improvement in the entire project.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Pseudo-Labeling Has Diminishing Returns
&lt;/h3&gt;

&lt;p&gt;The biggest gains came in the early rounds:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;R2→R3: +20.7% mAP50 (from 30.2% to 50.9%)&lt;/li&gt;
&lt;li&gt;R3→R4: +14.4% mAP50&lt;/li&gt;
&lt;li&gt;R7→R8: +3.2% mAP50&lt;/li&gt;
&lt;li&gt;R8→R10: +6.9% mAP50 (but only after fixing data quality)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each doubling of data yields less improvement. Beyond ~10K images, you need fundamentally better annotations (human review) or better architectures to see significant gains.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Per-Class Analysis Reveals Bottlenecks
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Class&lt;/th&gt;
&lt;th&gt;mAP50&lt;/th&gt;
&lt;th&gt;Precision&lt;/th&gt;
&lt;th&gt;Recall&lt;/th&gt;
&lt;th&gt;Issue&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Globe Valve&lt;/td&gt;
&lt;td&gt;94.7%&lt;/td&gt;
&lt;td&gt;89.0%&lt;/td&gt;
&lt;td&gt;86.6%&lt;/td&gt;
&lt;td&gt;Excellent&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Gate Valve&lt;/td&gt;
&lt;td&gt;86.1%&lt;/td&gt;
&lt;td&gt;89.9%&lt;/td&gt;
&lt;td&gt;66.6%&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Low recall&lt;/strong&gt; — many missed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ball Valve&lt;/td&gt;
&lt;td&gt;81.1%&lt;/td&gt;
&lt;td&gt;71.9%&lt;/td&gt;
&lt;td&gt;75.8%&lt;/td&gt;
&lt;td&gt;Confusion with gate valve&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Other Valve&lt;/td&gt;
&lt;td&gt;72.8%&lt;/td&gt;
&lt;td&gt;66.9%&lt;/td&gt;
&lt;td&gt;68.0%&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Scarce samples (4%)&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Gate valve has great precision but poor recall — the model is too conservative. Other valve has too few training samples. These insights guide where to invest annotation effort.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. GPS Metadata is an Underused Asset
&lt;/h3&gt;

&lt;p&gt;93% of our inspection images contained EXIF GPS data. This enabled us to build an interactive inspection map showing 650+ valve well locations across three Chinese provinces. For infrastructure companies, geospatial AI is a game-changer — detection results are not just labels, they are map pins.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Next
&lt;/h2&gt;

&lt;p&gt;We are continuing to iterate:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;R11+&lt;/strong&gt;: Class-specific augmentation targeting the Other Valve category (only 4% of data)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Model upgrade&lt;/strong&gt;: Testing YOLOv8m (25M params) if memory allows&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Production deployment&lt;/strong&gt;: ONNX export for edge devices&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Active learning&lt;/strong&gt;: Human review of borderline predictions to further improve label quality&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try It Yourself
&lt;/h2&gt;

&lt;p&gt;The model is available on Hugging Face with a commercial license. Try the &lt;a href="https://huggingface.co/spaces/lg227210/valve-detection-demo" rel="noopener noreferrer"&gt;live demo&lt;/a&gt; — upload your inspection photo and see instant results.&lt;/p&gt;

&lt;p&gt;If you are building AI for industrial inspection, reach out — I offer custom model development starting at $500.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Built on Apple M4 Mac Mini with PyTorch MPS acceleration. Total training time: ~50 hours across 10 rounds.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>computervision</category>
      <category>yolo</category>
      <category>industrial</category>
    </item>
  </channel>
</rss>
