# Optimizing YOLOv8 for detecting defective capsules: annotation strategy

**URL:** <https://discuss.roboflow.com/t/optimizing-yolov8-for-detecting-defective-capsules-annotation-strategy/9145>\
**Category:** 🤝  Community Help\
**Created:** [March 20, 2025, 1:24pm UTC](https://discuss.roboflow.com/t/optimizing-yolov8-for-detecting-defective-capsules-annotation-strategy/9145 "2025-03-20T13:24:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kostya\_Che\_Dev](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/kostya_che_dev/32/6750_2.png) [@Kostya\_Che\_Dev](https://discuss.roboflow.com/u/Kostya_Che_Dev)\
**Post date:** [March 20, 2025, 1:24pm UTC](https://discuss.roboflow.com/t/optimizing-yolov8-for-detecting-defective-capsules-annotation-strategy/9145/1 "2025-03-20T13:24:50Z")

</div>

I am working on a model to detect defective gelatin capsules. I use YOLOv8 and annotate capsules in two classes: **“normal”** and **“defective”**. My dataset currently has 2,000 images and 10,000 annotations (5,000 per class). However, I have some doubts about this approach.

Defects can be very different: cracks, dents, chips, open or damaged halves. Because of this, the shape of the capsules changes, which may make classification more difficult.

Would it be better to annotate all capsules as one class and train the model separately to detect defects? Or maybe there are other approaches that work better for this task?

I would appreciate any advice!

---

<div class="post-metadata">

**Author:** ![Subhranshu\_Mohanty](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/subhranshu_mohanty/32/6510_2.png) [@Subhranshu\_Mohanty](https://discuss.roboflow.com/u/Subhranshu_Mohanty)\
**Post date:** [March 24, 2025, 7:58am UTC](https://discuss.roboflow.com/t/optimizing-yolov8-for-detecting-defective-capsules-annotation-strategy/9145/2 "2025-03-24T07:58:04Z")

</div>

Hey there

I would say labelling each defect as a separate class would make it easier and improve the accuracy like Instead of a single “defective” class, you could label defects separately e.g. “cracked,” “dented,” etc.

you could also train the model on only normal capsules and use an anomaly detection method (autoencoder, one-class SVM, or YOLO-based outlier detection) to flag anything unusual as defective but since you have a lot of data on defects and normal i would suggest the first approach

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex029/uploads/roboflow1/original/1X/bb6edbfa56d0cf2ee603f061e9e09103502cc8cc.png) [@system](https://discuss.roboflow.com/u/system)\
**Post date:** [April 14, 2025, 7:58am UTC](https://discuss.roboflow.com/t/optimizing-yolov8-for-detecting-defective-capsules-annotation-strategy/9145/3 "2025-04-14T07:58:21Z")

</div>

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
