mirror of
https://github.com/MoreTore/openpilot.git
synced 2026-08-05 08:16:06 +08:00
training data
This commit is contained in:
Binary file not shown.
@@ -463,6 +463,7 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> keys = {
|
||||
{"VisionSpeedLimitAutoBookmark", {PERSISTENT, BOOL, "0", "0", 0}},
|
||||
{"VisionSpeedLimitAutoPreserveSegment", {PERSISTENT, BOOL, "0", "0", 0}},
|
||||
{"VisionSpeedLimitDetection", {PERSISTENT, BOOL, "0", "0", 0}},
|
||||
{"VisionSpeedLimitTrainingCollector", {PERSISTENT, BOOL, "1", "1", 0}},
|
||||
{"StandardFollow", {PERSISTENT, FLOAT, "1.45", "1.45", 2}},
|
||||
{"StandardFollowHigh", {PERSISTENT, FLOAT, "1.45", "1.45", 2}},
|
||||
{"StandardJerkAcceleration", {PERSISTENT, FLOAT, "50.0", "50.0", 3}},
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,2 +1,2 @@
|
||||
extern const uint8_t gitversion[19];
|
||||
const uint8_t gitversion[19] = "DEV-bbec8558-DEBUG";
|
||||
const uint8_t gitversion[19] = "DEV-a695eda0-DEBUG";
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
||||
DEV-bbec8558-DEBUG
|
||||
DEV-a695eda0-DEBUG
|
||||
@@ -41,7 +41,7 @@ def parse_args() -> argparse.Namespace:
|
||||
parser.add_argument("--latest", type=int, default=1, help="How many latest sessions to import when no session ids are provided.")
|
||||
parser.add_argument("--mode", choices=("symlink", "copy"), default="symlink", help="How to place snapshots into the workspace review/images directory.")
|
||||
parser.add_argument("--force", action="store_true", help="Overwrite snapshot links/files if they already exist.")
|
||||
parser.add_argument("--events", nargs="+", default=["bookmark", "auto_bookmark", "publish", "candidate"], help="Event types to include in the manifest.")
|
||||
parser.add_argument("--events", nargs="+", default=["bookmark", "auto_bookmark", "training_candidate", "publish", "candidate"], help="Event types to include in the manifest.")
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -31,6 +31,9 @@ PUBLISHED_REVERT_CONFIDENCE = 0.97
|
||||
AUTO_BOOKMARK_CONFIRM_DELAY_SECONDS = 0.9
|
||||
AUTO_BOOKMARK_COOLDOWN_SECONDS = 8.0
|
||||
AUTO_BOOKMARK_MIN_CONFIDENCE = 0.62
|
||||
TRAINING_COLLECTOR_CONFIRM_DELAY_SECONDS = 0.7
|
||||
TRAINING_COLLECTOR_COOLDOWN_SECONDS = 2.5
|
||||
TRAINING_COLLECTOR_MIN_CONFIDENCE = 0.40
|
||||
MODEL_PROPOSAL_MIN_CONFIDENCE = 0.0001
|
||||
MODEL_PROPOSAL_MAX_COUNT = 16
|
||||
MODEL_PROPOSAL_MAX_AREA_RATIO = 0.18
|
||||
@@ -223,6 +226,9 @@ class SpeedLimitVisionDaemon:
|
||||
self.last_auto_bookmark_speed_limit_mph = 0
|
||||
self.last_auto_bookmark_publish_at = 0.0
|
||||
self.pending_auto_bookmark = None
|
||||
self.last_training_capture_at = 0.0
|
||||
self.last_training_capture_speed_limit_mph = 0
|
||||
self.pending_training_capture = None
|
||||
self.ignore_next_user_bookmark = False
|
||||
self.current_frame_bgr = None
|
||||
|
||||
@@ -366,6 +372,24 @@ class SpeedLimitVisionDaemon:
|
||||
bookmarkCount=self.debug_bookmark_count,
|
||||
)
|
||||
|
||||
def _record_training_candidate(self, speed_limit_mph, confidence, source_confidence, source_event):
|
||||
if not self.use_runtime or self.params_memory is None or not self.debug_log_path:
|
||||
return
|
||||
|
||||
self._write_debug_event(
|
||||
"training_candidate",
|
||||
frame_bgr=self.current_frame_bgr,
|
||||
snapshot_prefix=f"training_candidate_{speed_limit_mph:03d}",
|
||||
candidateSpeedLimitMph=self.last_candidate_speed_limit_mph,
|
||||
candidateConfidence=round(self.last_candidate_confidence, 4),
|
||||
publishedSpeedLimitMph=self.published_speed_limit_mph,
|
||||
publishedConfidence=round(self.published_confidence, 4),
|
||||
speedLimitMph=speed_limit_mph,
|
||||
confidence=round(confidence, 4),
|
||||
sourceConfidence=round(source_confidence, 4),
|
||||
sourceEvent=source_event,
|
||||
)
|
||||
|
||||
def _schedule_auto_bookmark(self, speed_limit_mph, confidence, published_at):
|
||||
if not self.use_runtime or self.params is None:
|
||||
return
|
||||
@@ -383,6 +407,34 @@ class SpeedLimitVisionDaemon:
|
||||
"confidence": confidence,
|
||||
}
|
||||
|
||||
def _schedule_training_capture(self, speed_limit_mph, confidence, detected_at):
|
||||
if not self.use_runtime or self.params is None:
|
||||
return
|
||||
if not self.params.get_bool("VisionSpeedLimitTrainingCollector", default=True):
|
||||
self.pending_training_capture = None
|
||||
return
|
||||
if confidence < TRAINING_COLLECTOR_MIN_CONFIDENCE:
|
||||
return
|
||||
if detected_at - self.last_training_capture_at < TRAINING_COLLECTOR_COOLDOWN_SECONDS and speed_limit_mph == self.last_training_capture_speed_limit_mph:
|
||||
return
|
||||
|
||||
pending = self.pending_training_capture
|
||||
if pending is not None:
|
||||
if pending["speed_limit_mph"] == speed_limit_mph:
|
||||
pending["confidence"] = max(float(pending["confidence"]), confidence)
|
||||
pending["last_seen_at"] = detected_at
|
||||
return
|
||||
if detected_at < pending["due_at"] and confidence <= float(pending["confidence"]) + 0.08:
|
||||
return
|
||||
|
||||
self.pending_training_capture = {
|
||||
"due_at": detected_at + TRAINING_COLLECTOR_CONFIRM_DELAY_SECONDS,
|
||||
"detected_at": detected_at,
|
||||
"last_seen_at": detected_at,
|
||||
"speed_limit_mph": speed_limit_mph,
|
||||
"confidence": confidence,
|
||||
}
|
||||
|
||||
def _emit_preserve_bookmark(self):
|
||||
if not self.use_runtime or self.pm is None or self.messaging is None:
|
||||
return
|
||||
@@ -418,6 +470,39 @@ class SpeedLimitVisionDaemon:
|
||||
if self.params is not None and self.params.get_bool("VisionSpeedLimitAutoPreserveSegment"):
|
||||
self._emit_preserve_bookmark()
|
||||
|
||||
def _maybe_commit_training_capture(self, now):
|
||||
pending = self.pending_training_capture
|
||||
if pending is None or now < pending["due_at"]:
|
||||
return
|
||||
if self.params is not None and not self.params.get_bool("VisionSpeedLimitTrainingCollector", default=True):
|
||||
self.pending_training_capture = None
|
||||
return
|
||||
|
||||
self.pending_training_capture = None
|
||||
if self.current_frame_bgr is None:
|
||||
return
|
||||
|
||||
speed_limit_mph = int(pending["speed_limit_mph"])
|
||||
source_confidence = float(pending["confidence"])
|
||||
if now - self.last_candidate_at > FOLLOWUP_WINDOW_SECONDS and self.published_speed_limit_mph != speed_limit_mph:
|
||||
return
|
||||
|
||||
confidence = source_confidence
|
||||
source_event = "candidate"
|
||||
if self.last_candidate_speed_limit_mph == speed_limit_mph:
|
||||
confidence = max(confidence, self.last_candidate_confidence)
|
||||
if self.published_speed_limit_mph == speed_limit_mph:
|
||||
confidence = max(confidence, self.published_confidence)
|
||||
source_event = "publish"
|
||||
if confidence < TRAINING_COLLECTOR_MIN_CONFIDENCE:
|
||||
return
|
||||
if now - self.last_training_capture_at < TRAINING_COLLECTOR_COOLDOWN_SECONDS and speed_limit_mph == self.last_training_capture_speed_limit_mph:
|
||||
return
|
||||
|
||||
self.last_training_capture_at = now
|
||||
self.last_training_capture_speed_limit_mph = speed_limit_mph
|
||||
self._record_training_candidate(speed_limit_mph, confidence, source_confidence, source_event)
|
||||
|
||||
def _published_detection_stale(self, now):
|
||||
return self.published_speed_limit_mph > 0 and now - self.last_detection_at > PUBLISHED_HOLD_SECONDS
|
||||
|
||||
@@ -1336,6 +1421,7 @@ class SpeedLimitVisionDaemon:
|
||||
self.history.clear()
|
||||
self.followup_until = 0.0
|
||||
self.pending_auto_bookmark = None
|
||||
self.pending_training_capture = None
|
||||
self.previous_published_speed_limit_mph = self.published_speed_limit_mph
|
||||
self.published_speed_limit_mph = 0
|
||||
self.published_confidence = 0.0
|
||||
@@ -1406,6 +1492,7 @@ class SpeedLimitVisionDaemon:
|
||||
self.last_candidate_speed_limit_mph = detection.speed_limit_mph
|
||||
self.last_candidate_confidence = detection.confidence
|
||||
self.last_candidate_at = now
|
||||
self._schedule_training_capture(detection.speed_limit_mph, detection.confidence, now)
|
||||
|
||||
candidate_signature = (detection.speed_limit_mph, round(detection.confidence, 2))
|
||||
if candidate_signature != self.last_logged_candidate:
|
||||
@@ -1529,6 +1616,7 @@ class SpeedLimitVisionDaemon:
|
||||
self._publish_status(f"Scanning {self.stream_name}", clear_speed=False)
|
||||
|
||||
self._maybe_commit_auto_bookmark(now)
|
||||
self._maybe_commit_training_capture(now)
|
||||
|
||||
ratekeeper.keep_time()
|
||||
|
||||
|
||||
@@ -1159,6 +1159,14 @@
|
||||
"ui_type": "toggle",
|
||||
"parent_key": "VisionSpeedLimitDetection"
|
||||
},
|
||||
{
|
||||
"key": "VisionSpeedLimitTrainingCollector",
|
||||
"label": "Collect Extra Vision Training Samples",
|
||||
"description": "Save lower-threshold vision sign candidates into the debug session for later training import without showing or applying them live. Leave this on if you want to help improve the model.",
|
||||
"data_type": "bool",
|
||||
"ui_type": "toggle",
|
||||
"parent_key": "VisionSpeedLimitDetection"
|
||||
},
|
||||
{
|
||||
"key": "VisionSpeedLimitAutoPreserveSegment",
|
||||
"label": "Preserve Auto-Bookmarked Segments",
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user