Machine Learning Model is Bad

Need more information. How many images did you train your network on? What resolution are those images? What’s your train/test split? What problem are you even trying to solve with ML?

1 Like

Will also want to know what kind of validation method is being used. Holdout? Cross validation? Mostly we’re looking to learn what size of data you’re actually working with here. Low volume in test can just lead to low confidence as well.

1 Like

My plan is to label more images, I just would rather have an easier fix.

1 Like

Apparently you’re in company with Randall Munroe.

  • 210 images
  • 80% of images are used for training.
  • 10% of images are used for hyper-parameter tuning and/or to decide when to stop training.
  • 10% of images are used for evaluating the model.
  • Detecting the yellow balls
1 Like

Try decreasing your training set and increasing your validation set. 10% validation seems way too low in my experience. Your model also might be overtuned to a specific situation that most of your dataset’s pictures follow (same background/lighting or taken with a specific camera), in which case you will have very bad accuracy for any input image that isn’t in that same environment.


I typically use 25% if there’s enough data available. If you can tag more images that would obviously be best…

1 Like

That was the default for Google Cloud Vision, and that’s why I used it. Do you think that 210 images would be enough for the 25% validation

I’m also retraining with the entire dataset, but only 31 images have labels, the other 386 have no objects.

Thats your problem. You need much more than 31 labeled images. Most if not all of your dataset should contain at least one object.

It was 108 when i properly did it, but for anyone in the future who needs the labeled balls:

Have you experimented with simpler methods? Neural networks are amazing tools, but many times (especially with small data sets) problems can be tackled as well or better by simpler methods, such as conventional computer vision techniques or (for non-CV tasks) linear/logistic regression. Neural networks can model very complex relationships in data, but present opportunities to overfit, which is when a model memorizes the training data instead of learning the underlying patterns.

What is your neural network architecture? It may be worth playing with the number of hidden layers, how many nodes are in each layer, etc. The more layers and nodes you have, the more complex relationships your network can express, which can improve accuracy or introduce overfitting.

How similar is your dataset to the testing set and the actual conditions where the model will be applied? Your testing error is only meaningful if it’s relevant to the application.

I would recommend generating more samples if possible. If you’re working with images, 210 is WAY smaller than the number of features (the number of pixels in the image) you’re working with.


Cool that you’re using machine learning!

I’d recommend using more images to try to get a more comprehensive model.

1 Like

Yeah, you need a ton more images. We have over 2000 balls labeled for ours, and it works well. We use a different vision system though. The WPILib system seems to have several problems and things that just don’t make sense. I think they rushed development too fast. If it doesn’t turn out for you, please stay open to other solutions.

That’s what I did, but our team labeled the entire dataset. Link

1 Like

What’s something that doesn’t make sense? I can look into it if you give me a direction.

Just curious, what vision system do you guys use, and what hardware do you run it on?

You will likely need to combine machine learning with hard-coded logic.
locating a ball could be done with machine learning. But the glue is likely going to be regular code.

camera.seesBall() would be the machine learning thing.
targetBall() would use a combination.

This is basic code for a robot that looks around for nearby balls and yeets them. Would probably get you a more than 5 penalty XD
rotate(rot::clockwise) //Look for balls

Sorry for not seeing your post sooner. We’re using a RasPi 4 4gb model with an Intel Neural Compute Stick 2. We’ve moved to a custom machine learning solution that we plan to release after some field testing.

1 Like

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