|
8 | 8 | import qupath.lib.objects.PathObject; |
9 | 9 | import qupath.lib.projects.ProjectImageEntry; |
10 | 10 | import qupath.lib.objects.PathObjectTools; |
| 11 | +import java.util.Objects; |
11 | 12 |
|
12 | 13 |
|
13 | 14 | import java.awt.image.BufferedImage; |
@@ -105,7 +106,15 @@ public static void train( |
105 | 106 | List<PathObject> validDets = new ArrayList<>(detClass.keySet()); |
106 | 107 |
|
107 | 108 | if (validDets.isEmpty()) { |
108 | | - log.accept(" " + entry.getImageName() + ": 0 training objects found"); |
| 109 | + long annoCount = hierarchy.getAnnotationObjects().stream() |
| 110 | + .filter(a -> a.getPathClass() != null && classNames.contains(a.getPathClass().toString())) |
| 111 | + .count(); |
| 112 | + long detCount = hierarchy.getDetectionObjects().size(); |
| 113 | + long conflicts = detClass.values().stream().filter(Objects::isNull).count(); |
| 114 | + log.accept(" " + entry.getImageName() + ": 0 training objects found" |
| 115 | + + " (matching annotations: " + annoCount |
| 116 | + + ", detections: " + detCount |
| 117 | + + ", conflicts discarded: " + conflicts + ")"); |
109 | 118 | continue; |
110 | 119 | } |
111 | 120 |
|
@@ -175,9 +184,10 @@ record FeatureScore(String name, double score, int idx) {} |
175 | 184 | String.format(" %-50s %.0f", fs.name(), fs.score()))); |
176 | 185 |
|
177 | 186 | // ── 6. Select top-N features ──────────────────────────────────────────── |
178 | | - List<FeatureScore> selected = (topNFeatures > 0 && topNFeatures < nFeatures) |
| 187 | + List<FeatureScore> selected = (topNFeatures > 0 && topNFeatures < ranked.size()) |
179 | 188 | ? ranked.subList(0, topNFeatures) |
180 | 189 | : ranked; |
| 190 | + |
181 | 191 | int[] selIdx = selected.stream().mapToInt(FeatureScore::idx).toArray(); |
182 | 192 | log.accept("\nUsing " + selIdx.length + " features for final model."); |
183 | 193 |
|
|
0 commit comments