Looking for advice on increasing accuracy and speed of predictions #2036
-
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi @GraysonButcher, Thanks for the extensive documentation of your workflow so far!! That might be a contender for the most thorough description of a problem that we've ever received here 😁 Let's dig in:
You might consider using a magnetometer in your setup as it's been well validated for HTR. This paper from Adam Halberstadt even describes a cool approach for handling the data analysis piece. Not sure how it works in an arena like yours, but could be worth a shot :) In case you're not at the limit of your camera's capacity, you could try some of the tips here, in particular the binning since you have resolution to spare. If the issue is in acquisition, try out campy which has an easy configuration system for messing around with encoding settings so that your acquisition PC can keep up with the high FPS data stream or use the GPU for accelerated encoding.
Yep, the mAP score is a best effort metric that conveniently summarizes performance into a single number, but to use it appropriately, you'd really need to do a good bit of work to determine the true variability in your data. This page describes this in a lot more detail. In SLEAP, the problem is indeed that the number of keypoints you drop will greatly affect the OKS (and consequently mAP), even more so when you have few keypoints. I would recommend just treating it as something that allows you to compare relative performance between different model configurations trained on the same data.
Not sure about the smoothing across time (SLEAP predicts on individual images without temporal dependencies), but the rest can totally happen just by chance since model optimization has multiple layers of stochasticity. For example, it might be that several of your almost identical frames land in the validation set by chance, making them underrepresented overall.
Alright, so let's get into some model optimization, starting off with your favorite model: First off, you can decrease the validation fraction to 0.1, which will recover a bit more of your labels to be used for training. Second, set your sigma to 2.5. A sigma of 5 is pretty huge, especially for trying to recover HTRs! The sigma controls the spread of the confidence maps. The bigger they are, the easier it is to train, but the less spatially precise your estimates will be. This notebook covers some theory and has some experiments that help build an intuition for this behavior. Third, after retraining with the above changes, try training again, but this time, enable the "Use Trained Model" and "Resume Training" checkboxes. This will initialize the model with the weights from your last run. Importantly, also enable the "Online Mining" checkbox. This turns on a special optimization mode that will upweight underperforming node types, encouraging the model to focus more on hard nodes that are often missing. We find this works great when we're starting off doing well in general, but using it when training from scratch often leads to instability. You're welcome to try both, but I think resuming from the model that's doing well as a baseline should help you bridge that last gap.
Assuming the model isn't majorly misconfigured, labeling should actually always help. We didn't think it would until recently when we started experimenting with very large dataset sizes (10k-100k labels), and it turns out that it just keeps getting better -- even with a limited capacity model like the ones SLEAP uses! That said, it's definitely diminishing returns past ~1k, so you're really just optimizing for the outliers and to improve generalization across datasets/animals.
If your goal is to just increase throughput, the easiest thing is to increase the batch size. The default is 4 so that images will fit on most GPUs, but that's pretty conservative and usually won't make use of the whole GPU's capacity. Try 16 or 32 and see where you're at. You'll need to use the CLI ( Beyond that, you've already observed how changing the model can affect speed. I would focus on getting to a model that is accurate before tuning it for speed, but the thing that'll give you the most gain will definitely be setting the output stride to 4 or 8. This will subsample the confidence maps which will drastically improve speed at the cost of decreased resolution of your landmarks (i.e., you'll get more quantization error). Give these tips a go and let us know how it goes! Cheers, Talmo |
Beta Was this translation helpful? Give feedback.
Hi @GraysonButcher,
Thanks for the extensive documentation of your workflow so far!! That might be a contender for the most thorough description of a problem that we've ever received here 😁
Let's dig in:
You might consider using a magnetometer in your setup as it's been well validated for…