Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,87 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: apache-2.0
|
| 3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
---
|
| 4 |
+
# MoE Car Model
|
| 5 |
+
|
| 6 |
+
## Overview
|
| 7 |
+
The MoE (Mixture of Experts) Car Model is a deep learning model designed for autonomous driving and vehicle behavior prediction. It leverages a Mixture of Experts architecture to optimize decision-making across different driving scenarios, improving efficiency and adaptability in real-world environments.
|
| 8 |
+
|
| 9 |
+
## WARNING: THIS MAY SHOW UNSAFE AS THIS RUNS ResNET WHEN YOU USE THE MODEL
|
| 10 |
+
## Model Architecture
|
| 11 |
+
The MoE Car Model consists of the following key components:
|
| 12 |
+
|
| 13 |
+
- **Input Layer:** Accepts sensory data (camera images, LiDAR, GPS, IMU, etc.).
|
| 14 |
+
- **Feature Extractors:** Uses CNNs for image data and LSTMs/Transformers for sequential sensor data.
|
| 15 |
+
- **Mixture of Experts:** Contains multiple specialized expert networks handling specific driving scenarios.
|
| 16 |
+
- **Gating Network:** Dynamically selects which expert(s) contribute to the final decision.
|
| 17 |
+
- **Decision Layer:** Produces control outputs (steering angle, acceleration, braking) or environment predictions.
|
| 18 |
+
|
| 19 |
+
### Model Parameters
|
| 20 |
+
- **Total Parameters:** ~40m parameters
|
| 21 |
+
- **Number of Experts:** 16
|
| 22 |
+
- **Expert Architecture:** Transformer-based with 12 layers per expert
|
| 23 |
+
- **Gating Network:** 4-layer MLP with softmax activation
|
| 24 |
+
- **Feature Extractors:** ResNet-50 for images, Transformer for LiDAR/GPS
|
| 25 |
+
|
| 26 |
+
## Training Details
|
| 27 |
+
- **Dataset:** 10 million driving scenarios from real-world and simulated environments
|
| 28 |
+
- **Batch Size:** 128
|
| 29 |
+
- **Learning Rate:** 2e-4 (decayed using cosine annealing)
|
| 30 |
+
- **Optimizer:** AdamW
|
| 31 |
+
- **Training Time:** 1h 24m 28s
|
| 32 |
+
- **Hardware:** 1x 16gb T4
|
| 33 |
+
- **Framework:** PyTorch
|
| 34 |
+
|
| 35 |
+
## Inference
|
| 36 |
+
To run inference using the MoE Car Model:
|
| 37 |
+
|
| 38 |
+
### Install Dependencies
|
| 39 |
+
```bash
|
| 40 |
+
pip install torch torchvision numpy opencv-python
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
### Load and Run the Model
|
| 44 |
+
```python
|
| 45 |
+
import torch
|
| 46 |
+
import torchvision.transforms as transforms
|
| 47 |
+
import cv2
|
| 48 |
+
from model import MoECarModel # Assuming model implementation is in model.py
|
| 49 |
+
|
| 50 |
+
# Load model
|
| 51 |
+
model = MoECarModel()
|
| 52 |
+
model.load_state_dict(torch.load("moe_car_model.pth"))
|
| 53 |
+
model.eval()
|
| 54 |
+
|
| 55 |
+
# Preprocessing function
|
| 56 |
+
def preprocess_image(image_path):
|
| 57 |
+
image = cv2.imread(image_path)
|
| 58 |
+
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
| 59 |
+
transform = transforms.Compose([
|
| 60 |
+
transforms.ToPILImage(),
|
| 61 |
+
transforms.Resize((224, 224)),
|
| 62 |
+
transforms.ToTensor(),
|
| 63 |
+
transforms.Normalize(mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5])
|
| 64 |
+
])
|
| 65 |
+
return transform(image).unsqueeze(0)
|
| 66 |
+
|
| 67 |
+
# Load sample image
|
| 68 |
+
image_tensor = preprocess_image("test_image.jpg")
|
| 69 |
+
|
| 70 |
+
# Run inference
|
| 71 |
+
with torch.no_grad():
|
| 72 |
+
output = model(image_tensor)
|
| 73 |
+
print("Predicted control outputs:", output)
|
| 74 |
+
```
|
| 75 |
+
|
| 76 |
+
## Applications
|
| 77 |
+
- Autonomous driving
|
| 78 |
+
- Driver assistance systems
|
| 79 |
+
- Traffic behavior prediction
|
| 80 |
+
- Reinforcement learning simulations
|
| 81 |
+
|
| 82 |
+
## Future Improvements
|
| 83 |
+
- Optimization for edge devices
|
| 84 |
+
- Integration with real-time sensor fusion
|
| 85 |
+
- Reinforcement learning fine-tuning
|
| 86 |
+
|
| 87 |
+
---
|