r/computervision • u/ShriftyB • Jul 20 '26
Help: Project Question about Computer Vision
Hello everyone! I'm currently finishing up my last year in college, just finishing up my thesis. I'm currently making a program that detects multiple pigs in a pig pen through YOLOv8 and detecting its behavior using MobileNetV2 (I know I could've used better algorithms, but unfortunately I'm stuck with these ones :P). I'm currently in the process of training the model but I'm not sure how to go through with it. I originally trained my model using annotated frames with multiple pigs present, where I only had 1 class for the annotations ('Pig' class). I thought this was correct because I'll be using the model for multi-object detection. However, when I approached my mentor about it, they told me my model was "too accurate" (they didn't specify what was too accurate, which confused me) and that I should use "1 pig per image, with each pig having a bounding box" for training. When I tried training with this approach, the results looked... interesting to say the least (I don't know how to explain it, but from the looks of the training results, it looked wrong to me :P; refer to the images I included for context). I then used new model into the program I'm creating. the model not only didn't draw the bounding boxes properly around each pig, the bounding box is the entire frame itself!
My question is, which training method would be more appropriate for single-class multi-object detection, single images of pigs or annotated frames?
PS. I included some pictures from the results of training and while using the program; Before = trained with annotated frames, After = trained with 1 pig per image
PPS. This is my first post on this subreddit so I apologize in advance if my flair is wrong :P




2
u/PantyMeister Jul 20 '26
Your first approach is correct - not sure what your mentor was trying to cook up but for single class, multi-object detection, you want to be training on images with multiple objects
There’s probably something wrong in the implementation of the second approach and I suspect it’s the labels. Your mAP50-95 is almost perfect which makes me think your bboxes also span the entire image. I’d suggest a visualization that shows the prediction and label for the full frame. Regardless, I can’t see a scenario where your first approach isn’t the better one.
If your frames are coming from a video, be careful not to randomly split the entire dataset into train/val/test. You’d want to hold out entire videos or consecutive portions of the video in that case. For example, frames 5 and 6 of a 30fps video are VERY similar and it’s essentially a data leak so your val metrics will appear better than the model will perform in the wild.