feat: initial HSAP platform
Huaxu Sentinel Active Safety Platform with embedded algorithm code, Docker Compose setup, and vendored dataset scaffolds for clone-and-run. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1 @@
|
||||
from .detector import Detector
|
||||
@@ -0,0 +1,36 @@
|
||||
import torch.nn as nn
|
||||
import torch
|
||||
|
||||
from clrnet.models.registry import NETS
|
||||
from ..registry import build_backbones, build_aggregator, build_heads, build_necks
|
||||
|
||||
|
||||
@NETS.register_module
|
||||
class Detector(nn.Module):
|
||||
def __init__(self, cfg):
|
||||
super(Detector, self).__init__()
|
||||
self.cfg = cfg
|
||||
self.backbone = build_backbones(cfg)
|
||||
self.aggregator = build_aggregator(cfg) if cfg.haskey('aggregator') else None
|
||||
self.neck = build_necks(cfg) if cfg.haskey('neck') else None
|
||||
self.heads = build_heads(cfg)
|
||||
|
||||
def get_lanes(self):
|
||||
return self.heads.get_lanes(output)
|
||||
|
||||
def forward(self, batch):
|
||||
output = {}
|
||||
fea = self.backbone(batch['img'] if isinstance(batch, dict) else batch)
|
||||
|
||||
if self.aggregator:
|
||||
fea[-1] = self.aggregator(fea[-1])
|
||||
|
||||
if self.neck:
|
||||
fea = self.neck(fea)
|
||||
|
||||
if self.training:
|
||||
output = self.heads(fea, batch=batch)
|
||||
else:
|
||||
output = self.heads(fea)
|
||||
|
||||
return output
|
||||
Reference in New Issue
Block a user