Manuscript Offprint
arXiv:2611.05680Toward an Optimal Configuration for Tree Species Classification from Bark Images: A Leakage-Safe Ablation Study
Abstract
Background: The automatic identification of tree species from bark photographs is of practical interest for forestry inventory and for the wood-processing industry, yet the numerous design choices that govern the accuracy of deep-learning approaches have not been studied systematically, and some prior results may be inflated by the leakage of images of the same trunk across training and test partitions. Methods: A systematic ablation study is conducted on the public BarkNet 1.0 dataset (20 species) under the established tree-level, leakage-safe partitioning scheme. Using ConvNeXt-V2 backbones, the following factors are varied in turn and evaluated by five-fold cross-validation: the patch size at which bark is sampled (five sizes), the strategy by which per-patch predictions are aggregated into an image-level decision, the training regime (single- versus two-stage), the backbone capacity, the whole-image baseline, and the number of patches available at inference. Results: Per-patch accuracy rises monotonically with patch size (from 75.6% at 160 px to 89.6% at 512 px), and image-level accuracy rises in step, plateauing near 94.9% around 512 px. Learned aggregation exceeds majority voting by at most 0.7 pp, an advantage that shrinks as patches grow and the attention distribution becomes near-uniform. Backbone capacity (pico to tiny) alters accuracy by less than a point, and two-stage training does not offer an advantage over one-stage training. Whole-image classification (91.9%) trails patch-based aggregation despite its larger field of view, since it admits no bag to average over; and accuracy increases with the number of patches available at inference, saturating around 64 patches. Conclusions: The study yields a simple recommended configuration: patches as large as possible while still leaving enough patches to average over (around 512 px here), with a nano backbone. It also quantifies the second-order role of learned aggregation and model capacity, providing a reproducible reference point for practitioners and future research.
Keywords: tree species identification; bark recognition; ablation study; patch size; multiple instance learning; ConvNeXt; deep learning; data leakage; BarkNet 1.0; forestry; fine-grained visual categorization.
1 Introduction
The identification of tree species is a routine but labour-intensive task in forest inventory, ecological monitoring, and the grading and pricing of timber in the wood-processing industry, and automating it with computer vision has attracted sustained interest over the past decade [1, 2]. Most automated systems identify plants from leaves, flowers, or fruit [1], which are seasonal and frequently out of reach on a standing trunk. Bark, by contrast, is visible throughout the year and remains accessible on both standing and felled trunks, and its texture varies comparatively little with season; these properties have made it an attractive cue for automated identification [3–6].
*Independent researcher, Montréal, Canada; maeve04.cote@gmail.com
Early approaches to bark recognition relied on hand-crafted texture descriptors, such as local binary pattern variants and statistical radial binary patterns [3, 5]. The feasibility of learning such features directly was established by Carpentier et al. [6], who released the BarkNet 1.0 dataset and reported strong accuracy by classifying image crops with a convolutional network and aggregating the per-crop predictions through hard majority voting. Subsequent work has pursued higher accuracy with more capable backbones; Cui et al. [4], for example, reported near-saturated single-image accuracy on an extended dataset using a ConvNeXt architecture [7]. Beyond BarkNet 1.0, larger bark benchmarks have since been released, including Bark-101 [8] and the recent CentralBark dataset [9].
Viewed more abstractly, bark recognition is an instance of fine-grained visual categorization [2]: the classes are visually similar sub-categories separated by subtle, texture-like cues rather than by object shape. It also shares its computational structure with a broader family of tasks in which a single image is too large or too heterogeneous to classify directly and is instead tiled into patches whose predictions are aggregated into an image-level decision. This tile-and-aggregate paradigm is central to computational pathology, where gigapixel whole-slide images are split into thousands of patches and combined by multiple instance learning [10–12], and it recurs in remote sensing and document analysis. The design questions examined here, namely how large each tile should be, how many are needed, and how their predictions should be combined, are therefore not specific to bark, and the conclusions may inform other tile-based fine-grained recognition tasks.
Despite this progress, two issues limit the practical value of the existing literature. First, the design choices that determine accuracy (the resolution at which bark is sampled, the manner in which patch-level evidence is combined, the training procedure, the capacity of the backbone, and the number of patches required at inference) have largely been adopted by convention. Individual choices have been studied in isolation, for instance patch extraction and majority-voting rules for bark by Misra et al. [13], but they have not been compared jointly and on a common footing, so no consolidated guidance exists as to the configuration a practitioner should adopt. Second, when a dataset contains several photographs of the same trunk, partitioning the data at the level of individual images rather than at the level of trees allows near-identical views of a trunk to appear in both training and test sets; the resulting leakage can inflate the reported accuracy and obscure the true difficulty of the task. This is a failure mode documented across many machine-learning-based sciences [14] and guarded against, for example, by patient-level splitting in computational pathology [11]. On BarkNet 1.0, Carpentier et al. [6] adopted a tree-level split, which we retain; some more recent studies instead report image-level results that, as this study shows, can be optimistic.
Accordingly, the present study does not seek to introduce a new architecture or to maximise a single headline figure. Instead, a systematic and leakage-safe ablation study is conducted, in which each principal design choice is varied in isolation and its effect on accuracy is quantified under a common, tree-level evaluation protocol. The aim is to establish which configuration is most effective for bark-based species classification, and by how much each factor matters, so that the result may serve as a dependable starting point for both industrial deployment and future research.
The contributions of this work are as follows:
-
A systematic five-fold ablation conducted under the tree-level, leakage-safe evaluation protocol of Carpentier et al. [6], with all results reported as means and standard deviations of accuracy and macro- , together with a direct demonstration of the accuracy inflation that image-level splits can produce.
-
A systematic ablation over the principal design choices (patch size, aggregation strategy, training regime, backbone capacity, the whole-image baseline, and test-time bag size), quantifying the contribution of each to overall accuracy.
-
A practical recommended configuration for deployment, derived from the ablation and supported by an attention-concentration diagnostic and an analysis of the learned attention.
2.1 Dataset
The public BarkNet 1.0 dataset [6] is used throughout. It comprises photographs of trees belonging to 23 species, acquired with consumer smartphones under field conditions. Because several photographs were captured for each trunk, the dataset is well suited to a leakage-safe, tree-level evaluation but requires care in partitioning (Section 2.2). The 20 species with a sufficient number of trees are retained, and the three rarest species (ERB, PEG, PID) are excluded, yielding 998 trees and 23,271 images (a mean of 23.3 images per tree); this is the full retained set, with no further filtering, and the per-image cross-validation fold assignments are released with the code to allow exact reproduction. The resulting class distribution is summarised in Table 1.
Table 1: Class distribution of the 20 retained species in BarkNet 1.0 (trees, images, and 224 px patches).
| Code | Species (Latin) | Trees | Images | Patches | Patches/img |
|---|---|---|---|---|---|
| MEL | Larix laricina | 77 | 1,874 | 574,385 | 306.5 |
| CHR | Quercus rubra | 109 | 2,724 | 395,026 | 145.0 |
| ERS | Acer saccharum | 81 | 1,911 | 332,432 | 174.0 |
| PET | Populus tremuloides | 58 | 1,037 | 314,582 | 303.4 |
| FRA | Fraxinus americana | 61 | 1,472 | 282,180 | 191.7 |
| ERR | Acer rubrum | 64 | 1,676 | 264,115 | 157.6 |
| EPN | Picea mariana | 44 | 885 | 220,619 | 249.3 |
| BOJ | Betula alleghaniensis | 43 | 1,255 | 199,796 | 159.2 |
| EPO | Picea abies | 72 | 1,324 | 186,426 | 140.8 |
| BOP | Betula papyrifera | 32 | 1,285 | 184,384 | 143.5 |
| SAB | Abies balsamea | 41 | 922 | 151,021 | 163.8 |
| OSV | Ostrya virginiana | 29 | 612 | 146,457 | 239.3 |
| ORA | Ulmus americana | 25 | 767 | 145,963 | 190.3 |
| PRU | Tsuga canadensis | 45 | 986 | 143,715 | 145.8 |
| PIB | Pinus strobus | 39 | 1,023 | 138,035 | 134.9 |
| HEG | Fagus grandifolia | 41 | 840 | 128,342 | 152.8 |
| EPR | Picea rubens | 27 | 740 | 122,009 | 164.9 |
| THO | Thuja occidentalis | 38 | 746 | 105,487 | 141.4 |
| EPB | Picea glauca | 44 | 596 | 102,438 | 171.9 |
| PIR | Pinus resinosa | 29 | 596 | 78,793 | 132.2 |
| Total | 20 species | 998 | 23,271 | 4,216,205 | 181.2 |
2.2 Leakage-Safe, Tree-Level Partitioning
To prevent the leakage of near-identical views across partitions, the data are divided at the level of trees rather than images: every photograph of a given tree is assigned in its entirety to a single partition. This is the same tree-level split adopted by Carpentier et al. [6] on BarkNet 1.0, retained here so that our results remain directly comparable to theirs and free of same-trunk leakage. This entity-level (group-aware) partitioning is the standard safeguard against the leakage that arises when correlated images are divided independently, a failure mode documented across many machine-learning-based sciences [14] and mirrored by patient-level splitting in computational pathology [11]. Five-fold cross-validation is performed at the tree level, and all reported quantities are means and standard deviations across the five folds. Because the folds partition the trees exhaustively and disjointly, every image is used for evaluation exactly once, so pooled test predictions sum to the dataset size. The protocol yields accuracy estimates that are lower, but more faithful, than those obtained under image-level partitioning, and it is applied uniformly to every configuration examined in this study so that the ablations remain directly comparable.
2.3 Patch Extraction
Each photograph is divided into square patches of side pixels using a minimal-overlap tiling that covers the full trunk region. Five sampling resolutions are considered, . A photograph is treated as a bag of patches, and each patch is an instance within that bag; this bag-of-patches formulation mirrors the tiling of gigapixel images into instances in computational pathology [11, 12]. For reference, Carpentier et al. [6] extracted 224 px crops from images down-sampled to half of their native resolution (equivalent to roughly 448 px patches at full resolution), both to speed up loading and processing and to account for the Bayer colour-filter array, which samples each colour channel at only every other pixel. It is noted at the outset that patch size and bag size are confounded: at a fixed image resolution, larger patches yield fewer but individually more informative instances per bag. This confound is addressed explicitly in Section 4.3.
2.4 Backbone and Aggregation Model
A ConvNeXt-V2 backbone [7, 15], initialised from ImageNet-pretrained weights [16], is used as the per-patch feature extractor. Three capacities are compared, ConvNeXt-V2 pico, nano, and tiny, to characterise the effect of model size (Section 3.8); unless stated otherwise, results are reported for the nano backbone. For the learned-aggregation configuration, all patches of a bag are passed through the backbone to obtain embeddings , which are combined by attention-based multiple instance learning [10], an approach widely used to aggregate patch-level predictions over gigapixel whole-slide images in computational pathology [11, 12]. An attention module assigns each patch a weight, and the bag embedding is formed as the weighted sum of the patch embeddings,
A shared linear head maps the bag embedding to image-level logits, . The attention aggregation is one of the strategies compared in Section 2.7.
2.5 Auxiliary Instance Loss
Plain attention pooling provides gradient signal only through the aggregated bag embedding, which can weaken the per-patch representation. To counteract this, the shared head is additionally applied to every patch embedding and the image label is broadcast to all patches, giving the composite objective
in which denotes the cross-entropy loss and controls the weight of the instance term.
2.6 Training Regime
Two training regimes are compared. In the two-stage regime, the backbone and shared head are first trained as a plain per-patch classifier (Stage 1), and the resulting weights are then transferred to the attention model, which is fine-tuned end-to-end with the auxiliary loss (Stage
2). In the single-stage regime, the attention model is trained directly at the image level (Stage 2 only) without patch-level pre-training. The comparison of these regimes is itself one of the ablations (Section 3.3).
The models are optimised with AdamW [17]; the remaining optimisation details are given in Table 2. Hyperparameters were selected by a single Optuna search [18], performed for the nano backbone at a patch size of 224 pixels, and were transferred unchanged to all other patch sizes and backbones, with the sole exception of the stochastic-depth (drop-path) rate, which is increased with backbone capacity. Tuning is therefore not repeated per configuration; this keeps the comparison controlled, at the cost of accuracies that are, if anything, conservative for the non-nominal settings.
Table 2: Training configuration and tuned hyperparameters, obtained for the nano backbone at 224 px and transferred as described in the text.
| Hyperparameter | Stage 1 | Stage 2 |
|---|---|---|
| Backbone | ConvNeXt-V2 (pico, nano, tiny) | |
| Base learning rate | 1.0e-4 | 1.0e-5 |
| Weight decay | 1.0e-3 | 6.4e-4 |
| Drop-path rate | 0.15, 0.25, 0.35 | |
| Instance-loss weight | – | 0.65 |
| Differential-LR multiplier | – | 15 |
| Attention Head Dropout | – | 0.42 |
| Classifier Head Dropout | 0.12 | 0.21 |
| Batch / accumulation | 128 | /32 |
2.7 Aggregation Strategies and Baselines
Four ways of arriving at an image-level decision are compared over identical backbones:
-
Majority voting: a hard majority vote over the per-patch predictions of a bag, reproducing the aggregation used in earlier bark-classification work and serving as the reference baseline.
-
Attention-based MIL (AMIL): learned attention pooling with the auxiliary loss (Sections 2.4–2.5).
-
Fixed-head majority vote (AMIL-vote): a majority vote taken over the per-patch head of a trained AMIL model, with the weights held fixed, which isolates the effect of the aggregation rule from the additional training.
-
Whole-image: the entire photograph, resized to the network input, is classified as a single instance; this is the limiting case in which a bag contains a single patch, and it tests whether patch-based processing is beneficial at all.
2.8 Ablation Design
The study is organised around a set of hypotheses, each isolating one design choice; stating them explicitly delimits the scope of the study and allows each to be confirmed or refuted individually. The corresponding results are reported in Section 3.
-
(H1) Per-patch accuracy increases with patch size, as larger patches carry more discriminative bark structure.
-
(H2) The advantage of learned aggregation over voting is greatest when patches are individually weak and diminishes as patch size, and hence per-patch quality, increases; equivalently, the attention distribution is more concentrated at small patch sizes and more diffuse (voting-like) at large ones.
-
(H3) Two-stage training (patch-level pre-training followed by attention fine-tuning) yields a stronger patch representation and thereby higher final accuracy than single-stage (image-level only) training.
-
(H4) An optimal patch size exists that balances per-patch quality against retaining enough patches to aggregate, so that the best size is a deliberate trade-off rather than the largest possible.
-
(H5) Patch-based processing outperforms whole-image classification.
-
(H6) With the backbone held fixed, learned aggregation outperforms hard voting.
-
(H7) Accuracy increases with the number of patches available at inference, with diminishing returns beyond a certain bag size.
-
(H8) A larger backbone (more parameters) yields higher image-level accuracy.
2.9 Evaluation Metrics and Attention Diagnostics
Every configuration is evaluated by five-fold, tree-level cross-validation, and all quantities are reported as means and standard deviations across folds. Two performance metrics are reported: top-1 image-level accuracy and the macro-averaged score, the latter to account for class imbalance across the 20 species.
To characterise how the attention model uses its patches, the Shannon entropy of the attention distribution of each bag is computed, , and summarised as the effective fraction of patches attended, . A value near one indicates near-uniform attention, under which learned aggregation approaches an average over all patches and is expected to behave like voting; small values indicate that the decision is concentrated on a few patches. This diagnostic is used to interpret the interaction between patch size and aggregation (Section 3.2) and the effect of the training regime (Section 3.3).
3 Results
3.1 Effect of Patch Size on Per-Patch Accuracy (H1)
Per-patch (Stage-1) accuracy increases monotonically with patch size, from 75.6% at 160 px to 89.6% at 512 px (Figure 1), confirming H1: larger patches, which capture more of the trunk's bark structure, are individually more discriminative. The gains are largest at the small end of the range (roughly +5.6 pp from 160 to 224 px) and taper towards the largest sizes (+1.9 pp from 384 to 512 px).
3.2 Interaction Between Patch Size and Aggregation (H2)
The advantage of learned aggregation over majority voting is small at every patch size and declines monotonically as patch size increases, from +0.73 pp at 160 px to +0.16 pp at 512 px (Figure 1). This decline tracks the attention distribution directly: the effective fraction of patches attended rises from 70.7% at 160 px to 99.0% at 512 px, so that at large patch sizes the attention model spreads its weight almost uniformly and therefore behaves like voting. Both observations support H2: learned aggregation is most useful when instances are individually weak, and its value dissipates as per-patch quality rises and the model has little reason to prefer some patches over others. The concurrent fall in bag size, from a mean of 347 patches at 160 px to 38 at 512 px, is noted here and disentangled from patch size in Section 4.3.

Figure 1: Effect of patch size (nano backbone; five-fold, mean±std). (a) Per-patch (Stage-1) accuracy and image-level accuracy under majority voting and AMIL: all rise with patch size and the image-level curves plateau near 512 px, well above the per-patch accuracy that aggregation is built from. (b) The AMIL–voting gap (left axis) shrinks as patch size grows, while the effective fraction of patches attended (right axis) rises toward one, so at large patches the attention distribution is near-uniform and pooling behaves like voting. (H1), (H2), (H6)
3.3 Training Regime: Single- versus Two-Stage (H3)
Two-stage training does not offer an advantage over single-stage training, contrary to H3. The single-stage model attains 92.8% image-level accuracy against 91.5% for the two-stage model (Table 3), a difference that, if anything, favours the simpler single-stage regime and is not robust across folds. The two regimes differ sharply, however, in how they use attention. Under single-stage training the attention distribution is far more concentrated (effective fraction 50.6% versus 89.3%), and pooling beats a vote over the same head by +1.63 pp rather than +0.45 pp. This is consistent with the mechanism identified in Section 3.2: two-stage pre-training yields a stronger per-patch representation, which leaves the attention module less to do, whereas single-stage training, lacking that representation, leans more heavily on selective attention to reach a comparable result. Two-stage training therefore buys a more robust patch representation and more diffuse attention, but not higher accuracy, so the added complexity of a separate pre-training stage is not warranted here.
Table 3: Single- versus two-stage training at 224 px, nano backbone (five-fold, mean±std). The aggregation gap is AMIL minus a vote over the same fixed head. (H3)
| Regime | AMIL acc. (%) | AMIL macro- | (AMIL–AMIL-vote) pp | Eff. frac. (%) |
|---|---|---|---|---|
| Two-stage | 91.5±2.7 | 91.7 | +0.45 | 89.3 |
| Single-stage | 92.8±2.2 | 92.7 | +1.63 | 50.6 |
3.4 Patch Size, Bag Size, and the Optimal Operating Point (H4)
Per-patch accuracy increases monotonically with patch size (Section 3.1), and the whole-image baseline (the limit of a single, maximally large “patch”) attains the highest single-instance accuracy of all (91.9%; Section 3.5), exceeding even the 512 px per-patch accuracy (89.6%). Image-level accuracy, however, behaves differently. It rises with patch size and plateaus near 512 px (94.7% at 384 to 94.9% at 512; Figure 1), whereas the whole-image case, which admits no aggregation because its bag contains a single instance, falls well below it (91.9%). Enlarging patches thus improves the individual instances but shrinks the bag, and past a certain point too few patches remain to average over and image-level performance degrades, the whole-image case being the extreme of this trade-off. The resulting optimum, where per-patch quality is high yet enough patches remain to aggregate, lies around 512px, where image-level accuracy plateaus. This supports H4: the best patch size is a deliberate trade-off rather than simply the largest possible.
3.5 Patch-Based Processing versus Whole-Image Classification (H5)
The whole-image baseline, in which the entire photograph is resized to the network input and classified as a single instance, attains 91.9% ± 2.7 accuracy (91.9% macro- ). Two observations follow. First, this exceeds the per-patch accuracy of even the largest (512px) patches (89.6%; Figure 1): a single view covering the whole trunk is more informative than a single localised patch, confirming that a larger field of view per instance helps. Second, it nonetheless trails patch-based aggregation at the larger patch sizes (94.9% at 512px; Figure 1), so aggregating several large patches beats classifying one whole image, supporting H5. One caveat applies: the whole-image baseline resizes each photograph to the fixed 224px network input, discarding most of the native resolution and blurring fine bark texture, so its lower accuracy is partly an artefact of that downsampling rather than evidence that whole-image classification is inherently inferior. Indeed, this limitation is itself an argument for patching, the mechanism by which a fixed-input network can exploit the full image resolution. The comparison is also relevant to the leakage discussion: the leakage-safe whole-image accuracy (91.9%) is far below the near-saturated single-image figure of Cui et al. [4] (97.61%, reported on the 33-species BarkNetV2, which includes a non-public subset, under an apparently image-level split); although the datasets differ, the gap is consistent with same-trunk leakage inflating such a split.
3.6 Learned Aggregation versus Hard Voting (H6)
Holding the backbone fixed, attention pooling outperforms a majority vote taken over the same per-patch head (the AMIL-vote baseline) at every patch size, by +0.85 pp at 160 px falling to +0.10 pp at 512 px; the comparison against the classical Stage-1 voting baseline is similar in direction and magnitude (+0.73 to +0.16 pp; Figure 1). The differences are positive in the mean at every patch size and consistent in sign across folds, though small in magnitude. H6 is therefore supported in direction but not in magnitude: learned aggregation confers a small, consistent edge that is largest when patches are weak and narrows as they strengthen.
This behaviour has a structural explanation. Attention-based MIL was devised for settings such as computational pathology, in which a bag mixes a few informative instances with a large majority of uninformative background patches, and the attention layer earns its value by suppressing that background [10, 11]. Bark bags are the opposite case: the photographs are framed tightly on the trunk, so nearly every patch is a discriminative instance, and near-equal weighting is close to optimal, precisely the uniform attention observed here. Whether learned aggregation is worthwhile on a fine-grained task in which essentially all instances are informative is one of the questions this study set out to answer; the answer is that its benefit is real but marginal. Because the attention module adds only a handful of parameters over a plain per-patch classifier and is never worse than voting in the mean, it is a low-cost option worth enabling wherever maximal accuracy is valuable while it can be omitted with negligible loss when simplicity is the priority.
3.7 Effect of Test-Time Bag Size (H7)
Image-level accuracy increases with the number of patches available at inference and saturates well before the full bag is used (Figure 2). For the nano 224px model, AMIL accuracy rises from 88.8% with 4 patches to 91.3% with 64, and only 91.5% with 256; the bulk of the benefit is realised by roughly 64 patches, and a dozen already come within half a point of the plateau. The advantage of learned aggregation over voting is largest when few patches are available (+1.13 pp at 4 patches) and shrinks as the bag grows (+0.42 pp at 256), echoing Section 3.2: when evidence is scarce, weighting patches selectively matters more. In deployment, only a few dozen patches per trunk are therefore needed to approach full accuracy, which combines favourably with the preference for large patches (few patches per image) established in Section 3.4. Because this sweep varies bag size at a fixed 224 px patch size, it also serves to disentangle the two factors (Section 4.3), confirming H7.

Figure 2: Image-level accuracy as a function of the number of patches available at inference (nano backbone, 224 px; mean±std over five folds). Both aggregation rules improve steeply up to about 16–32 patches and plateau thereafter, so a few dozen patches per trunk suffice; AMIL stays above majority voting throughout, by a margin that is largest when patches are scarce and narrows as the bag grows. (H7)
3.8 Effect of Backbone Capacity (H8)
Contrary to H8, backbone capacity has little effect on image-level accuracy. Across ConvNeXt-V2 pico, nano, and tiny, a roughly threefold range in parameters, AMIL accuracy varies by less than a percentage point (90.8% to 91.5%), with the nano backbone marginally ahead of the larger tiny (Table 4). Per-patch accuracy rises slightly with capacity (80.4% to 81.6%), but this does not translate into a meaningful image-level gain. A larger backbone is therefore not worth its additional training and inference cost for this task, and the nano backbone is retained as the default.
Table 4: Effect of backbone capacity at a patch size of 224 px (five-fold, mean±std). (H8)
| Backbone | Params (M) | Per-patch (%) | Voting (%) | AMIL (%) | AMIL macro- | pp |
|---|---|---|---|---|---|---|
| ConvNeXt-V2 pico | 9.1 | 80.4±4.8 | 90.1±3.0 | 90.8±2.9 | 90.9 | +0.73 |
| ConvNeXt-V2 nano | 15.6 | 81.2±4.6 | 90.8±2.8 | 91.5±2.7 | 91.7 | +0.70 |
| ConvNeXt-V2 tiny | 28.6 | 81.6±4.8 | 91.1±2.9 | 91.3±2.8 | 91.2 | +0.19 |
3.9 Interpretability: Attention over the Trunk
Figure 3 shows the learned attention over representative trunks of four species, expressed relative to the uniform weight 1/N. In practice, the attention offers little interpretive value. At the small patch size used here the weights are distributed fairly evenly across the trunk: most patches receive near-uniform weight, and the few higher-weight patches form no consistent, human-legible pattern that could be tied to particular bark features. This is the spatial counterpart of the diffuse attention quantified in Section 3.2 and, we suggest, a consequence of the patch-based design itself. Because each patch is classified independently, the model has no access to the larger-scale bark structure (ridges, plating, lenticel rows) that a human observer uses, so attention merely re-weights already-similar local views. Enlarging the patches does not recover interpretability either: as patch size grows the attention becomes essentially uniform (Figure 1), conveying even less about which regions matter. Viewing the attention map is therefore of limited diagnostic use here, in contrast to whole-image saliency methods such as class-activation mapping, which have been used to localise discriminative bark regions on entire trunk images [19].

Figure 3: Attention over the trunk for four species (CHR, ERS, MEL, ERR), nano backbone at 224 px resulting from single-stage training. Each patch is shaded by its attention weight relative to the uniform weight 1/N (colour bar, 0.25× to 4×); brighter patches receive more weight. The attention is largely diffuse: most patches receive near-uniform weight and the few higher-weight patches show no consistent spatial structure.
3.10 Per-Species Performance
For the recommended configuration (nano backbone, 512 px, AMIL), the image-level confusion matrix is shown in Figure 4; per-class precision, recall, and are reported in Table A4. Classification is strong across the board (94.8% accuracy, 94.9% macro-), and the residual errors are highly structured: almost all confusions occur within a genus rather than across genera. Yellow and white birch (BOJ/BOP), sugar and red maple (ERS/ERR), the spruces (EPB/EPO), and red pine with tamarack (PIR/MEL) account for the bulk of the off-diagonal mass, whereas confusions between genera are rare.
This pattern is consistent with the visual structure of the task. Congeneric species tend to share their gross bark characters (ridge and plate structure, colour, and lenticel arrangement), and the features that separate them are often subtle and expressed at a spatial scale, or under lighting conditions, that the present patch size and backbone may not fully capture; in some cases the more reliable distinguishing cues are not morphological at all but chemical, as documented for spruces via terpene profiles [20]. We stress that these confusions reflect the limits of this model at this resolution rather than a claim that the species are visually indistinguishable: trained observers routinely separate these taxa from bark. Nonetheless, the errors are concentrated exactly where congeneric bark is most alike, as the near-diagonal, within-genus structure of Figure 4 makes plain. The weakest class, American elm (ORA, 79.7% recall), follows the same pattern, being confused mainly with red maple and ironwood, whose bark is similarly ridged. These congeneric confusions account for essentially all of the small gap between overall accuracy and macro-.

Figure 4: Row-normalized (recall, %) confusion matrix for the recommended configuration (nano, 512 px, AMIL, image level), pooled over the five held-out test folds (each image classified once). Rows are true species, columns predicted; species are ordered by genus, so that the predominantly intra-genus confusions appear as near-diagonal blocks.
4 Discussion
4.1 Recommended Configuration
Taken together, the ablations point to a simple recommended configuration. Patch size is the dominant factor and should be made as large as the image allows while retaining a bag large enough to average over; on BarkNet 1.0 this optimum is around 512px (Section 3.4). The backbone need not be large: ConvNeXt-V2 nano offers the best accuracy-to-size trade-off, with larger capacities giving no meaningful gain (Section 3.8). The aggregation rule and the training regime are second-order. Single-stage training suffices, since two-stage pre-training offers no advantage (Section 3.3); and while majority voting is already strong, attention pooling is consistently at least as accurate for a negligible increase in parameters, so a practitioner seeking maximal precision should prefer it (Section 3.6). Finally, only about a dozen patches per trunk are needed at inference to approach full accuracy, with essentially no further gain beyond roughly 64 (Section 3.7).
4.2 Comparison with Prior Work
The strongest results obtained across the ablation are compared with prior work in Table 5. Under the leakage-safe, tree-level protocol, they closely reproduce the honest, tree-split figures of Carpentier et al. [6] at every level of aggregation: single-patch accuracy of 89.6% against their 87.0% single crop, image-level voting of 94.7% against their 93.88%, and tree-level AMIL of 97.8% against their 97.81%. The near-saturated single-image figure of Cui et al. [4] is not directly comparable: it is reported on the 33-species BarkNetV2 (which includes a non-public subset) under an apparently image-level split, and the whole-image result of Section 3.5 (91.9% under a leakage-safe split) is consistent with same-trunk leakage inflating such a split.
Table 5: Comparison with prior work on BarkNet 1.0 (20 species where comparable). The results of Carpentier et al. were obtained under a tree-level split and are directly comparable; the split of Cui et al. appears to be image-level and may therefore reflect same-trunk leakage. Rows marked “This work” use the nano backbone at 512 px and are five-fold means.
| Method | Split | Aggregation | Acc. (%) |
|---|---|---|---|
| Carpentier et al. [6] | tree | single crop | 87.0 |
| Carpentier et al. [6] | tree | vote (image) | 93.88 |
| Carpentier et al. [6] | tree | vote (tree) | 97.81 |
| Cui et al. [4]ª | imageª | single image | 97.61 |
| This work: per-patch | tree | single patch | 89.6 |
| This work: image | tree | vote | 94.7 |
| This work: image | tree | AMIL | 94.9 |
| This work: tree | tree | AMIL | 97.8 |
ª BarkNetV2 (33 classes, including a non-public subset); the partition appears to be random by image, so the figure is not directly comparable and may reflect same-trunk leakage.
4.3 Decoupling the Bag-Size and Patch-Size Confound
Patch size and bag size are inevitably confounded in the patch-size sweep, since larger patches produce fewer instances per image (Figure 1). The test-time bag-size sweep of Section 3.7 isolates the two: holding patch size fixed at 224 px and reducing the number of patches lowers accuracy only modestly and with strong diminishing returns (91.5% at 256 patches to 88.8% at 4). By contrast, the patch-size sweep shows accuracy rising as patches grow despite the accompanying fall in bag size. Over the range tested, the two effects act in opposite directions, and the net improvement with larger patches is attributable to per-patch quality rather than to bag size. The whole-image case (Section 3.4) marks the point at which the shrinking bag finally dominates and accuracy falls, locating the optimum at an intermediate-to-large patch size.
4.4 Limitations
Several limitations qualify these findings. The study uses a single dataset from one geographic region and species set, so the recommended configuration may not transfer directly to other floras or acquisition conditions. Classes are imbalanced, which macro- mitigates but does not remove. Hyperparameters were tuned only for the nano backbone at 224 px and transferred, which may modestly understate the accuracy of the other settings. The training and evaluation bags differ in size (training caps the number of patches per bag, whereas evaluation uses the full bag). Because images from the same tree are correlated, we characterise the smaller effects, notably the aggregation advantage, by their magnitude and their consistency in sign across folds rather than by image-level significance tests, which would overstate confidence on clustered data. Finally, we evaluate a single, established attention-MIL formulation [10]; aggregators that model inter-patch context, such as transformer-based MIL [21], might behave differently, although the near-uniform attention observed here, driven by the absence of uninformative background patches, suggests limited headroom. We leave this to future work.
5 Conclusions
Under a strictly leakage-safe, tree-level evaluation on BarkNet 1.0, this study systematically ablated the principal design choices for bark-based tree-species classification. Accuracy is governed chiefly by patch size: it should be made as large as the image allows while still leaving enough patches to average over, an optimum reached around 512 px, beyond which too few patches remain and performance degrades, as the whole-image case makes plain. Backbone capacity and the training regime are second-order: ConvNeXt-V2 nano gives the best accuracy-to-size trade-off, and two-stage training offers no advantage over the simpler single-stage regime. Learned attention pooling is consistently at least as accurate as majority voting for a negligible parameter cost, making it worthwhile wherever maximal accuracy matters, and only about a dozen patches per trunk are needed at inference to approach full accuracy. Because the task is an instance of tile-based fine-grained recognition, these findings may also inform patch-and-aggregate pipelines beyond bark, and they provide a dependable, inexpensive starting point for deployment and future research.
Author Contributions
This study was conceived, implemented, analysed, and written by the sole author, M. Côté.
Funding
This research received no external funding. The computational experiments were carried out on infrastructure provided by the Digital Research Alliance of Canada (DRAC).
Data and Code Availability
The BarkNet 1.0 dataset is available at https://github.com/ulaval-damas/tree-bark-classification. Code to reproduce the experiments, including the per-image cross-validation fold assignments, is available at https://github.com/MaeveCote/barknet-amil.
Acknowledgments
The author thanks A. Oberman (McGill University and Mila) for sponsoring the Digital Research Alliance of Canada resource allocation under which the experiments were run.
Conflicts of Interest
The author declares no conflict of interest.
Declaration of Generative AI Use
The author used Anthropic Claude, an AI-assisted editing tool, to improve spelling, grammar, clarity, and readability during manuscript preparation and to help format the IATEX manuscript. After using this tool, the author carefully reviewed and edited the text and takes full responsibility for the final content.
A Detailed Result Tables
The following tables give the exact five-fold means and standard deviations behind Figures 1, 2 and 4.
Table A1: Per-patch (Stage-1) accuracy by patch size, nano backbone (five-fold, mean±std). Exact values for Figure 1(a). (H1)
| Patch size (px) | 160 | 224 | 288 | 384 | 512 |
|---|---|---|---|---|---|
| Per-patch accuracy (%) |
Table A2: Image-level performance, aggregation comparison, and attention concentration by patch size (nano backbone; five-fold, mean±std). Exact values for Figure 1. (H2), (H6)
| Patch size (px) | 160 | 224 | 288 | 384 | 512 |
|---|---|---|---|---|---|
| Mean bag size (patches) | 347 | 181 | 113 | 64 | 38 |
| Voting accuracy (%) | |||||
| AMIL-vote accuracy (%) | |||||
| AMIL accuracy (%) | |||||
| Δ (AMIL–voting) pp | +0.73 | +0.70 | +0.49 | +0.33 | +0.16 |
| Effective attention fraction (%) |
Table A3: Image-level accuracy versus the number of patches available at inference (nano, 224 px; five-fold means). Exact values for Figure 2. (H7)
| Patches per bag | 4 | 8 | 16 | 32 | 64 | 128 | 256 |
|---|---|---|---|---|---|---|---|
| Voting accuracy (%) | 87.5 | 89.0 | 90.0 | 90.4 | 90.6 | 90.7 | 90.8 |
| AMIL accuracy (%) | 88.8 | 90.1 | 91.0 | 91.1 | 91.3 | 91.4 | 91.5 |
| Δ (AMIL–voting) pp | +1.13 | +0.78 | +0.69 | +0.44 | +0.47 | +0.44 | +0.42 |
Table A4: Per-class precision, recall, and (%) for the recommended configuration (nano, 512 px, AMIL, image level). is the number of test images per species (each classified once across the five held-out folds).
| Species | Precision | Recall | ||
|---|---|---|---|---|
| BOJ | 97.0 | 91.4 | 94.1 | 1255 |
| BOP | 94.0 | 97.4 | 95.7 | 1285 |
| ERS | 89.0 | 90.1 | 89.5 | 1911 |
| ERR | 88.0 | 85.3 | 86.6 | 1676 |
| EPN | 95.0 | 99.3 | 97.1 | 885 |
| EPB | 96.9 | 94.6 | 95.8 | 596 |
| EPR | 98.6 | 92.8 | 95.6 | 740 |
| EPO | 97.2 | 98.4 | 97.8 | 1324 |
| PIB | 95.5 | 95.3 | 95.4 | 1023 |
| PIR | 98.7 | 89.9 | 94.1 | 596 |
| MEL | 96.1 | 99.9 | 98.0 | 1874 |
| SAB | 95.0 | 93.1 | 94.0 | 922 |
| THO | 99.2 | 99.5 | 99.3 | 746 |
| PRU | 97.6 | 98.9 | 98.2 | 986 |
| PET | 97.9 | 99.0 | 98.5 | 1037 |
| FRA | 94.1 | 98.1 | 96.1 | 1472 |
| OSV | 87.9 | 97.1 | 92.2 | 612 |
| ORA | 96.5 | 79.7 | 87.3 | 767 |
| HEG | 98.1 | 97.3 | 97.7 | 840 |
| CHR | 95.0 | 96.5 | 95.8 | 2724 |
| Macro avg. | 95.4 | 94.7 | 94.9 | 23,271 |
References
[1] Jana Wäldchen, Michael Rzanny, Marco Seeland, and Patrick Mäder. Automated plant species identification—trends and future directions. PLoS Computational Biology, 14(4): e1005993, 2018.
[2] Xiu-Shen Wei, Yi-Zhe Song, Oisin Mac Aodha, Jianxin Wu, Yuxin Peng, Jinhui Tang, Jian Yang, and Serge Belongie. Fine-grained image analysis with deep learning: A survey. IEEE Transactions on Pattern Analysis and Machine Intelligence, 44(12):8927–8948, 2022.
[3] Stefan Fiel and Robert Sablatnig. Automated identification of tree species from images of the bark, leaves or needles. In Proceedings of the 16th Computer Vision Winter Workshop (CVWW), pages 67–74, 2011.
[4] Zhelin Cui, Xinran Li, Tao Li, and Mingyang Li. Improvement and assessment of convolutional neural network for tree species identification based on bark characteristics. Forests, 14(7):1292, 2023. doi: 10.3390/f14071292.
[5] Safia Boudra, Itheri Yahiaoui, and Ali Behloul. Bark identification using improved statistical radial binary patterns. In International Conference on Content-Based Multimedia Indexing (CBMI), pages 1–6. IEEE, 2018.
[6] Mathieu Carpentier, Philippe Giguère, and Jonathan Gaudreault. Tree species identification from bark images using convolutional neural networks. arXiv preprint arXiv:1803.00949, 2018. Also in IEEE/RSJ Int. Conf. on Intelligent Robots and Systems (IROS) 2018.
[7] Zhuang Liu, Hanzi Mao, Chao-Yuan Wu, Christoph Feichtenhofer, Trevor Darrell, and
Saining Xie. A convnet for the 2020s. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 11976–11986, 2022.
[8] Rémi Ratajczak, Sarah Bertrand, Carlos Crispim-Junior, and Laure Tougne. Efficient bark recognition in the wild. In Proceedings of the 14th International Joint Conference on Computer Vision, Imaging and Computer Graphics Theory and Applications (VISIGRAPP) – Volume 4: VISAPP, pages 240–248. SciTePress, 2019. doi: 10.5220/0007361902400248.
[9] Charles Warner, Fanyou Wu, Rado Gazo, Bedrich Benes, Nicole Kong, and Songlin Fei. Centralbark image dataset and tree species classification using deep learning. Algorithms, 17(5):179, 2024.
[10] Maximilian Ilse, Jakub M. Tomczak, and Max Welling. Attention-based deep multiple instance learning. In Proceedings of the 35th International Conference on Machine Learning (ICML), pages 2127–2136, 2018.
[11] Gabriele Campanella, Matthew G. Hanna, Luke Geneslaw, Allen Miraflor, Vitor Werneck Krauss Silva, Klaus J. Busam, Edi Brogi, Victor E. Reuter, David S. Klimstra, and Thomas J. Fuchs. Clinical-grade computational pathology using weakly supervised deep learning on whole slide images. Nature Medicine, 25(8):1301–1309, 2019.
[12] Ming Y. Lu, Drew F.K. Williamson, Tiffany Y. Chen, Richard J. Chen, Matteo Barbieri, and Faisal Mahmood. Data-efficient and weakly supervised computational pathology on whole-slide images. Nature Biomedical Engineering, 5(6):555–570, 2021.
[13] Debaleena Misra, Carlos Crispim-Junior, and Laure Tougne. Patch-based cnn evaluation for bark classification. In Computer Vision – ECCV 2020 Workshops (Workshop on Computer Vision Problems in Plant Phenotyping), volume 12540 of Lecture Notes in Computer Science, pages 197–212. Springer, 2020. doi: 10.1007/978-3-030-65414-6_15.
[14] Sayash Kapoor and Arvind Narayanan. Leakage and the reproducibility crisis in machine-learning-based science. Patterns, 4(9):100804, 2023.
[15] Sanghyun Woo, Shoubhik Debnath, Ronghang Hu, Xinlei Chen, Zhuang Liu, In So Kweon, and Saining Xie. Convnext v2: Co-designing and scaling convnets with masked autoencoders. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 16133–16142, 2023.
[16] Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pages 248–255, 2009.
[17] Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In International Conference on Learning Representations (ICLR), 2019.
[18] Takuya Akiba, Shotaro Sano, Toshihiko Yanase, Takeru Ohta, and Masanori Koyama. Optuna: A next-generation hyperparameter optimization framework. In Proceedings of the 25th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, pages 2623–2631, 2019.
[19] Tae Kyung Kim, Jeonghyun Hong, Daun Ryu, Sukyung Kim, Si Yeon Byeon, Woojin Huh, Kunhyo Kim, Gyu Heon Baek, and Hyun Seok Kim. Identifying and extracting bark key features of 42 tree species using convolutional neural networks and class activation mapping. Scientific Reports, 12:4772, 2022. doi: 10.1038/s41598-022-08571-9.
[20] Alexandra Malhocká and Martina Švábová. Inter and intraspecies variability of terpene profiles of four spruce species growing in the czech republic: a chemotaxonomic study. Biochemical Systematics and Ecology, 123:105095, 2025.
[21] Zhuchen Shao, Hao Bian, Yang Chen, Yifeng Wang, Jian Zhang, Xiangyang Ji, and Yongbing Zhang. Transmil: Transformer based correlated multiple instance learning for whole slide image classification. In Advances in Neural Information Processing Systems (NeurIPS), volume 34, pages 2136–2147, 2021.