File size: 3,863 Bytes
63ed3a7 | 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 | # π€ Integrated Inference Server
This is an integrated ACT Model Inference Server that combines **FastAPI** and **Gradio** on a single port, perfect for deployment and development.
## π Quick Start
```bash
# Install dependencies
uv sync
# Run the integrated server
uv run python launch_simple.py --host 0.0.0.0 --port 7860
```
## π‘ Access Points
Once running, you can access:
- **π¨ Gradio UI**: http://localhost:7860/
- **π API Documentation**: http://localhost:7860/api/docs
- **π Health Check**: http://localhost:7860/api/health
- **π OpenAPI Schema**: http://localhost:7860/api/openapi.json
## ποΈ Architecture
### Integration Approach
- **Single Process**: Everything runs in one Python process
- **Single Port**: Both API and UI on the same port (7860)
- **FastAPI at `/api`**: Full REST API with automatic documentation
- **Gradio at `/`**: User-friendly web interface
- **Direct Session Management**: UI communicates directly with session manager (no HTTP overhead)
### Key Components
1. **`simple_integrated.py`**: Main integration logic
- Creates FastAPI app and mounts it at `/api`
- Creates Gradio interface and mounts it at `/`
- Provides `SimpleServerManager` for direct session access
2. **`launch_simple.py`**: Entry point script
- Handles command-line arguments
- Starts the integrated application
3. **`main.py`**: Core FastAPI application
- Session management endpoints
- Policy loading and inference
- OpenAPI documentation
## π§ Features
### For UI Users
- β
**Simple Interface**: Create and manage AI sessions through web UI
- β
**Real-time Status**: Live session monitoring and control
- β
**Direct Performance**: No HTTP overhead for UI operations
### For API Users
- β
**Full REST API**: Complete programmatic access
- β
**Interactive Docs**: Automatic Swagger/OpenAPI documentation
- β
**Standard Endpoints**: `/sessions`, `/health`, etc.
- β
**CORS Enabled**: Ready for frontend integration
### For Deployment
- β
**Single Port**: Easy to deploy behind reverse proxy
- β
**Docker Ready**: Dockerfile included
- β
**Health Checks**: Built-in monitoring endpoints
- β
**HuggingFace Spaces**: Perfect for cloud deployment
## π API Usage Examples
### Health Check
```bash
curl http://localhost:7860/api/health
```
### Create Session
```bash
curl -X POST http://localhost:7860/api/sessions \
-H "Content-Type: application/json" \
-d '{
"session_id": "my-robot",
"policy_path": "./checkpoints/act_so101_beyond",
"camera_names": ["front"],
"arena_server_url": "http://localhost:8000"
}'
```
### Start Inference
```bash
curl -X POST http://localhost:7860/api/sessions/my-robot/start
```
### Get Session Status
```bash
curl http://localhost:7860/api/sessions/my-robot
```
## π³ Docker Usage
```bash
# Build
docker build -t inference-server .
# Run
docker run -p 7860:7860 inference-server
```
## π Testing
Run the integration test to verify everything works:
```bash
uv run python test_integration.py
```
## π‘ Development Tips
### Use Both Interfaces
- **Development**: Use Gradio UI for quick testing and setup
- **Production**: Use REST API for automated systems
- **Integration**: Both can run simultaneously
### Session Management
- UI uses direct session manager access (faster)
- API uses HTTP endpoints (standard REST)
- Both share the same underlying session data
### Debugging
- Check logs for startup issues
- Use `/api/health` to verify API is working
- Visit `/api/docs` for interactive API testing
## π Benefits of This Approach
1. **Flexibility**: Use UI or API as needed
2. **Performance**: Direct access for UI, standard REST for API
3. **Deployment**: Single port, single process
4. **Documentation**: Auto-generated API docs
5. **Development**: Fast iteration with integrated setup |