Spaces:
Runtime error
Runtime error
File size: 7,240 Bytes
11b91b6 779f141 11b91b6 779f141 11b91b6 779f141 11b91b6 779f141 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
---
title: Baseer Self-Driving API
emoji: π
colorFrom: blue
colorTo: red
sdk: docker
app_port: 7860
pinned: true
license: mit
short_description: A RESTful API for an InterFuser-based self-driving model.
tags:
- computer-vision
- autonomous-driving
- deep-learning
- fastapi
- pytorch
- interfuser
- graduation-project
- carla
- self-driving
---
# π Baseer Self-Driving API
| Service | Status |
|---|---|
| **API Status** | [](https://BaseerAI-baseer-server.hf.space) |
| **Model** | [](https://huggingface.co/BaseerAI/Interfuser-Baseer-v1) |
| **Frameworks** | [](https://fastapi.tiangolo.com/) [](https://pytorch.org/) |
## π Project Description
**Baseer** is an advanced self-driving system that provides a robust, real-time API for autonomous vehicle control. This Space hosts the FastAPI server that acts as an interface to the fine-tuned **[Interfuser-Baseer-v1](https://huggingface.co/BaseerAI/Interfuser-Baseer-v1)** model.
The system is designed to take a live camera feed and vehicle measurements, process them through the deep learning model, and return actionable control commands and a comprehensive scene analysis.
---
## ποΈ Architecture
This project follows a decoupled client-server architecture, where the model and the application are managed separately for better modularity and scalability.
```
+-----------+ +------------------------+ +--------------------------+
| | | | | |
| Client | -> | Baseer API (Space) | -> | Interfuser Model (Hub) |
|(e.g.CARLA)| | (FastAPI Server) | | (Private/Gated Weights) |
| | | | | |
+-----------+ +------------------------+ +--------------------------+
HTTP Loads Model Model Repository
Request
```
## β¨ Key Features
### π§ **Advanced Perception Engine**
- **Powered by:** The [Interfuser-Baseer-v1](https://huggingface.co/BaseerAI/Interfuser-Baseer-v1) model.
- **Focus:** High-accuracy traffic object detection and safe waypoint prediction.
- **Scene Analysis:** Real-time assessment of junctions, traffic lights, and stop signs.
### β‘ **High-Performance API**
- **Framework:** Built with **FastAPI** for high throughput and low latency.
- **Stateful Sessions:** Manages multiple, independent driving sessions, each with its own tracker and controller state.
- **RESTful Interface:** Intuitive and easy-to-use API design.
### π **Comprehensive Outputs**
- **Control Commands:** `steer`, `throttle`, `brake`.
- **Scene Analysis:** Probabilities for junctions, traffic lights, and stop signs.
- **Predicted Waypoints:** The model's intended path for the next 10 steps.
- **Visual Dashboard:** A generated image that provides a complete, human-readable overview of the current state.
---
## π How to Use
Interact with the API by making HTTP requests to its endpoints. The typical workflow is to start a session, run steps in a loop, and then end the session.
### 1. Start a New Session
This will initialize a new set of tracker and controller instances on the server.
**Request:**
```bash
curl -X POST "https://BaseerAI-baseer-server.hf.space/start_session"
```
**Example Response:**
```json
{
"session_id": "a1b2c3d4-e5f6-7890-1234-567890abcdef"
}
```
### 2. Run a Simulation Step
Send the current camera view and vehicle measurements to be processed. The API will return control commands and a full analysis.
**Request:**
```bash
curl -X POST "https://BaseerAI-baseer-server.hf.space/run_step" \
-H "Content-Type: application/json" \
-d '{
"session_id": "a1b2c3d4-e5f6-7890-1234-567890abcdef",
"image_b64": "your-base64-encoded-bgr-image-string",
"measurements": {
"pos_global": [105.0, -20.0],
"theta": 1.57,
"speed": 5.5,
"target_point": [10.0, 0.0]
}
}'
```
**Example Response:**
```json
{
"control_commands": {
"steer": 0.05,
"throttle": 0.6,
"brake": false
},
"scene_analysis": {
"is_junction": 0.02,
"traffic_light_state": 0.95,
"stop_sign": 0.01
},
"predicted_waypoints": [
[1.0, 0.05],
[2.0, 0.06],
[3.0, 0.07],
[4.0, 0.07],
[5.0, 0.08],
[6.0, 0.08],
[7.0, 0.09],
[8.0, 0.09],
[9.0, 0.10],
[10.0, 0.10]
],
"dashboard_b64": "a-very-long-base64-string-representing-the-dashboard-image...",
"reason": "Red Light"
}
```
**Response Fields:**
- **`control_commands`**: The final commands to be applied to the vehicle.
- **`scene_analysis`**: Probabilities for different road hazards. A high `traffic_light_state` value (e.g., > 0.5) indicates a red light.
- **`predicted_waypoints`**: The model's intended path, relative to the vehicle.
- **`dashboard_b64`**: A Base64-encoded JPEG image of the full dashboard view, which can be directly displayed in a client application.
- **`reason`**: A human-readable string explaining the primary reason for the control action (e.g., "Following ID 12", "Red Light", "Cruising").
### 3. End the Session
This will clean up the session data from the server.
**Request:**
```bash
curl -X POST "https://BaseerAI-baseer-server.hf.space/end_session?session_id=a1b2c3d4-e5f6-7890-1234-567890abcdef"
```
**Example Response:**
```json
{
"message": "Session a1b2c3d4-e5f6-7890-1234-567890abcdef ended."
}
```
---
## π‘ API Endpoints
| Endpoint | Method | Description |
|---|---|---|
| `/` | GET | Landing page with API status. |
| `/docs` | GET | Interactive API documentation (Swagger UI). |
| `/start_session` | POST | Initializes a new driving session. |
| `/run_step` | POST | Processes a single frame and returns control commands. |
| `/end_session` | POST | Terminates a specific session. |
| `/sessions` | GET | Lists all currently active sessions. |
---
## π― Intended Use Cases & Limitations
### β
Optimal Use Cases
- Simulating driving in CARLA environments.
- Research in end-to-end autonomous driving.
- Testing perception and control modules in a closed-loop system.
- Real-time object detection and trajectory planning.
### β οΈ Limitations
- **Simulation-Only:** Trained exclusively on CARLA data. Not suitable for real-world driving.
- **Vision-Based:** Relies on a single front-facing camera and has inherent blind spots.
- **No LiDAR:** Lacks the robustness of sensor fusion in adverse conditions.
---
## π οΈ Development
This project is part of a graduation thesis in Artificial Intelligence.
- **Deep Learning:** PyTorch
- **API Server:** FastAPI
- **Image Processing:** OpenCV
- **Scientific Computing:** NumPy
## π Contact
For inquiries or support, please use the **Community** tab in this Space or open an issue in the project's GitHub repository (if available).
---
**Developed by:** Adam Altawil
**License:** MIT |