**바람누리(BaramNuri)**는 차량 내 카메라 영상에서 운전자의 이상행동을 실시간으로 탐지하는 경량화 딥러닝 모델입니다.
┌─────────────────────────────────────────────────────────────────┐
│ BaramNuri Architecture │
├─────────────────────────────────────────────────────────────────┤
│ │
│ Input: [B, 3, 30, 224, 224] (1초 영상, 30fps) │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────┐ │
│ │ Video Swin-T (Stage 1-3) │ ← Kinetics-400 │
│ │ Shifted Window Attention │ Pretrained │
│ │ Output: 384 dim features │ │
│ └─────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────┐ │
│ │ Selective SSM Block (x2) │ ← Mamba-style │
│ │ - 1D Conv for local context │ Temporal │
│ │ - Selective state space │ Modeling │
│ │ - Input-dependent B, C, delta │ │
│ └─────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────┐ │
│ │ Classification Head │ │
│ │ LayerNorm → Dropout → Linear │ │
│ └─────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ Output: [B, 5] (5-class logits) │
│ │
└─────────────────────────────────────────────────────────────────┘
1 import torch
2 from model import BaramNuri
3
4 # Load model
5 model = BaramNuri ( num_classes = 5 , pretrained = False )
6 checkpoint = torch . load ( 'baramnuri_beta.pth' , map_location = 'cpu' )
7 model . load_state_dict ( checkpoint [ 'model_state_dict' ] )
8 model . eval ( )
9
10 # Prepare input (1 second video, 30fps, 224x224)
11 # Shape: [batch, channels, frames, height, width]
12 video = torch . randn ( 1 , 3 , 30 , 224 , 224 )
13
14 # Inference
15 with torch . no_grad ( ) :
16 logits = model ( video )
17 probs = torch . softmax ( logits , dim = - 1 )
18 pred_class = probs . argmax ( dim = - 1 ) . item ( )
19
20 # Class names
21 class_names = [ "정상" , "졸음운전" , "물건찾기" , "휴대폰 사용" , "운전자 폭행" ]
22 print ( f"Predicted: { class_names [ pred_class ] } ( { probs [ 0 , pred_class ] : .2% } )" )
1 # Single prediction with confidence
2 result = model . predict ( video )
3 print ( f"Class: { result [ 'class_name' ] } " )
4 print ( f"Confidence: { result [ 'confidence' ] : .2% } " )
1 from torchvision import transforms
2
3 transform = transforms . Compose ( [
4 transforms . Resize ( ( 224 , 224 ) ) ,
5 transforms . ToTensor ( ) ,
6 transforms . Normalize (
7 mean = [ 0.485 , 0.456 , 0.406 ] ,
8 std = [ 0.229 , 0.224 , 0.225 ]
9 ) ,
10 ] )
Teacher: Video Swin-T (27.86M, 98.05% acc)
│
│ Soft Labels (Temperature=4.0)
▼
Student: BaramNuri (14.20M)
│
│ L = 0.5 * L_hard + 0.5 * L_soft
▼
Result: 96.17% acc (98% of teacher performance)
1 model = BaramNuri ( num_classes = 5 )
2 model . load_state_dict ( torch . load ( 'baramnuri_beta.pth' ) [ 'model_state_dict' ] )
3 model = model . cuda ( ) . eval ( )
4
5 # FP16 for faster inference
6 model = model . half ( )
1 import torch . quantization as quant
2
3 model_int8 = quant . quantize_dynamic (
4 model , { torch . nn . Linear } , dtype = torch . qint8
5 )
6 # Model size: ~13MB
1 dummy_input = torch . randn ( 1 , 3 , 30 , 224 , 224 )
2 torch . onnx . export (
3 model , dummy_input , "baramnuri.onnx" ,
4 input_names = [ 'video' ] ,
5 output_names = [ 'logits' ] ,
6 dynamic_axes = { 'video' : { 0 : 'batch' } }
7 )
1 @misc{baramnuri2025,
2 title={BaramNuri: Lightweight Driver Behavior Detection with Knowledge Distillation},
3 author={C-Team},
4 year={2025},
5 howpublished={\url{https://huggingface.co/c-team/baramnuri-beta}}
6 }
This model is released under the
Apache 2.0 License .