Election 2026 A Forecast of Every Senate, House & Governor Race See the Forecast

Classifying Curiosity Rover Images

Deep Learning
Computer Vision
Transfer Learning
TensorFlow
Class Imbalance
Mars
A three-stage ResNet-50 transfer learning pipeline for 25 classes of Curiosity rover imagery. Errors on held-out images are driven mainly by visually similar classes rather than by class imbalance.
Published

April 18, 2026

In collaboration with Emily Mader, Sarah Son, Peter Le and Will Yang

The Decision

Evaluate the classifier on macro-F1 across rare classes instead of headline accuracy.

Takeaways

  • With class weighting, the final model reaches 76.5% accuracy and 0.666 macro-F1 on held-out images.
  • Per-class performance follows how visually distinctive a class is. No measurable dependence on class size was found.
  • Under simulated dust on the optics, accuracy falls by 4.2 percentage points.

Autonomous navigation on Mars depends on the rover correctly identifying what its cameras observe. This project trained a three-stage transfer learning pipeline, built on ResNet-50, to classify images from Curiosity’s onboard cameras into 25 label classes. These cover surface features such as ground and horizon, instruments such as the drill and scoop, and the calibration targets carried by each instrument.

The original report argued that overall accuracy is a misleading metric for planetary data, and that argument survives re-examination. A subsequent review of the held-out predictions produced two further findings that the original report did not make; both are discussed below.

Source code: github.com/olivia-jackson-lambert/mars-project

The Data

The dataset was collected by Stanboli and Wagstaff at NASA in 2017 from three of Curiosity’s cameras and contains 6,691 labelled images. Because aspect ratios vary up to 3.0, each image was padded by reflection to a 256 by 256 square; stretching would have distorted the instrument shapes on which classification depends.

A grid of 19 real Curiosity camera images, one per class, each labelled with its class name. The APXS Cal Target is a clean circular disc and the Observation Tray shows a checkerboard; instruments such as the drill, DRT, inlet and scoop are grey metal against orange sand.

One example image per class from the held-out test set.

Three classes (Drill Holes, Sun and Turret) have no examples in the held-out test split, which affects how the headline score is computed, as discussed below. A further three (APXS, Portion Box and Portion Tube Opening) have no image file in the archive, so the grid shows 19 of the 22 classes measured by the test set.

The grid also illustrates the difficulty of the task. The calibration targets, with their circular patterns and machined edges, resemble nothing else in the set, whereas the drill, the DRT, the scoop and the inlet are all grey metal photographed against similar sand at a similar scale.

The Pipeline

Each stage relaxes the constraints of the one before it.

Stage 1, frozen backbone. ResNet-50, pretrained on ImageNet, with all convolutional weights fixed and only a new classifier head trained. This stage measures how far generic visual features transfer to Martian imagery without adaptation.

Stage 2, partial unfreezing. The final convolutional block, conv5, was unfrozen so that the network could adapt its highest-level features to Martian textures. Validation accuracy rose substantially, to 0.968.

Stage 3, class weighting. The architecture is unchanged from Stage 2, but the loss is weighted by inverse class frequency and model selection uses macro-F1 rather than accuracy. The aim is to prevent the model from neglecting rare classes.

Results

Stage Test accuracy Test macro-F1
Majority-class reference (always predict Wheel) 0.2299
Stage 1, frozen backbone 0.7172 0.6047
Stage 3, class weighted 0.7648 0.6656

The notebooks recorded only the 0.968 validation accuracy for Stage 2 and never its test figures, so Stage 2 is omitted from the table rather than estimated.

Confusion matrix for the Stage 3 model across the 22 classes present in the test set, each row normalised to sum to one. Most weight sits on the diagonal. DRT Side is split almost evenly between DRT Side and Scoop, DRT Front is most often predicted as Wheel, and Inlet spreads across Inlet, Wheel and Rover Rear Deck.

Stage 3 confusion matrix on held-out images, normalised by true class.

The Stage 2 figure of 0.968 was measured on validation data for a model selected on accuracy, and such a model can score well overall while performing poorly on the rarest classes. Stage 3 is selected on macro-F1, which weights every class equally, and its test accuracy of 0.765 is therefore the more reliable estimate of performance.

Dependence of Macro-F1 on the Class Set

Macro-F1 is the mean of the per-class F1 scores. The set of classes included in that mean is a choice, and in this case it has a substantial effect on the result.

Bar chart of Stage 3 test macro-F1 under three class sets: 0.7261 over the 22 classes present in test, 0.6656 over 24 classes as reported, and 0.6389 over all 25 label indices.

The same Stage 3 predictions scored with three different sets of classes.

Drill Holes, Sun and Turret have no test examples, but the model occasionally predicts two of them, which brings them into scikit-learn’s default label set. Each of these classes then scores an F1 of exactly zero and lowers the mean.

Classes averaged Macro-F1
The 22 classes present in test 0.7261
24 classes, the default and the reported figure 0.6656
All 25 label indices 0.6389

The predictions are identical in all three rows. The value of 0.7261 is the better description of performance on the classes that the test set can measure, and the reported 0.6656 understates it by about 0.06. Either figure is defensible provided the class set is stated alongside it, which the original report did not do.

Class Size and Visual Similarity

The original report attributed the difficulty of the task to class imbalance. The held-out predictions do not support that interpretation.

Scatter of per-class F1 score against test set class size on a log scale. Points show no trend. The four calibration targets, marked as red diamonds, all score above 0.9, while DRT Front, Inlet and Scoop score near 0.2 or below.

Per-class F1 against the number of test images in the class. Mastcam Cal Target and Portion Box both have 48 test images, so their markers are nudged apart slightly.

Across the 22 classes with test examples, the rank correlation between class size and F1 is +0.15 (p = 0.50), consistent with no relationship. DRT Front has 60 test examples, more than all but five other classes, yet scores an F1 of 0.125, while APXS Cal Target has 14 and scores 1.000.

The visual character of the object is a considerably better predictor of performance.

Group Mean F1 Mean test examples
Calibration targets 0.953 35
Instruments and terrain 0.676 65

The calibration targets score far higher despite being rarer on average. This is physically reasonable: a calibration target is designed to be visually unambiguous, since it must be recognisable under changing illumination. The drill, scoop, DRT and inlet, by contrast, are metal instruments imaged against similar sand at a similar scale, and they genuinely resemble one another.

The SAM-2 analysis points to the same conclusion by a different route. For DRT Side images misclassified as Scoop, masking individual regions never changed the prediction by more than 0.002, which suggests that the error is not localised in any single region and arises instead from the overall similarity of the two instruments.

Class weighting therefore addressed the first problem identified, rare classes going undetected, but it cannot by itself resolve confusion between classes that look alike.

Dust Robustness

Rover optics accumulate dust over a mission, so a model that performs well only on clean images would be of limited operational use. To test this, simulated dust was applied to the held-out test images and the Stage 3 model was re-scored without retraining.

Two bar charts stacked vertically. Test accuracy falls from 0.7648 on clean images to 0.7226 with simulated dust, a drop of 0.0421. Test macro-F1 falls from 0.6656 to 0.6371, a drop of 0.0285.

Stage 3 test accuracy and macro-F1 on clean and dust-degraded images.
Condition Accuracy Macro-F1
Clean 0.7648 0.6656
Simulated dust 0.7226 0.6371
Drop 0.0421 0.0285

Accuracy falls by 4.2 percentage points and macro-F1 by 0.029. The degradation is real, although an accuracy of 72.3% on degraded images, from a model trained only on clean frames, is a reasonable result.

Two caveats apply. The dust is synthetic, a filter applied after capture, so it reproduces the loss of contrast but not the scattering or wavelength-dependent effects of real Martian dust. In addition, macro-F1 falls proportionally less than accuracy, which indicates that the rare classes are not disproportionately affected and that what the model has learned about them is at least as robust as the rest.

Limitations

No test metrics for Stage 2. The held-out figures for the middle stage are missing, so only the progression from Stage 1 to Stage 3 can be shown.

Three classes cannot be measured. Drill Holes, Sun and Turret have no test examples, so it is not possible to say whether the pipeline improved them. This is a significant gap given that rare-class detection is the stated goal.

The label space does not reconcile. The source dataset is documented as having 24 classes, the model’s output layer has 25 indices, and 22 classes appear in test. The notebooks do not account for the difference.

Dust is simulated. Images taken through genuinely dusty optics would provide a stronger test.

Next Steps

Target confusable classes directly. The evidence points to pairs of similar-looking instruments. Metric learning, or a hierarchical classifier that first separates terrain from hardware and then distinguishes between instruments, would address this failure mode.

Report macro-F1 with its class set. Alternatively, restrict evaluation to the classes the test split can measure and state this explicitly.

Train on degraded images. The dust analysis measures robustness, but nothing in the pipeline is designed to improve it. Dust augmentation during training would show whether the 4.2 point drop can be reduced.

Rebalance the test split. A class with two test examples cannot support a stable F1 estimate, and a stratified split would make claims about rare classes testable.