Update detection_api.py
Browse files- detection_api.py +16 -0
detection_api.py
CHANGED
|
@@ -7,6 +7,7 @@ import aiofiles
|
|
| 7 |
from pathlib import Path
|
| 8 |
import uuid
|
| 9 |
import logging
|
|
|
|
| 10 |
|
| 11 |
# Import the smart sequential moderator
|
| 12 |
from sequential_moderation import SmartSequentialModerator
|
|
@@ -40,6 +41,21 @@ MAX_VIDEO_SIZE = 500 * 1024 * 1024 # 500MB
|
|
| 40 |
# Global moderator
|
| 41 |
moderator = None
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
# ============== Response Model ==============
|
| 45 |
class DetectionResponse(BaseModel):
|
|
|
|
| 7 |
from pathlib import Path
|
| 8 |
import uuid
|
| 9 |
import logging
|
| 10 |
+
from gunicorn.app.base import BaseApplication
|
| 11 |
|
| 12 |
# Import the smart sequential moderator
|
| 13 |
from sequential_moderation import SmartSequentialModerator
|
|
|
|
| 41 |
# Global moderator
|
| 42 |
moderator = None
|
| 43 |
|
| 44 |
+
class StandaloneApplication(BaseApplication):
|
| 45 |
+
def __init__(self, app, options=None):
|
| 46 |
+
self.options = options or {}
|
| 47 |
+
self.application = app
|
| 48 |
+
super().__init__()
|
| 49 |
+
|
| 50 |
+
def load_config(self):
|
| 51 |
+
config = {key: value for key, value in self.options.items()
|
| 52 |
+
if key in self.cfg.settings and value is not None}
|
| 53 |
+
for key, value in config.items():
|
| 54 |
+
self.cfg.set(key.lower(), value)
|
| 55 |
+
|
| 56 |
+
def load(self):
|
| 57 |
+
return self.application
|
| 58 |
+
|
| 59 |
|
| 60 |
# ============== Response Model ==============
|
| 61 |
class DetectionResponse(BaseModel):
|