Spaces:
Runtime error
Runtime error
File size: 2,382 Bytes
4fc93b8 | 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 | # Deepfake Detection Service Backend
### Prerequisites
- Python 3.8+
- pip or conda
### Installation
1. **Navigate to the backend directory:**
```bash
cd backend
```
2. **Create a virtual environment (recommended):**
```bash
# Using venv
python -m venv venv
# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate
```
3. **Install dependencies:**
```bash
pip install -r requirements.txt
```
4. **Run the server:**
```bash
python main.py
```
The server will start on `http://127.0.0.1:8000`
## 📖 API Documentation
Once the server is running, interactive API documentation is available at:
- Swagger UI: `http://127.0.0.1:8000/docs`
- ReDoc: `http://127.0.0.1:8000/redoc`
## 🔌 API Endpoints
### Health Check
```bash
GET /
```
Returns service status and available models.
**Response:**
```json
{
"status": "ok",
"service": "Deepfake Detection Service",
"version": "1.0.0",
"available_models": ["mock"]
}
```
### Analyze File
```bash
POST /analyze
Content-Type: application/json
{
"file_url": "https://example.com/video.mp4",
"model": "mock"
}
```
**Request Parameters:**
- `file_url` (required): URL of the file to analyze
- `model` (optional): Detector model to use. Defaults to configured model
**Response (200 OK):**
```json
{
"is_deepfake": true,
"confidence": 0.847,
"analysis_time": 1.234,
"model_used": "mock"
}
```
**Error Responses:**
- `400 Bad Request`: Invalid URL, file too large, or unsupported model
- `408 Request Timeout`: File download timed out
- `500 Internal Server Error`: Server error during analysis
### Using curl:
```bash
curl -X POST http://localhost:8000/analyze \
-H "Content-Type: application/json" \
-d '{"file_url": "https://example.com/video.mp4"}'
```
The API provides comprehensive error handling:
```python
# Invalid URL
{
"error": "Invalid URL format",
"status_code": 400,
"details": null
}
# File too large
{
"error": "File size exceeds maximum allowed size of 104857600 bytes",
"status_code": 400,
"details": null
}
# Download timeout
{
"error": "File download timed out",
"status_code": 408,
"details": null
}
# Unsupported model
{
"error": "Detector model 'invalid' is not supported. Available models: mock",
"status_code": 400,
"details": null
}
```
|